cli: List patches by last update

To help users notice changes to patches, make `rad patch` order patches
by revision timestamp instead of patch timestamp.
This commit is contained in:
Slack Coder 2023-05-04 08:59:51 -05:00 committed by Alexis Sellier
parent 091154faed
commit 3e2cf83f9b
No known key found for this signature in database
3 changed files with 17 additions and 9 deletions

View File

@ -42,7 +42,7 @@ It will now be listed as one of the project's open patches.
``` ```
$ rad patch $ rad patch
╭──────────────────────────────────────────────────────────────────────────────────────────────╮ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮
│ ● ID Title Author Head + - Opened │ ● ID Title Author Head + - Updated
├──────────────────────────────────────────────────────────────────────────────────────────────┤ ├──────────────────────────────────────────────────────────────────────────────────────────────┤
│ ● de3096d Define power requirements z6MknSL…StBU8Vi (you) 3e674d1 +0 -0 4 months ago │ │ ● de3096d Define power requirements z6MknSL…StBU8Vi (you) 3e674d1 +0 -0 4 months ago │
╰──────────────────────────────────────────────────────────────────────────────────────────────╯ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯

View File

@ -42,7 +42,7 @@ It will now be listed as one of the project's open patches.
``` ```
$ rad patch $ rad patch
╭──────────────────────────────────────────────────────────────────────────────────────────────╮ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮
│ ● ID Title Author Head + - Opened │ ● ID Title Author Head + - Updated
├──────────────────────────────────────────────────────────────────────────────────────────────┤ ├──────────────────────────────────────────────────────────────────────────────────────────────┤
│ ● 5f0a547 Define power requirements z6Mkt67…v4N1tRk (you) 3e674d1 +0 -0 4 months ago │ │ ● 5f0a547 Define power requirements z6Mkt67…v4N1tRk (you) 3e674d1 +0 -0 4 months ago │
╰──────────────────────────────────────────────────────────────────────────────────────────────╯ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯

View File

@ -52,17 +52,20 @@ pub fn run(
term::format::bold(String::from("Head")).into(), term::format::bold(String::from("Head")).into(),
term::format::bold(String::from("+")).into(), term::format::bold(String::from("+")).into(),
term::format::bold(String::from("-")).into(), term::format::bold(String::from("-")).into(),
term::format::bold(String::from("Opened")).into(), term::format::bold(String::from("Updated")).into(),
]); ]);
table.divider(); table.divider();
let me = *profile.id(); let me = *profile.id();
all.sort_by(|(id1, p1), (id2, p2)| { all.sort_by(|(id1, p1), (id2, p2)| {
let is_me = (p2.author().id().as_key() == &me).cmp(&(p1.author().id().as_key() == &me)); let is_me = (p2.author().id().as_key() == &me).cmp(&(p1.author().id().as_key() == &me));
let by_timestamp = p2.timestamp().cmp(&p1.timestamp());
let by_id = id1.cmp(id2); let by_id = id1.cmp(id2);
let by_rev_time = p2
.latest()
.map(|(_, r)| r.timestamp())
.cmp(&p1.latest().map(|(_, r)| r.timestamp()));
is_me.then(by_timestamp).then(by_id) is_me.then(by_rev_time).then(by_id)
}); });
let mut errors = Vec::new(); let mut errors = Vec::new();
@ -118,10 +121,15 @@ pub fn row(
term::format::secondary(term::format::oid(revision.head())).into(), term::format::secondary(term::format::oid(revision.head())).into(),
term::format::positive(format!("+{}", stats.insertions())).into(), term::format::positive(format!("+{}", stats.insertions())).into(),
term::format::negative(format!("-{}", stats.deletions())).into(), term::format::negative(format!("-{}", stats.deletions())).into(),
term::format::timestamp(&patch.timestamp()) term::format::timestamp(
.dim() &patch
.italic() .latest()
.into(), .map(|(_, r)| r.timestamp())
.unwrap_or_default(),
)
.dim()
.italic()
.into(),
]) ])
} }