dashboard: distinguish missing-dir vs missing-git in approval_diff
This commit is contained in:
parent
9af5234f74
commit
99867195e5
1 changed files with 21 additions and 7 deletions
|
|
@ -157,14 +157,22 @@ async fn render_approvals(approvals: &[Approval]) -> String {
|
|||
}
|
||||
|
||||
async fn approval_diff(agent: &str, commit_ref: &str) -> String {
|
||||
let applied = Coordinator::agent_applied_dir(agent).join("agent.nix");
|
||||
let proposed = Coordinator::agent_proposed_dir(agent);
|
||||
if !proposed.exists() {
|
||||
return format!(
|
||||
"(proposed dir {} does not exist — agent destroyed?)",
|
||||
proposed.display()
|
||||
);
|
||||
}
|
||||
if !proposed.join(".git").exists() {
|
||||
return format!("(no git repo at {})", proposed.display());
|
||||
}
|
||||
let applied = Coordinator::agent_applied_dir(agent).join("agent.nix");
|
||||
let applied_text = std::fs::read_to_string(&applied).unwrap_or_default();
|
||||
let proposed_text = match git_show(&proposed, commit_ref).await {
|
||||
Ok(s) => s,
|
||||
Err(e) => return format!("(error reading proposed agent.nix: {e:#})"),
|
||||
};
|
||||
unified_diff(&applied_text, &proposed_text)
|
||||
match git_show(&proposed, commit_ref).await {
|
||||
Ok(s) => unified_diff(&applied_text, &s),
|
||||
Err(e) => format!("(error: {e:#})"),
|
||||
}
|
||||
}
|
||||
|
||||
async fn git_show(proposed_dir: &Path, commit_ref: &str) -> Result<String> {
|
||||
|
|
@ -173,7 +181,13 @@ async fn git_show(proposed_dir: &Path, commit_ref: &str) -> Result<String> {
|
|||
.args(["show", &format!("{commit_ref}:agent.nix")])
|
||||
.output()
|
||||
.await
|
||||
.context("git show")?;
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"spawn `git show` in {} (HYPERHIVE_GIT={})",
|
||||
proposed_dir.display(),
|
||||
std::env::var("HYPERHIVE_GIT").unwrap_or_else(|_| "<unset>".into()),
|
||||
)
|
||||
})?;
|
||||
if !out.status.success() {
|
||||
anyhow::bail!(
|
||||
"git show {commit_ref}:agent.nix failed: {}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue