fix: key review checkmarks by file snapshots instead of revision pairs
This commit is contained in:
@@ -2770,6 +2770,7 @@ impl Repository {
|
||||
continue;
|
||||
}
|
||||
files.push(ChangedFile {
|
||||
review_revisions: None,
|
||||
path: path.clone(),
|
||||
old_path: None,
|
||||
status: if a.is_none() {
|
||||
@@ -2827,6 +2828,10 @@ impl Repository {
|
||||
.files
|
||||
.iter()
|
||||
.map(|(path, old_path, status)| ChangedFile {
|
||||
review_revisions: Some([
|
||||
review_file_revision(prepared.left.get(old_path.as_ref().unwrap_or(path))),
|
||||
review_file_revision(prepared.right.get(path)),
|
||||
]),
|
||||
path: path.clone(),
|
||||
old_path: old_path.clone(),
|
||||
status: *status,
|
||||
@@ -2902,6 +2907,7 @@ impl Repository {
|
||||
)?;
|
||||
file.status = *status;
|
||||
file.old_path = old_path.clone();
|
||||
file.review_revisions = Some([review_file_revision(before), review_file_revision(after)]);
|
||||
Ok(file)
|
||||
}
|
||||
fn changed_file(
|
||||
@@ -2972,6 +2978,7 @@ impl Repository {
|
||||
};
|
||||
notices.dedup();
|
||||
Ok(ChangedFile {
|
||||
review_revisions: None,
|
||||
path: path.to_path_buf(),
|
||||
old_path: None,
|
||||
status,
|
||||
@@ -2990,6 +2997,14 @@ impl Repository {
|
||||
}
|
||||
}
|
||||
|
||||
fn review_file_revision(file: Option<&FileData>) -> String {
|
||||
// Git object IDs cover exact bytes (including binary data and EOF), without loading blobs.
|
||||
format!(
|
||||
"file:{}",
|
||||
serde_json::to_string(&file.map(file_identity)).unwrap()
|
||||
)
|
||||
}
|
||||
|
||||
fn file_identity(file: &FileData) -> (&str, Option<&str>, &[u8], Option<&str>) {
|
||||
(
|
||||
&file.mode,
|
||||
|
||||
Reference in New Issue
Block a user