fix: resolve git_context field references after cherry-pick merge

This commit is contained in:
YeonGyu-Kim
2026-04-07 15:20:20 +09:00
parent dab16c230a
commit 8f4651a096

View File

@@ -328,10 +328,14 @@ fn render_project_context(project_context: &ProjectContext) -> String {
lines.push("Git status snapshot:".to_string()); lines.push("Git status snapshot:".to_string());
lines.push(status.clone()); lines.push(status.clone());
} }
if let Some(commits) = &project_context.git_recent_commits { if let Some(ref gc) = project_context.git_context {
if !gc.recent_commits.is_empty() {
lines.push(String::new()); lines.push(String::new());
lines.push("Recent commits (last 5):".to_string()); lines.push("Recent commits (last 5):".to_string());
lines.push(commits.clone()); for c in &gc.recent_commits {
lines.push(format!(" {} {}", c.hash, c.subject));
}
}
} }
if let Some(diff) = &project_context.git_diff { if let Some(diff) = &project_context.git_diff {
lines.push(String::new()); lines.push(String::new());
@@ -735,14 +739,12 @@ mod tests {
.render(); .render();
// then: branch, recent commits and staged files are present in context // then: branch, recent commits and staged files are present in context
let commits = context let gc = context.git_context.as_ref().expect("git context should be present");
.git_recent_commits let commits: String = gc.recent_commits.iter().map(|c| c.subject.clone()).collect::<Vec<_>>().join("\n");
.as_deref()
.expect("recent commits should be present");
assert!(commits.contains("first commit")); assert!(commits.contains("first commit"));
assert!(commits.contains("second commit")); assert!(commits.contains("second commit"));
assert!(commits.contains("third commit")); assert!(commits.contains("third commit"));
assert_eq!(commits.lines().count(), 3); assert_eq!(gc.recent_commits.len(), 3);
let status = context.git_status.as_deref().expect("status snapshot"); let status = context.git_status.as_deref().expect("status snapshot");
assert!(status.contains("## main")); assert!(status.contains("## main"));