cli: show head on patch opened

Previously, the head of the opened patch would not be displayed, and
so the user could not tell what it was if any updates were applied.

Show the head for the opened revision. The below shows the difference
between before and after, respectively:

```
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by z6MknSL…StBU8Vi (you) now                               │
│ ↑ updated to 8d6692ce2b2219a54d09ccd5feefedb2bae33eba (02bef3f) now │
│ ↑ updated to 8438ab3940316abe65c93982a0a8f39688400359 (9304dbc) now │
╰─────────────────────────────────────────────────────────────────────╯
```

```
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by z6MknSL…StBU8Vi (you) (8b0ea80) now                     │
│ ↑ updated to 8d6692ce2b2219a54d09ccd5feefedb2bae33eba (02bef3f) now │
│ ↑ updated to 8438ab3940316abe65c93982a0a8f39688400359 (9304dbc) now │
╰─────────────────────────────────────────────────────────────────────╯
```

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny
2024-01-10 15:51:09 +01:00
committed by cloudhead
parent c8afda2ddf
commit 498da296fd
13 changed files with 33 additions and 27 deletions
+7 -1
View File
@@ -183,6 +183,8 @@ struct Opened<'a> {
author: Author<'a>,
/// When the patch was created.
timestamp: cob::Timestamp,
/// The commit head of the `Revision`.
head: git::Oid,
/// Any updates performed on the root `Revision`.
updates: Vec<Update<'a>>,
}
@@ -216,6 +218,7 @@ impl<'a> Opened<'a> {
Opened {
author: Author::new(&patch.author().id, profile),
timestamp: patch.timestamp(),
head: revision.head(),
updates: updates.into_iter().map(|(_, up)| up).collect(),
}
}
@@ -229,7 +232,10 @@ impl<'a> Opened<'a> {
.space()
.extend(self.author.line())
.space()
.extend([term::format::dim(term::format::timestamp(self.timestamp)).into()]),
.extend(term::Line::spaced([
term::format::parens(term::format::secondary(term::format::oid(self.head))).into(),
term::format::dim(term::format::timestamp(self.timestamp)).into(),
])),
)
.chain(self.updates.into_iter().map(|up| {
term::Line::spaced([term::Label::space(), term::Label::from("└─ ")])