mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-21 10:30:48 +08:00
cob: Guarantee there is always a latest revision
We change `Patch::latest` to always return something, because a patch is malformed if it doesn't have at least one revision, and thus would not load in the first place. This also implies that there is a latest revision in the face of concurrent updates. Note that currently, traversal order for concurrent updates is still random. This will be fixed in another patch.
This commit is contained in:
@@ -26,7 +26,7 @@ pub fn load_proposed(repository: &Repository) -> Result<Vec<(PatchId, Patch)>> {
|
||||
}
|
||||
|
||||
pub fn sync_status(repository: &Repository, patch: &Patch) -> Result<(usize, usize)> {
|
||||
let (_, revision) = patch.latest().unwrap();
|
||||
let (_, revision) = patch.latest();
|
||||
let target_oid = merge_target_oid(patch.target(), repository)?;
|
||||
let (ahead, behind) = repository
|
||||
.raw()
|
||||
|
||||
@@ -49,10 +49,8 @@ pub fn format_timestamp(patch: &Patch) -> String {
|
||||
}
|
||||
|
||||
pub fn format_comments(patch: &Patch) -> String {
|
||||
let count = match patch.latest() {
|
||||
Some((_, rev)) => rev.discussion().len(),
|
||||
None => 0,
|
||||
};
|
||||
let count: usize = patch.revisions().map(|(_, r)| r.discussion().len()).sum();
|
||||
|
||||
format!("{count}")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user