cli: Stabilize sort order of inbox repos

Sort repositories before displaying them.
This commit is contained in:
cloudhead 2024-02-12 12:01:54 +01:00
parent 9576a6496b
commit b477864b83
No known key found for this signature in database
2 changed files with 13 additions and 10 deletions

View File

@ -28,17 +28,17 @@ $ rad inbox --sort-by id
``` ~alice ``` ~alice
$ rad inbox --all --sort-by id $ rad inbox --all --sort-by id
╭──────────────────────────────────────────────────────────╮
│ radicle-git │
├──────────────────────────────────────────────────────────┤
│ 3 ● patch Copyright fixes [ ... ] opened now │
╰──────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────╮ ╭──────────────────────────────────────────────────────────────╮
│ heartwood │ │ heartwood │
├──────────────────────────────────────────────────────────────┤ ├──────────────────────────────────────────────────────────────┤
│ 1 ● issue No license file [ .. ] opened now │ │ 1 ● issue No license file [ .. ] opened now │
│ 2 ● branch Change copyright bob/copy created now │ │ 2 ● branch Change copyright bob/copy created now │
╰──────────────────────────────────────────────────────────────╯ ╰──────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────╮
│ radicle-git │
├──────────────────────────────────────────────────────────┤
│ 3 ● patch Copyright fixes [ ... ] opened now │
╰──────────────────────────────────────────────────────────╯
``` ```
``` ~alice ``` ~alice

View File

@ -201,12 +201,15 @@ fn list_all<'a>(
notifs: &notifications::StoreReader, notifs: &notifications::StoreReader,
storage: &Storage, storage: &Storage,
) -> anyhow::Result<Vec<term::VStack<'a>>> { ) -> anyhow::Result<Vec<term::VStack<'a>>> {
let mut repos = Vec::new(); let mut repos = storage.repositories()?;
for repo in storage.repositories()? { repos.sort_by_key(|r| r.rid);
let repo = list_repo(repo.rid, sort_by, notifs, storage)?;
repos.extend(repo.into_iter()); let mut vstacks = Vec::new();
for repo in repos {
let vstack = list_repo(repo.rid, sort_by, notifs, storage)?;
vstacks.extend(vstack.into_iter());
} }
Ok(repos) Ok(vstacks)
} }
fn list_repo<'a, R: ReadStorage>( fn list_repo<'a, R: ReadStorage>(