mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-08 00:54:49 +08:00
fix: resolve git_context field references after cherry-pick merge
This commit is contained in:
@@ -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 {
|
||||||
lines.push(String::new());
|
if !gc.recent_commits.is_empty() {
|
||||||
lines.push("Recent commits (last 5):".to_string());
|
lines.push(String::new());
|
||||||
lines.push(commits.clone());
|
lines.push("Recent commits (last 5):".to_string());
|
||||||
|
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"));
|
||||||
|
|||||||
Reference in New Issue
Block a user