lifecycle: HYPERHIVE_GIT env override (bypass PATH); module sets it

This commit is contained in:
müde 2026-05-15 00:24:51 +02:00
parent 42e7761ea1
commit 7c1ed07cf2
4 changed files with 34 additions and 5 deletions

View file

@ -20,7 +20,6 @@ use axum::{
routing::{get, post},
};
use hive_sh4re::Approval;
use tokio::process::Command;
use tokio_stream::wrappers::BroadcastStream;
use tokio_stream::{Stream, StreamExt};
@ -169,7 +168,7 @@ async fn approval_diff(agent: &str, commit_ref: &str) -> String {
}
async fn git_show(proposed_dir: &Path, commit_ref: &str) -> Result<String> {
let out = Command::new("git")
let out = lifecycle::git_command()
.current_dir(proposed_dir)
.args(["show", &format!("{commit_ref}:agent.nix")])
.output()

View file

@ -198,7 +198,7 @@ pub async fn setup_applied(applied_dir: &Path, name: &str, hyperhive_flake: &str
/// proposed repo, write it into the applied repo, commit. Hive-c0re alone
/// advances `applied`'s `main`; the manager only sees `proposed/`.
pub async fn apply_commit(applied_dir: &Path, proposed_dir: &Path, commit_ref: &str) -> Result<()> {
let out = Command::new("git")
let out = git_command()
.current_dir(proposed_dir)
.args(["show", &format!("{commit_ref}:agent.nix")])
.output()
@ -243,8 +243,16 @@ async fn git_commit(dir: &Path, message: &str) -> Result<()> {
.await
}
/// Spawn `git` honoring the `HYPERHIVE_GIT` env var (absolute path baked in
/// by the NixOS module), falling back to bare `git` (PATH lookup) otherwise.
#[must_use]
pub fn git_command() -> Command {
let exe = std::env::var("HYPERHIVE_GIT").unwrap_or_else(|_| "git".into());
Command::new(exe)
}
async fn git(dir: &Path, args: &[&str]) -> Result<()> {
let out = Command::new("git")
let out = git_command()
.current_dir(dir)
.args(args)
.output()
@ -263,7 +271,7 @@ async fn git(dir: &Path, args: &[&str]) -> Result<()> {
/// Returns true if the command exits 0.
async fn git_status(dir: &Path, args: &[&str]) -> Result<bool> {
let st = Command::new("git")
let st = git_command()
.current_dir(dir)
.args(args)
.status()