feat: scope local reviews to comparisons

This commit is contained in:
2026-10-25 01:00:58 +02:00
parent 815fcccbe8
commit 448c3bf477
15 changed files with 760 additions and 72 deletions
+22 -2
View File
@@ -154,6 +154,7 @@ fn cli_resolves_only_the_requested_comment_and_preserves_original_feedback() {
let storage = root.join("reviews");
let mut store = Store::open(&storage).unwrap();
let mut review = Review::new(root.join("repo"));
review.comparison = Some(["frozen-base".into(), "working:frozen-tip".into()]);
review.summary = "Keep summary".into();
review.verdict = Some(Verdict::ChangesRequested);
review.comments = [u64::MAX, 2, 3]
@@ -176,6 +177,11 @@ fn cli_resolves_only_the_requested_comment_and_preserves_original_feedback() {
let mut other = Review::new(root.join("other"));
other.comments = review.comments.clone();
store.save(&mut other).unwrap();
let mut source = Review::new(review.root.clone());
store.save(&mut source).unwrap();
let mut reversed = Review::new(review.root.clone());
reversed.comparison = Some(["working:frozen-tip".into(), "frozen-base".into()]);
store.save(&mut reversed).unwrap();
let id = review.storage_id.unwrap();
let id_text = id.to_string();
let cli = |repo: &str, args: &[&str]| {
@@ -214,6 +220,7 @@ fn cli_resolves_only_the_requested_comment_and_preserves_original_feedback() {
let json: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
assert_eq!(json["id"], id);
assert_eq!(json["revision"], review.storage_revision + 1);
assert_eq!(json["comparison"], serde_json::json!(review.comparison));
assert_eq!(
json["counts"],
serde_json::json!({"total": 3, "resolved": 2, "unresolved": 1})
@@ -227,6 +234,7 @@ fn cli_resolves_only_the_requested_comment_and_preserves_original_feedback() {
assert_eq!(loaded.summary, review.summary);
assert_eq!(loaded.verdict, review.verdict);
assert_eq!(loaded.reviewed_files, review.reviewed_files);
assert_eq!(loaded.comparison, review.comparison);
assert!(store.save(&mut review).is_err()); // Stale editors cannot undo resolution.
assert_eq!(store.load(&review.root, id).unwrap().comments, expected);
@@ -264,8 +272,20 @@ fn cli_resolves_only_the_requested_comment_and_preserves_original_feedback() {
let output = cli("repo", &["list", "--json"]);
assert!(output.status.success(), "{:?}", output);
let list: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
assert_eq!(list["reviews"].as_array().unwrap().len(), 1);
assert_eq!(list["reviews"][0]["counts"], json["counts"]);
assert_eq!(list["reviews"].as_array().unwrap().len(), 3);
assert_eq!(
list["reviews"][0]["comparison"],
serde_json::json!(reversed.comparison)
);
assert!(list["reviews"][1]["comparison"].is_null());
assert_eq!(list["reviews"][2]["comparison"], json["comparison"]);
assert_eq!(list["reviews"][2]["counts"], json["counts"]);
let output = cli("repo", &["list"]);
assert!(output.status.success(), "{:?}", output);
let text = String::from_utf8(output.stdout).unwrap();
assert!(text.contains("Scope: source"));
assert!(text.contains("Scope: comparison frozen-base → working:frozen-tip"));
assert!(text.contains("Scope: comparison working:frozen-tip → frozen-base"));
let output = cli("repo", &["resolve", &id_text, "2"]);
assert!(output.status.success(), "{:?}", output);
let text = String::from_utf8(output.stdout).unwrap();