cli: Make `rad patch show` prettier

The output of this command is confusing. It is not clear which of the
hashes printed is that of the revision and which one is the respective
head commit.

Further, the hash is omitted on the initial revision, adding confusion.

Further, the terminology of "revised" vs. "updated" is confusing.

This rewrites `timeline.rs` to drop the distinction between various
revisions (in wording, the small icon is still different) and cleans up
the output.

Attention is paid to alignment of the output. Now all verbs of updates
("accepted", "rejected", "reviewed", "merged") are aligned, and authors
("… by …") are also aligned.

The rewrite itself is not for better code quality or readability.
Note that all the code in this file only accessed via one `fn` by one
callsite in the implementation of `rad patch`.
This commit is contained in:
Lorenz Leutgeb 2025-08-26 13:51:07 +02:00 committed by Erik Kundt
parent 43246fe6c8
commit f9ff484c9e
18 changed files with 560 additions and 623 deletions

View File

@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `rad clone` now supports the flag `--bare` which works analoguously to
`git clone --bare`.
- `rad patch show` now has improved output. It does not distinguish between the
original author's updates and other updated, each update is marked as
`Revision`, and the general output is cleaned up. It also shows `Base` by
default without the `--verbose` flag.
- `rad init --setup-signing` now works on bare repositories.
- `git-remote-rad` now correctly reports the default branch to Git by listing
the symbolic reference `HEAD`.

View File

@ -46,6 +46,7 @@ $ rad patch show 89f7afb
│ Patch 89f7afb1511b976482b21f6b2f39aef7f4fb88a2 │
│ Author alice (you) │
│ Head 8945f6189adf027892c85ac57f7e9341049c2537 │
│ Base [.. ] │
│ Branches changes │
│ Commits ahead 2, behind 0 │
│ Status open │
@ -69,6 +70,7 @@ $ rad patch show 89f7afb
│ Patch 89f7afb1511b976482b21f6b2f39aef7f4fb88a2 │
│ Author alice (you) │
│ Head 8945f6189adf027892c85ac57f7e9341049c2537 │
│ Base [.. ] │
│ Branches changes │
│ Commits ahead 2, behind 0 │
│ Status open │
@ -161,6 +163,7 @@ $ rad patch show 89f7afb
│ Patch 89f7afb1511b976482b21f6b2f39aef7f4fb88a2 │
│ Author alice (you) │
│ Head f1339dd109e538c6b3a7fed3e72403e1b4db08c9 │
│ Base [.. ] │
│ Branches changes │
│ Commits ahead 3, behind 0 │
│ Status open │

View File

@ -83,35 +83,37 @@ $ rad patch --merged
│ ✓ [ ... ] First change alice (you) - 20aa5dd +0 -0 now │
╰─────────────────────────────────────────────────────────────────────────────╯
$ rad patch show 696ec5508494692899337afe6713fe1796d0315c
╭────────────────────────────────────────────────────────────────╮
│ Title First change │
│ Patch 696ec5508494692899337afe6713fe1796d0315c │
│ Author alice (you) │
│ Head 20aa5dde6210796c3a2f04079b42316a31d02689 │
│ Branches feature/1 │
│ Commits ahead 0, behind 2 │
│ Status merged │
├────────────────────────────────────────────────────────────────┤
│ 20aa5dd First change │
├────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (20aa5dd) now │
│ └─ ✓ merged by alice (you) at revision 696ec55 (20aa5dd) now │
╰────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────╮
│ Title First change │
│ Patch 696ec5508494692899337afe6713fe1796d0315c │
│ Author alice (you) │
│ Head 20aa5dde6210796c3a2f04079b42316a31d02689 │
│ Base [.. ] │
│ Branches feature/1 │
│ Commits ahead 0, behind 2 │
│ Status merged │
├────────────────────────────────────────────────────┤
│ 20aa5dd First change │
├────────────────────────────────────────────────────┤
│ ● Revision 696ec55 @ 20aa5dd by alice (you) now │
│ └─ ✓ merged by alice (you) │
╰────────────────────────────────────────────────────╯
$ rad patch show 356f73863a8920455ff6e77cd9c805d68910551b
╭────────────────────────────────────────────────────────────────╮
│ Title Second change │
│ Patch 356f73863a8920455ff6e77cd9c805d68910551b │
│ Author alice (you) │
│ Head daf349ff76bedf48c5f292290b682ee7be0683cf │
│ Branches feature/2 │
│ Commits ahead 0, behind 2 │
│ Status merged │
├────────────────────────────────────────────────────────────────┤
│ daf349f Second change │
├────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (daf349f) now │
│ └─ ✓ merged by alice (you) at revision 356f738 (daf349f) now │
╰────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────╮
│ Title Second change │
│ Patch 356f73863a8920455ff6e77cd9c805d68910551b │
│ Author alice (you) │
│ Head daf349ff76bedf48c5f292290b682ee7be0683cf │
│ Base [.. ] │
│ Branches feature/2 │
│ Commits ahead 0, behind 2 │
│ Status merged │
├────────────────────────────────────────────────────┤
│ daf349f Second change │
├────────────────────────────────────────────────────┤
│ ● Revision 356f738 @ daf349f by alice (you) now │
│ └─ ✓ merged by alice (you) │
╰────────────────────────────────────────────────────╯
```
We can verify that the remote tracking branches were also deleted:

View File

@ -56,20 +56,20 @@ When showing the patch, we see that it is `ahead 1, behind 1`, since master has
diverged by one commit:
```
$ rad patch show -v -p 217f050
╭────────────────────────────────────────────────────╮
│ Title Add Alan │
│ Patch 217f050f8891def8fb863f7c0b4f85c89f97299d │
│ Author alice (you) │
│ Head 5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7 │
│ Base f64fb2c8fe28f7c458c72ec8d700373924794943 │
│ Branches feature/1 │
│ Commits ahead 1, behind 1 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 5c88a79 Add Alan │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (5c88a79) now
╰────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ Title Add Alan
│ Patch 217f050f8891def8fb863f7c0b4f85c89f97299d
│ Author alice (you)
│ Head 5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7
│ Base f64fb2c8fe28f7c458c72ec8d700373924794943
│ Branches feature/1
│ Commits ahead 1, behind 1
│ Status open
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ 5c88a79 Add Alan
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ ● Revision 217f050f8891def8fb863f7c0b4f85c89f97299d with head 5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7 by alice (you) now
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
commit 5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7
Author: radicle <radicle@localhost>
@ -102,21 +102,21 @@ When we look at the patch, we see that it has both commits, because this new
patch uses the same base as the previous patch:
```
$ rad patch show -v e22ff008e2a0ed47262890d13263031d7555b555
╭────────────────────────────────────────────────────╮
│ Title Add Mel │
│ Patch e22ff008e2a0ed47262890d13263031d7555b555 │
│ Author alice (you) │
│ Head 7f63fcbcf23fc39eea784c091ad3d20d7e4bd005 │
│ Base f64fb2c8fe28f7c458c72ec8d700373924794943 │
│ Branches feature/2 │
│ Commits ahead 2, behind 1 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 7f63fcb Add Mel │
│ 5c88a79 Add Alan │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (7f63fcb) now
╰────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ Title Add Mel
│ Patch e22ff008e2a0ed47262890d13263031d7555b555
│ Author alice (you)
│ Head 7f63fcbcf23fc39eea784c091ad3d20d7e4bd005
│ Base f64fb2c8fe28f7c458c72ec8d700373924794943
│ Branches feature/2
│ Commits ahead 2, behind 1
│ Status open
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ 7f63fcb Add Mel
│ 5c88a79 Add Alan
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ ● Revision e22ff008e2a0ed47262890d13263031d7555b555 with head 7f63fcbcf23fc39eea784c091ad3d20d7e4bd005 by alice (you) now
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
```
If we want to instead create a "stacked" patch, we can do so with the
@ -137,18 +137,18 @@ that it is still two commits ahead and one behind from `master`.
```
$ rad patch show -v a467ffa260c4fbe355b6fb550ba0c4956078717e
╭────────────────────────────────────────────────────╮
│ Title Add Mel #2
│ Patch a467ffa260c4fbe355b6fb550ba0c4956078717e │
│ Author alice (you) │
│ Head 7f63fcbcf23fc39eea784c091ad3d20d7e4bd005 │
│ Base 5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7 │
│ Branches feature/2 │
│ Commits ahead 2, behind 1 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 7f63fcb Add Mel │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (7f63fcb) now
╰────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ Title Add Mel #2
│ Patch a467ffa260c4fbe355b6fb550ba0c4956078717e
│ Author alice (you)
│ Head 7f63fcbcf23fc39eea784c091ad3d20d7e4bd005
│ Base 5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7
│ Branches feature/2
│ Commits ahead 2, behind 1
│ Status open
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ 7f63fcb Add Mel
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ ● Revision a467ffa260c4fbe355b6fb550ba0c4956078717e with head 7f63fcbcf23fc39eea784c091ad3d20d7e4bd005 by alice (you) now
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
```

View File

@ -43,7 +43,7 @@ To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkE
Our second patch looks like the following:
```
$ rad patch show 183d343ab47d7fe18baf1b24b7209ad033d7fe5c -v
$ rad patch show 183d343ab47d7fe18baf1b24b7209ad033d7fe5c
╭────────────────────────────────────────────────────╮
│ Title Add README, just for the fun │
│ Patch 183d343ab47d7fe18baf1b24b7209ad033d7fe5c │
@ -57,7 +57,7 @@ $ rad patch show 183d343ab47d7fe18baf1b24b7209ad033d7fe5c -v
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (27857ec) now
│ ● Revision 183d343 @ 27857ec by alice (you) now
╰────────────────────────────────────────────────────╯
```
@ -74,20 +74,20 @@ Now, if we show the patch we can see the patch's base has changed and
we have a single commit:
```
$ rad patch show 183d343 -v
╭─────────────────────────────────────────────────────────────────────
│ Title Add README, just for the fun
│ Patch 183d343ab47d7fe18baf1b24b7209ad033d7fe5c
│ Author alice (you)
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66
│ Base 3e674d1a1df90807e934f9ae5da2591dd6848a33
│ Branches add-readme
│ Commits ahead 2, behind 0
│ Status open
├─────────────────────────────────────────────────────────────────────
│ 27857ec Add README, just for the fun
├─────────────────────────────────────────────────────────────────────
│ ● opened by alice (you) (27857ec) now
│ ↑ updated to ebe76f9c2148eb595d7a745f82275786bf3458c3 (27857ec) now
╰─────────────────────────────────────────────────────────────────────
$ rad patch show 183d343
╭────────────────────────────────────────────────────╮
│ Title Add README, just for the fun │
│ Patch 183d343ab47d7fe18baf1b24b7209ad033d7fe5c │
│ Author alice (you) │
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66 │
│ Base 3e674d1a1df90807e934f9ae5da2591dd6848a33 │
│ Branches add-readme │
│ Commits ahead 2, behind 0 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 27857ec Add README, just for the fun │
├────────────────────────────────────────────────────┤
│ ● Revision 183d343 @ 27857ec by alice (you) now
│ ↑ Revision ebe76f9 @ 27857ec by alice (you) now
╰────────────────────────────────────────────────────╯
```

View File

@ -15,25 +15,26 @@ We can see the list of revisions of the patch by `show`ing it:
```
$ rad patch show aa45913
╭─────────────────────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch aa45913e757cacd46972733bddee5472c78fa32a │
│ Author alice (you) │
│ Head 639f44a25145a37f747f3c84265037a9461e44c5 │
│ Branches patch/aa45913 │
│ Commits ahead 3, behind 0 │
│ Status open │
│ │
│ See details. │
├─────────────────────────────────────────────────────────────────────┤
│ 639f44a Add LICENSE, just for the business │
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (3e674d1) now │
│ ↑ updated to 3156bed9d64d4675d6cf56612d217fc5f4e8a53a (27857ec) now │
│ ↑ updated to 2f5324f61e05cda65b667eeea02570d077a8e724 (639f44a) now │
╰─────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch aa45913e757cacd46972733bddee5472c78fa32a │
│ Author alice (you) │
│ Head 639f44a25145a37f747f3c84265037a9461e44c5 │
│ Base [.. ] │
│ Branches patch/aa45913 │
│ Commits ahead 3, behind 0 │
│ Status open │
│ │
│ See details. │
├────────────────────────────────────────────────────┤
│ 639f44a Add LICENSE, just for the business │
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├────────────────────────────────────────────────────┤
│ ● Revision aa45913 @ 3e674d1 by alice (you) now │
│ ↑ Revision 3156bed @ 27857ec by alice (you) now │
│ ↑ Revision 2f5324f @ 639f44a by alice (you) now │
╰────────────────────────────────────────────────────╯
```
So, let's checkout the previous revision, `0c0942e2`:

View File

@ -33,23 +33,23 @@ $ rad patch comment 6c61ef1 -m "I think we should use MIT"
``` ~alice
$ rad patch show 6c61ef1 -v
╭────────────────────────────────────────────────────╮
│ Title Define LICENSE for project │
│ Patch 6c61ef1716ad8a5c11e04dd7a3fec51e01fba70b │
│ Author alice (you) │
│ Head 717c900ec17735639587325e0fd9fe09991c9edd │
│ Base f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 │
│ Branches prepare-license │
│ Commits ahead 1, behind 0 │
│ Status draft │
├────────────────────────────────────────────────────┤
│ 717c900 Introduce license │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (717c900) now
├────────────────────────────────────────────────────┤
│ bob z6Mkt67…v4N1tRk now 833db19 │
│ I think we should use MIT │
╰────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ Title Define LICENSE for project
│ Patch 6c61ef1716ad8a5c11e04dd7a3fec51e01fba70b
│ Author alice (you)
│ Head 717c900ec17735639587325e0fd9fe09991c9edd
│ Base f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354
│ Branches prepare-license
│ Commits ahead 1, behind 0
│ Status draft
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ 717c900 Introduce license
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ ● Revision 6c61ef1716ad8a5c11e04dd7a3fec51e01fba70b with head 717c900ec17735639587325e0fd9fe09991c9edd by alice (you) now
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ bob z6Mkt67…v4N1tRk now 833db19
│ I think we should use MIT
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
$ rad patch comment 6c61ef1 --reply-to 833db19 -m "Thanks, I'll add it!"
╭─────────────────────────╮
│ alice (you) now 1803a38 │
@ -85,22 +85,22 @@ $ rad patch review 6c61ef1 --accept -m "LGTM!"
✓ Patch 6c61ef1 accepted
✓ Synced with 2 seed(s)
$ rad patch show 6c61ef1 -v
╭─────────────────────────────────────────────────────────────────────╮
│ Title Define LICENSE for project │
│ Patch 6c61ef1716ad8a5c11e04dd7a3fec51e01fba70b │
│ Author alice z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi │
│ Head 1cc8cd9de8ccc44b4fe3876f2dbd2cd1cf9ddc0e │
│ Base f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 │
│ Commits ahead 2, behind 0 │
│ Status draft │
├─────────────────────────────────────────────────────────────────────┤
│ 1cc8cd9 Add MIT License │
│ 717c900 Introduce license │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by alice z6MknSL…StBU8Vi (717c900) now
│ ↑ updated to 93915b9afa94a9dc4f52f12cdf077d4613ea3eb3 (1cc8cd9) now │
│ └─ ✓ accepted by bob (you) now │
╰─────────────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ Title Define LICENSE for project
│ Patch 6c61ef1716ad8a5c11e04dd7a3fec51e01fba70b
│ Author alice z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Head 1cc8cd9de8ccc44b4fe3876f2dbd2cd1cf9ddc0e
│ Base f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354
│ Commits ahead 2, behind 0
│ Status draft
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ 1cc8cd9 Add MIT License
│ 717c900 Introduce license
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ ● Revision 6c61ef1716ad8a5c11e04dd7a3fec51e01fba70b with head 717c900ec17735639587325e0fd9fe09991c9edd by alice z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi now
│ ↑ Revision 93915b9afa94a9dc4f52f12cdf077d4613ea3eb3 with head 1cc8cd9de8ccc44b4fe3876f2dbd2cd1cf9ddc0e by alice z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi now │
│ └─ ✓ accepted by bob (you) now
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
```
``` ~bob
@ -110,22 +110,22 @@ $ rad patch delete 6c61ef1
``` ~alice
$ rad patch show 6c61ef1 -v
╭─────────────────────────────────────────────────────────────────────╮
│ Title Define LICENSE for project │
│ Patch 6c61ef1716ad8a5c11e04dd7a3fec51e01fba70b │
│ Author alice (you) │
│ Head 1cc8cd9de8ccc44b4fe3876f2dbd2cd1cf9ddc0e │
│ Base f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 │
│ Branches prepare-license │
│ Commits ahead 2, behind 0 │
│ Status draft │
├─────────────────────────────────────────────────────────────────────┤
│ 1cc8cd9 Add MIT License │
│ 717c900 Introduce license │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (717c900) now
│ ↑ updated to 93915b9afa94a9dc4f52f12cdf077d4613ea3eb3 (1cc8cd9) now │
╰─────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ Title Define LICENSE for project
│ Patch 6c61ef1716ad8a5c11e04dd7a3fec51e01fba70b
│ Author alice (you)
│ Head 1cc8cd9de8ccc44b4fe3876f2dbd2cd1cf9ddc0e
│ Base f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354
│ Branches prepare-license
│ Commits ahead 2, behind 0
│ Status draft
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ 1cc8cd9 Add MIT License
│ 717c900 Introduce license
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ ● Revision 6c61ef1716ad8a5c11e04dd7a3fec51e01fba70b with head 717c900ec17735639587325e0fd9fe09991c9edd by alice (you) now
│ ↑ Revision 93915b9afa94a9dc4f52f12cdf077d4613ea3eb3 with head 1cc8cd9de8ccc44b4fe3876f2dbd2cd1cf9ddc0e by alice (you) now │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
```
If Alice also decides to delete the patch, then any seeds that have synced with

View File

@ -23,13 +23,14 @@ $ rad patch show 97e18f8598237a396a1c0ac1509c89028e666c97
│ Patch 97e18f8598237a396a1c0ac1509c89028e666c97 │
│ Author alice (you) │
│ Head 2a465832b5a76abe25be44a3a5d224bbd7741ba7 │
│ Base [.. ] │
│ Branches cloudhead/draft │
│ Commits ahead 1, behind 0 │
│ Status draft │
├────────────────────────────────────────────────────┤
│ 2a46583 Nothing to see here.. │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (2a46583) [ .. ]
│ ● Revision 97e18f8 @ 2a46583 by alice (you) now
╰────────────────────────────────────────────────────╯
```
@ -46,13 +47,14 @@ $ rad patch show 97e18f8598237a396a1c0ac1509c89028e666c97
│ Patch 97e18f8598237a396a1c0ac1509c89028e666c97 │
│ Author alice (you) │
│ Head 2a465832b5a76abe25be44a3a5d224bbd7741ba7 │
│ Base [.. ] │
│ Branches cloudhead/draft │
│ Commits ahead 1, behind 0 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 2a46583 Nothing to see here.. │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (2a46583) [ .. ]
│ ● Revision 97e18f8 @ 2a46583 by alice (you) now
╰────────────────────────────────────────────────────╯
```
@ -67,12 +69,13 @@ $ rad patch show 97e18f8598237a396a1c0ac1509c89028e666c97
│ Patch 97e18f8598237a396a1c0ac1509c89028e666c97 │
│ Author alice (you) │
│ Head 2a465832b5a76abe25be44a3a5d224bbd7741ba7 │
│ Base [.. ] │
│ Branches cloudhead/draft │
│ Commits ahead 1, behind 0 │
│ Status draft │
├────────────────────────────────────────────────────┤
│ 2a46583 Nothing to see here.. │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (2a46583) [ .. ]
│ ● Revision 97e18f8 @ 2a46583 by alice (you) now
╰────────────────────────────────────────────────────╯
```

View File

@ -45,21 +45,22 @@ Let's look at the patch, to see what it looks like before editing it:
```
$ rad patch show 89f7afb
╭─────────────────────────────────────────────────────────────────────╮
│ Title Add README, just for the fun │
│ Patch 89f7afb1511b976482b21f6b2f39aef7f4fb88a2 │
│ Author alice (you) │
│ Head 8945f6189adf027892c85ac57f7e9341049c2537 │
│ Branches changes │
│ Commits ahead 2, behind 0 │
│ Status open │
├─────────────────────────────────────────────────────────────────────┤
│ 8945f61 Define the LICENSE │
│ 03c02af Add README, just for the fun │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (03c02af) now │
│ ↑ updated to 5d78dd5376453e25df5988ec86951c99cb73742c (8945f61) now │
╰─────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────╮
│ Title Add README, just for the fun │
│ Patch 89f7afb1511b976482b21f6b2f39aef7f4fb88a2 │
│ Author alice (you) │
│ Head 8945f6189adf027892c85ac57f7e9341049c2537 │
│ Base [.. ] │
│ Branches changes │
│ Commits ahead 2, behind 0 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 8945f61 Define the LICENSE │
│ 03c02af Add README, just for the fun │
├────────────────────────────────────────────────────┤
│ ● Revision 89f7afb @ 03c02af by alice (you) now │
│ ↑ Revision 5d78dd5 @ 8945f61 by alice (you) now │
╰────────────────────────────────────────────────────╯
```
We can change the title and description of the patch itself by using a
@ -68,23 +69,24 @@ multi-line message (using two `--message` options here):
```
$ rad patch edit 89f7afb --message "Add Metadata" --message "Add README & LICENSE" --no-announce
$ rad patch show 89f7afb
╭─────────────────────────────────────────────────────────────────────╮
│ Title Add Metadata │
│ Patch 89f7afb1511b976482b21f6b2f39aef7f4fb88a2 │
│ Author alice (you) │
│ Head 8945f6189adf027892c85ac57f7e9341049c2537 │
│ Branches changes │
│ Commits ahead 2, behind 0 │
│ Status open │
│ │
│ Add README & LICENSE │
├─────────────────────────────────────────────────────────────────────┤
│ 8945f61 Define the LICENSE │
│ 03c02af Add README, just for the fun │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (03c02af) now │
│ ↑ updated to 5d78dd5376453e25df5988ec86951c99cb73742c (8945f61) now │
╰─────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────╮
│ Title Add Metadata │
│ Patch 89f7afb1511b976482b21f6b2f39aef7f4fb88a2 │
│ Author alice (you) │
│ Head 8945f6189adf027892c85ac57f7e9341049c2537 │
│ Base [.. ] │
│ Branches changes │
│ Commits ahead 2, behind 0 │
│ Status open │
│ │
│ Add README & LICENSE │
├────────────────────────────────────────────────────┤
│ 8945f61 Define the LICENSE │
│ 03c02af Add README, just for the fun │
├────────────────────────────────────────────────────┤
│ ● Revision 89f7afb @ 03c02af by alice (you) now │
│ ↑ Revision 5d78dd5 @ 8945f61 by alice (you) now │
╰────────────────────────────────────────────────────╯
```
Notice that the `Title` is now `Add Metadata`, and the patch now has a
@ -96,23 +98,24 @@ If we want to change a specific revision's description, we can use the
```
$ rad patch edit 89f7afb --revision 5d78dd5 --message "Changes: Adds LICENSE file" --no-announce
$ rad patch show 89f7afb
╭─────────────────────────────────────────────────────────────────────╮
│ Title Add Metadata │
│ Patch 89f7afb1511b976482b21f6b2f39aef7f4fb88a2 │
│ Author alice (you) │
│ Head 8945f6189adf027892c85ac57f7e9341049c2537 │
│ Branches changes │
│ Commits ahead 2, behind 0 │
│ Status open │
│ │
│ Add README & LICENSE │
├─────────────────────────────────────────────────────────────────────┤
│ 8945f61 Define the LICENSE │
│ 03c02af Add README, just for the fun │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (03c02af) now │
│ ↑ updated to 5d78dd5376453e25df5988ec86951c99cb73742c (8945f61) now │
╰─────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────╮
│ Title Add Metadata │
│ Patch 89f7afb1511b976482b21f6b2f39aef7f4fb88a2 │
│ Author alice (you) │
│ Head 8945f6189adf027892c85ac57f7e9341049c2537 │
│ Base [.. ] │
│ Branches changes │
│ Commits ahead 2, behind 0 │
│ Status open │
│ │
│ Add README & LICENSE │
├────────────────────────────────────────────────────┤
│ 8945f61 Define the LICENSE │
│ 03c02af Add README, just for the fun │
├────────────────────────────────────────────────────┤
│ ● Revision 89f7afb @ 03c02af by alice (you) now │
│ ↑ Revision 5d78dd5 @ 8945f61 by alice (you) now │
╰────────────────────────────────────────────────────╯
```
We can see that this didn't affect the patch's description, but

View File

@ -97,20 +97,21 @@ Alice pulls the update.
``` ~alice
$ rad patch show 55b9721
╭─────────────────────────────────────────────────────────────────────╮
│ Title Bob's patch │
│ Patch 55b9721ed7f6bfec38f43729e9b6631c5dc812fb │
│ Author bob z6Mkt67…v4N1tRk │
│ Head cad2666a8a2250e4dee175ed5044be2c251ff08b │
│ Commits ahead 2, behind 0 │
│ Status open │
├─────────────────────────────────────────────────────────────────────┤
│ cad2666 Bob's commit #2
│ bdcdb30 Bob's commit #1
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by bob z6Mkt67…v4N1tRk (bdcdb30) now │
│ ↑ updated to f91e056da05b2d9a58af1160c76245bc3debf7a8 (cad2666) now │
╰─────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────────────────────────────────╮
│ Title Bob's patch │
│ Patch 55b9721ed7f6bfec38f43729e9b6631c5dc812fb │
│ Author bob z6Mkt67…v4N1tRk │
│ Head cad2666a8a2250e4dee175ed5044be2c251ff08b │
│ Base [.. ] │
│ Commits ahead 2, behind 0 │
│ Status open │
├─────────────────────────────────────────────────────────┤
│ cad2666 Bob's commit #2
│ bdcdb30 Bob's commit #1
├─────────────────────────────────────────────────────────┤
│ ● Revision 55b9721 @ bdcdb30 by bob z6Mkt67…v4N1tRk now │
│ ↑ Revision f91e056 @ cad2666 by bob z6Mkt67…v4N1tRk now │
╰─────────────────────────────────────────────────────────╯
$ git ls-remote rad
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 HEAD
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 refs/heads/master

View File

@ -21,20 +21,21 @@ First we see the patch as merged.
```
$ rad patch show 696ec5508494692899337afe6713fe1796d0315c
╭────────────────────────────────────────────────────────────────╮
│ Title First change │
│ Patch 696ec5508494692899337afe6713fe1796d0315c │
│ Author alice (you) │
│ Head 20aa5dde6210796c3a2f04079b42316a31d02689 │
│ Branches feature/1, master │
│ Commits up to date │
│ Status merged │
├────────────────────────────────────────────────────────────────┤
│ 20aa5dd First change │
├────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (20aa5dd) now │
│ └─ ✓ merged by alice (you) at revision 696ec55 (20aa5dd) now │
╰────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────╮
│ Title First change │
│ Patch 696ec5508494692899337afe6713fe1796d0315c │
│ Author alice (you) │
│ Head 20aa5dde6210796c3a2f04079b42316a31d02689 │
│ Base [.. ] │
│ Branches feature/1, master │
│ Commits up to date │
│ Status merged │
├────────────────────────────────────────────────────┤
│ 20aa5dd First change │
├────────────────────────────────────────────────────┤
│ ● Revision 696ec55 @ 20aa5dd by alice (you) now │
│ └─ ✓ merged by alice (you) │
╰────────────────────────────────────────────────────╯
```
Now let's revert the patch by pushing a new `master` that doesn't include
@ -64,12 +65,13 @@ $ rad patch show 696ec5508494692899337afe6713fe1796d0315c
│ Patch 696ec5508494692899337afe6713fe1796d0315c │
│ Author alice (you) │
│ Head 20aa5dde6210796c3a2f04079b42316a31d02689 │
│ Base [.. ] │
│ Branches feature/1 │
│ Commits ahead 1, behind 0 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 20aa5dd First change │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (20aa5dd) now
│ ● Revision 696ec55 @ 20aa5dd by alice (you) now │
╰────────────────────────────────────────────────────╯
```

View File

@ -18,13 +18,14 @@ $ rad patch show b6a23eb08656de0ef1fcc0b5fe8820841e5cb2e5
│ Patch b6a23eb08656de0ef1fcc0b5fe8820841e5cb2e5 │
│ Author alice (you) │
│ Head 51b2f0f77b9849bfaa3e9d3ff68ee2f57771d20c │
│ Base [.. ] │
│ Branches feature/1 │
│ Commits ahead 1, behind 0 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 51b2f0f Not a real change │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (51b2f0f) now
│ ● Revision b6a23eb @ 51b2f0f by alice (you) now
╰────────────────────────────────────────────────────╯
```
@ -54,19 +55,20 @@ The command outputs the new Revision ID, which we can now see here:
```
$ rad patch show b6a23eb08656de0ef1fcc0b5fe8820841e5cb2e5
╭─────────────────────────────────────────────────────────────────────╮
│ Title Not a real change │
│ Patch b6a23eb08656de0ef1fcc0b5fe8820841e5cb2e5 │
│ Author alice (you) │
│ Head 4d272148458a17620541555b1f0905c01658aa9f │
│ Branches feature/1 │
│ Commits ahead 2, behind 0 │
│ Status open │
├─────────────────────────────────────────────────────────────────────┤
│ 4d27214 Rename readme file │
│ 51b2f0f Not a real change │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (51b2f0f) now │
│ ↑ updated to ea7def3857f62f404606d7cd6490cd0de4eaebd1 (4d27214) now │
╰─────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────╮
│ Title Not a real change │
│ Patch b6a23eb08656de0ef1fcc0b5fe8820841e5cb2e5 │
│ Author alice (you) │
│ Head 4d272148458a17620541555b1f0905c01658aa9f │
│ Base [.. ] │
│ Branches feature/1 │
│ Commits ahead 2, behind 0 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 4d27214 Rename readme file │
│ 51b2f0f Not a real change │
├────────────────────────────────────────────────────┤
│ ● Revision b6a23eb @ 51b2f0f by alice (you) now │
│ ↑ Revision ea7def3 @ 4d27214 by alice (you) now │
╰────────────────────────────────────────────────────╯
```

View File

@ -25,6 +25,7 @@ $ rad patch show 6035d2f582afbe01ff23ea87528ae523d76875b6
│ Patch 6035d2f582afbe01ff23ea87528ae523d76875b6 │
│ Author alice (you) │
│ Head 42d894a83c9c356552a57af09ccdbd5587a99045 │
│ Base [.. ] │
│ Branches feature/1 │
│ Commits ahead 1, behind 0 │
│ Status open │
@ -33,7 +34,7 @@ $ rad patch show 6035d2f582afbe01ff23ea87528ae523d76875b6
├────────────────────────────────────────────────────┤
│ 42d894a Add things │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (42d894a) now
│ ● Revision 6035d2f @ 42d894a by alice (you) now
╰────────────────────────────────────────────────────╯
```
@ -138,21 +139,22 @@ We can then see that the patch head has moved:
```
$ rad patch show 9580891
╭─────────────────────────────────────────────────────────────────────╮
│ Title Add more things │
│ Patch 95808913573cead52ad7b42c7b475260ec45c4b2 │
│ Author alice (you) │
│ Head 02bef3fac41b2f98bb3c02b868a53ddfecb55b5f │
│ Branches feature/2 │
│ Commits ahead 2, behind 0 │
│ Status open │
├─────────────────────────────────────────────────────────────────────┤
│ 02bef3f Improve code │
│ 8b0ea80 Add more things │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (8b0ea80) now │
│ ↑ updated to d7040c6c97629c2b94f86fb639bebbff5de39697 (02bef3f) now │
╰─────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────╮
│ Title Add more things │
│ Patch 95808913573cead52ad7b42c7b475260ec45c4b2 │
│ Author alice (you) │
│ Head 02bef3fac41b2f98bb3c02b868a53ddfecb55b5f │
│ Base [.. ] │
│ Branches feature/2 │
│ Commits ahead 2, behind 0 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 02bef3f Improve code │
│ 8b0ea80 Add more things │
├────────────────────────────────────────────────────┤
│ ● Revision 9580891 @ 8b0ea80 by alice (you) now │
│ ↑ Revision d7040c6 @ 02bef3f by alice (you) now │
╰────────────────────────────────────────────────────╯
```
And we can check that all the refs are properly updated in our repository:
@ -218,22 +220,23 @@ That worked. We can see the new revision if we call `rad patch show`:
```
$ rad patch show 9580891
╭─────────────────────────────────────────────────────────────────────╮
│ Title Add more things │
│ Patch 95808913573cead52ad7b42c7b475260ec45c4b2 │
│ Author alice (you) │
│ Head 9304dbc445925187994a7a93222a3f8bde73b785 │
│ Branches feature/2 │
│ Commits ahead 2, behind 0 │
│ Status open │
├─────────────────────────────────────────────────────────────────────┤
│ 9304dbc Amended commit │
│ 8b0ea80 Add more things │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (8b0ea80) now │
│ ↑ updated to d7040c6c97629c2b94f86fb639bebbff5de39697 (02bef3f) now │
│ ↑ updated to 670d02794aa05afd6e0851f4aa848bc87c4712c7 (9304dbc) now │
╰─────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────╮
│ Title Add more things │
│ Patch 95808913573cead52ad7b42c7b475260ec45c4b2 │
│ Author alice (you) │
│ Head 9304dbc445925187994a7a93222a3f8bde73b785 │
│ Base [.. ] │
│ Branches feature/2 │
│ Commits ahead 2, behind 0 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 9304dbc Amended commit │
│ 8b0ea80 Add more things │
├────────────────────────────────────────────────────┤
│ ● Revision 9580891 @ 8b0ea80 by alice (you) now │
│ ↑ Revision d7040c6 @ 02bef3f by alice (you) now │
│ ↑ Revision 670d027 @ 9304dbc by alice (you) now │
╰────────────────────────────────────────────────────╯
```
## Empty patch

View File

@ -48,6 +48,7 @@ $ rad patch show aa45913e757cacd46972733bddee5472c78fa32a -p
│ Patch aa45913e757cacd46972733bddee5472c78fa32a │
│ Author alice (you) │
│ Head 3e674d1a1df90807e934f9ae5da2591dd6848a33 │
│ Base [.. ] │
│ Branches flux-capacitor-power │
│ Commits ahead 1, behind 0 │
│ Status open │
@ -56,7 +57,7 @@ $ rad patch show aa45913e757cacd46972733bddee5472c78fa32a -p
├────────────────────────────────────────────────────┤
│ 3e674d1 Define power requirements │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (3e674d1) now
│ ● Revision aa45913 @ 3e674d1 by alice (you) now │
╰────────────────────────────────────────────────────╯
commit 3e674d1a1df90807e934f9ae5da2591dd6848a33
@ -102,6 +103,7 @@ $ rad patch show aa45913
│ Author alice (you) │
│ Labels fun │
│ Head 3e674d1a1df90807e934f9ae5da2591dd6848a33 │
│ Base [.. ] │
│ Branches flux-capacitor-power │
│ Commits ahead 1, behind 0 │
│ Status open │
@ -110,7 +112,7 @@ $ rad patch show aa45913
├────────────────────────────────────────────────────┤
│ 3e674d1 Define power requirements │
├────────────────────────────────────────────────────┤
│ ● opened by alice (you) (3e674d1) now
│ ● Revision aa45913 @ 3e674d1 by alice (you) now │
╰────────────────────────────────────────────────────╯
```
@ -183,25 +185,26 @@ Showing the patch list now will reveal the favorable verdict:
```
$ rad patch show aa45913
╭─────────────────────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch aa45913e757cacd46972733bddee5472c78fa32a │
│ Author alice (you) │
│ Labels fun │
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66 │
│ Branches flux-capacitor-power, patch/aa45913 │
│ Commits ahead 2, behind 0 │
│ Status open │
│ │
│ See details. │
├─────────────────────────────────────────────────────────────────────┤
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (3e674d1) now │
│ ↑ updated to 6e5a3b7b2ce27b32e7ccc2f0b3f4594897dde638 (27857ec) now │
│ └─ ✓ accepted by alice (you) now │
╰─────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch aa45913e757cacd46972733bddee5472c78fa32a │
│ Author alice (you) │
│ Labels fun │
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66 │
│ Base [.. ] │
│ Branches flux-capacitor-power, patch/aa45913 │
│ Commits ahead 2, behind 0 │
│ Status open │
│ │
│ See details. │
├────────────────────────────────────────────────────┤
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├────────────────────────────────────────────────────┤
│ ● Revision aa45913 @ 3e674d1 by alice (you) now │
│ ↑ Revision 6e5a3b7 @ 27857ec by alice (you) now │
│ └─ ✓ accepted by alice (you) now │
╰────────────────────────────────────────────────────╯
$ rad patch list
╭─────────────────────────────────────────────────────────────────────────────────────────╮
│ ● ID Title Author Reviews Head + - Updated │
@ -215,23 +218,24 @@ If you make a mistake on the patch description, you can always change it!
```
$ rad patch edit aa45913 --message "Define power requirements" --message "Add requirements file" --no-announce
$ rad patch show aa45913
╭─────────────────────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch aa45913e757cacd46972733bddee5472c78fa32a │
│ Author alice (you) │
│ Labels fun │
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66 │
│ Branches flux-capacitor-power, patch/aa45913 │
│ Commits ahead 2, behind 0 │
│ Status open │
│ │
│ Add requirements file │
├─────────────────────────────────────────────────────────────────────┤
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by alice (you) (3e674d1) now │
│ ↑ updated to 6e5a3b7b2ce27b32e7ccc2f0b3f4594897dde638 (27857ec) now │
│ └─ ✓ accepted by alice (you) now │
╰─────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch aa45913e757cacd46972733bddee5472c78fa32a │
│ Author alice (you) │
│ Labels fun │
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66 │
│ Base [.. ] │
│ Branches flux-capacitor-power, patch/aa45913 │
│ Commits ahead 2, behind 0 │
│ Status open │
│ │
│ Add requirements file │
├────────────────────────────────────────────────────┤
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├────────────────────────────────────────────────────┤
│ ● Revision aa45913 @ 3e674d1 by alice (you) now │
│ ↑ Revision 6e5a3b7 @ 27857ec by alice (you) now │
│ └─ ✓ accepted by alice (you) now │
╰────────────────────────────────────────────────────╯
```

View File

@ -46,6 +46,7 @@ $ rad patch show e4934b6d9dbe01ce3c7fbb5b77a80d5f1dacdc46
│ Patch e4934b6d9dbe01ce3c7fbb5b77a80d5f1dacdc46 │
│ Author bob (you) │
│ Head 3e674d1a1df90807e934f9ae5da2591dd6848a33 │
│ Base [.. ] │
│ Branches flux-capacitor-power │
│ Commits ahead 1, behind 0 │
│ Status open │
@ -54,7 +55,7 @@ $ rad patch show e4934b6d9dbe01ce3c7fbb5b77a80d5f1dacdc46
├────────────────────────────────────────────────────┤
│ 3e674d1 Define power requirements │
├────────────────────────────────────────────────────┤
│ ● opened by bob (you) (3e674d1) now
│ ● Revision e4934b6 @ 3e674d1 by bob (you) now │
╰────────────────────────────────────────────────────╯
```

View File

@ -28,22 +28,23 @@ $ git branch -r
bob/patches/e4934b6d9dbe01ce3c7fbb5b77a80d5f1dacdc46
rad/master
$ rad patch show e4934b6
╭─────────────────────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch e4934b6d9dbe01ce3c7fbb5b77a80d5f1dacdc46 │
│ Author bob z6Mkt67…v4N1tRk │
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66 │
│ Commits ahead 2, behind 0 │
│ Status open │
│ │
│ See details. │
├─────────────────────────────────────────────────────────────────────┤
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by bob z6Mkt67…v4N1tRk (3e674d1) now │
│ ↑ updated to 773b9aab58b11e9fa83d0ed0baca2bea6ff889c9 (27857ec) now │
╰─────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch e4934b6d9dbe01ce3c7fbb5b77a80d5f1dacdc46 │
│ Author bob z6Mkt67…v4N1tRk │
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66 │
│ Base [.. ] │
│ Commits ahead 2, behind 0 │
│ Status open │
│ │
│ See details. │
├─────────────────────────────────────────────────────────┤
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├─────────────────────────────────────────────────────────┤
│ ● Revision e4934b6 @ 3e674d1 by bob z6Mkt67…v4N1tRk now │
│ ↑ Revision 773b9aa @ 27857ec by bob z6Mkt67…v4N1tRk now │
╰─────────────────────────────────────────────────────────╯
```
Wait! There's a mistake. The REQUIREMENTS should be a markdown file. Let's
@ -102,25 +103,26 @@ The patch is now merged and closed :).
```
$ rad patch show e4934b6
╭─────────────────────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch e4934b6d9dbe01ce3c7fbb5b77a80d5f1dacdc46 │
│ Author bob z6Mkt67…v4N1tRk │
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66 │
│ Commits ahead 0, behind 1 │
│ Status merged │
│ │
│ See details. │
├─────────────────────────────────────────────────────────────────────┤
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├─────────────────────────────────────────────────────────────────────┤
│ ● opened by bob z6Mkt67…v4N1tRk (3e674d1) now │
│ ↑ updated to 773b9aab58b11e9fa83d0ed0baca2bea6ff889c9 (27857ec) now │
│ * revised by alice (you) in 9d62420 (f567f69) now │
│ └─ ✓ accepted by alice (you) now │
│ └─ ✓ merged by alice (you) at revision 9d62420 (f567f69) now │
╰─────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch e4934b6d9dbe01ce3c7fbb5b77a80d5f1dacdc46 │
│ Author bob z6Mkt67…v4N1tRk │
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66 │
│ Base [.. ] │
│ Commits ahead 0, behind 1 │
│ Status merged │
│ │
│ See details. │
├─────────────────────────────────────────────────────────┤
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├─────────────────────────────────────────────────────────┤
│ ● Revision e4934b6 @ 3e674d1 by bob z6Mkt67…v4N1tRk now │
│ ↑ Revision 773b9aa @ 27857ec by bob z6Mkt67…v4N1tRk now │
│ ↑ Revision 9d62420 @ f567f69 by alice (you) now │
│ └─ ✓ accepted by alice (you) now │
│ └─ ✓ merged by alice (you) │
╰─────────────────────────────────────────────────────────╯
```
To publish our new state to the network, we simply push:

View File

@ -394,12 +394,10 @@ pub fn show(
term::format::tertiary("Head".to_owned()).into(),
term::format::secondary(revision.head().to_string()).into(),
]);
if verbose {
attrs.push([
term::format::tertiary("Base".to_owned()).into(),
term::format::secondary(revision.base().to_string()).into(),
]);
}
attrs.push([
term::format::tertiary("Base".to_owned()).into(),
term::format::secondary(revision.base().to_string()).into(),
]);
if !branches.is_empty() {
attrs.push([
term::format::tertiary("Branches".to_owned()).into(),
@ -438,7 +436,7 @@ pub fn show(
.children(commits.into_iter().map(|l| l.boxed()))
.divider();
for line in timeline::timeline(profile, patch) {
for line in timeline::timeline(profile, patch, verbose) {
widget.push(line);
}

View File

@ -9,150 +9,54 @@ use radicle::profile::Profile;
use crate::terminal as term;
use crate::terminal::format::Author;
/// The timeline of a [`Patch`].
///
/// A [`Patch`] will always have opened with a root revision and may
/// have a series of revisions that update the patch.
///
/// This function converts it into a series of [`term::Line`]s for
/// display.
pub fn timeline<'a>(
profile: &'a Profile,
patch: &'a Patch,
verbose: bool,
) -> impl Iterator<Item = term::Line> + 'a {
Timeline::build(profile, patch).into_lines(profile)
}
/// The timeline of a [`Patch`].
///
/// A `Patch` will always have opened with a root revision and may
/// have a series of revisions that update the patch.
///
/// The function, [`timeline`], builds a `Timeline` and converts it
/// into a series of [`term::Line`]s.
struct Timeline<'a> {
opened: Opened<'a>,
revisions: Vec<RevisionEntry<'a>>,
}
impl<'a> Timeline<'a> {
fn build(profile: &Profile, patch: &'a Patch) -> Self {
let opened = Opened::from_patch(patch, profile);
let mut revisions = patch
.revisions()
.skip(1) // skip the root revision since it's handled in `Opened::from_patch`
.map(|(id, revision)| {
(
revision.timestamp(),
RevisionEntry::from_revision(patch, id, revision, profile),
)
})
.collect::<Vec<_>>();
revisions.sort_by_key(|(t, _)| *t);
Timeline {
opened,
revisions: revisions.into_iter().map(|(_, e)| e).collect(),
}
}
fn into_lines(self, profile: &'a Profile) -> impl Iterator<Item = term::Line> + 'a {
self.opened.into_lines(profile).chain(
self.revisions
.into_iter()
.flat_map(|r| r.into_lines(profile)),
)
}
}
/// The root `Revision` of the `Patch`.
struct Opened<'a> {
/// The `Author` of the patch.
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>>,
}
impl<'a> Opened<'a> {
fn from_patch(patch: &'a Patch, profile: &Profile) -> Self {
let (root, revision) = patch.root();
let mut updates = Vec::new();
updates.extend(revision.reviews().map(|(_, review)| {
let mut revisions = patch
.revisions()
.map(|(id, revision)| {
(
review.timestamp(),
Update::Reviewed {
review: review.clone(),
},
revision.timestamp(),
RevisionEntry::from_revision(patch, id, revision, profile, verbose),
)
}));
updates.extend(patch.merges().filter_map(|(nid, merge)| {
if merge.revision == root {
Some((
merge.timestamp,
Update::Merged {
author: Author::new(nid, profile, false),
merge: merge.clone(),
},
))
} else {
None
}
}));
updates.sort_by_key(|(t, _)| *t);
Opened {
author: Author::new(&patch.author().id, profile, false),
timestamp: patch.timestamp(),
head: revision.head(),
updates: updates.into_iter().map(|(_, up)| up).collect(),
}
}
})
.collect::<Vec<_>>();
fn into_lines(self, profile: &'a Profile) -> impl Iterator<Item = term::Line> + 'a {
iter::once(
term::Line::spaced([
term::format::positive("").into(),
term::format::default("opened by").into(),
])
.space()
.extend(self.author.line())
.space()
.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("└─ ")])
.extend(up.into_line(profile))
}))
}
revisions.sort_by_key(|(t, _)| *t);
revisions
.into_iter()
.map(|(_, e)| e)
.flat_map(move |r| r.into_lines(profile, verbose))
}
/// A revision entry in the [`Timeline`].
enum RevisionEntry<'a> {
/// An `Updated` entry means that the original author of the
/// `Patch` created a new revision.
Updated {
/// When the `Revision` was created.
timestamp: cob::Timestamp,
/// The id of the `Revision`.
id: RevisionId,
/// The commit head of the `Revision`.
head: git::Oid,
/// All [`Update`]s that occurred on the `Revision`.
updates: Vec<Update<'a>>,
},
/// A `Revised` entry means that an author other than the original
/// author of the `Patch` created a new revision.
Revised {
/// The `Author` that created the `Revision` (that is not the
/// `Patch` author).
author: Author<'a>,
/// When the `Revision` was created.
timestamp: cob::Timestamp,
/// The id of the `Revision`.
id: RevisionId,
/// The commit head of the `Revision`.
head: git::Oid,
/// All [`Update`]s that occurred on the `Revision`.
updates: Vec<Update<'a>>,
},
/// A revision entry in the timeline.
///
/// We do not distinguish between revisions created by the original author and
/// others, and also not between the initial revision and others. This tends to
/// confuse more than it helps.
struct RevisionEntry<'a> {
/// Whether this entry is about the initial [`Revision`] of the patch.
is_initial: bool,
/// The [`Author`] that created the [`Revision`].
author: Author<'a>,
/// When the [`Revision`] was created.
timestamp: cob::Timestamp,
/// The id of the [`Revision`].
id: RevisionId,
/// The commit head of the [`Revision`].
head: git::Oid,
/// All [`Update`]s that occurred on the [`Revision`].
updates: Vec<Update<'a>>,
}
impl<'a> RevisionEntry<'a> {
@ -161,6 +65,7 @@ impl<'a> RevisionEntry<'a> {
id: RevisionId,
revision: &'a Revision,
profile: &Profile,
verbose: bool,
) -> Self {
let mut updates = Vec::new();
updates.extend(revision.reviews().map(|(_, review)| {
@ -176,8 +81,12 @@ impl<'a> RevisionEntry<'a> {
Some((
merge.timestamp,
Update::Merged {
author: Author::new(nid, profile, false),
merge: merge.clone(),
author: Author::new(nid, profile, verbose),
merge: if merge.commit != revision.head() {
Some(merge.clone())
} else {
None
},
},
))
} else {
@ -186,84 +95,58 @@ impl<'a> RevisionEntry<'a> {
}));
updates.sort_by_key(|(t, _)| *t);
if revision.author() == patch.author() {
RevisionEntry::Updated {
timestamp: revision.timestamp(),
id,
head: revision.head(),
updates: updates.into_iter().map(|(_, up)| up).collect(),
}
RevisionEntry {
is_initial: patch.root().0 == id,
author: Author::new(&revision.author().id, profile, verbose),
timestamp: revision.timestamp(),
id,
head: revision.head(),
updates: updates.into_iter().map(|(_, up)| up).collect(),
}
}
fn into_lines(
self,
profile: &'a Profile,
verbose: bool,
) -> impl Iterator<Item = term::Line> + 'a {
use term::{format::*, *};
let id: Label = if verbose {
self.id.to_string().into()
} else {
RevisionEntry::Revised {
author: Author::new(&revision.author().id, profile, false),
timestamp: revision.timestamp(),
id,
head: revision.head(),
updates: updates.into_iter().map(|(_, up)| up).collect(),
}
}
}
oid(self.id).into()
};
fn into_lines(self, profile: &'a Profile) -> Vec<term::Line> {
match self {
RevisionEntry::Updated {
timestamp,
id,
head,
updates,
} => Self::updated(profile, timestamp, id, head, updates).collect(),
RevisionEntry::Revised {
author,
timestamp,
id,
head,
updates,
} => Self::revised(profile, author, timestamp, id, head, updates).collect(),
}
}
let icon = if self.is_initial {
positive("")
} else {
tertiary("")
};
fn updated(
profile: &'a Profile,
timestamp: cob::Timestamp,
id: RevisionId,
head: git::Oid,
updates: Vec<Update<'a>>,
) -> impl Iterator<Item = term::Line> + 'a {
iter::once(term::Line::spaced([
term::format::tertiary("").into(),
term::format::default("updated to").into(),
term::format::dim(id).into(),
term::format::parens(term::format::secondary(term::format::oid(head))).into(),
term::format::dim(term::format::timestamp(timestamp)).into(),
]))
.chain(updates.into_iter().map(|up| {
term::Line::spaced([term::Label::space(), term::Label::from("└─ ")])
.extend(up.into_line(profile))
}))
}
let line = Line::spaced([icon.into(), dim("Revision").into(), id]).space();
fn revised(
profile: &'a Profile,
author: Author<'a>,
timestamp: cob::Timestamp,
id: RevisionId,
head: git::Oid,
updates: Vec<Update<'a>>,
) -> impl Iterator<Item = term::Line> + 'a {
let (alias, nid) = author.labels();
iter::once(term::Line::spaced([
term::format::tertiary("*").into(),
term::format::default("revised by").into(),
alias,
nid,
term::format::default("in").into(),
term::format::dim(term::format::oid(id)).into(),
term::format::parens(term::format::secondary(term::format::oid(head))).into(),
term::format::dim(term::format::timestamp(timestamp)).into(),
]))
.chain(updates.into_iter().map(|up| {
term::Line::spaced([term::Label::space(), term::Label::from("└─ ")])
.extend(up.into_line(profile))
let line = line
.item(dim(if verbose { "with head" } else { "@" }))
.space();
let line = line.item(secondary(if verbose {
Paint::new(self.head.to_string())
} else {
oid(self.head)
}));
iter::once(
line.space()
.extend([dim("by").into()])
.space()
.extend(self.author.line())
.space()
.item(dim(timestamp(self.timestamp))),
)
.chain(self.updates.into_iter().map(move |up| {
Line::spaced([Label::space(), Label::from("└─ ")])
.extend(up.into_line(profile, verbose))
}))
}
}
@ -273,56 +156,81 @@ enum Update<'a> {
/// A revision of the patch was reviewed.
Reviewed { review: Review },
/// A revision of the patch was merged.
Merged { author: Author<'a>, merge: Merge },
Merged {
author: Author<'a>,
/// If the merge is none, this means that it was a fast-forward merge.
merge: Option<Merge>,
},
}
impl Update<'_> {
fn timestamp(&self) -> cob::Timestamp {
match self {
Update::Reviewed { review } => review.timestamp(),
Update::Merged { merge, .. } => merge.timestamp,
}
}
fn into_line(self, profile: &Profile, verbose: bool) -> term::Line {
use term::{format::*, *};
fn into_line(self, profile: &Profile) -> term::Line {
let timestamp = self.timestamp();
let mut line = match self {
match self {
Update::Reviewed { review } => {
let verdict = review.verdict();
let verdict_symbol = match verdict {
Some(Verdict::Accept) => term::PREFIX_SUCCESS,
Some(Verdict::Reject) => term::PREFIX_ERROR,
None => term::format::dim(""),
let by = " ".repeat(if verbose { 0 } else { 13 }) + "by";
let (symbol, verb) = match review.verdict() {
Some(Verdict::Accept) => (PREFIX_SUCCESS, positive("accepted")),
Some(Verdict::Reject) => (PREFIX_ERROR, negative("rejected")),
None => (dim(""), default("reviewed")),
};
let verdict_verb = match verdict {
Some(Verdict::Accept) => term::format::default("accepted"),
Some(Verdict::Reject) => term::format::default("rejected"),
None => term::format::default("reviewed"),
};
term::Line::spaced([
verdict_symbol.into(),
verdict_verb.into(),
term::format::default("by").into(),
])
.space()
.extend(Author::new(&review.author().id.into(), profile, false).line())
Line::spaced([symbol.into(), verb.into(), dim(by).into()])
.space()
.extend(Author::new(&review.author().id.into(), profile, verbose).line())
.space()
.item(dim(timestamp(review.timestamp())))
}
Update::Merged { author, merge } => {
// The additional whitespace after makes it align, see:
// - "merged "
// - "accepted"
// - "rejected"
// This is less noisy to look at in the terminal.
const MERGED: &str = "merged ";
let at_commit = if !verbose { " @ " } else { " at commit " };
let (alias, nid) = author.labels();
term::Line::spaced([
term::PREFIX_SUCCESS.bold().into(),
term::format::default("merged by").into(),
alias,
nid,
term::format::default("at revision").into(),
term::format::dim(term::format::oid(merge.revision)).into(),
term::format::parens(term::format::secondary(term::format::oid(merge.commit)))
.into(),
])
let (commit, timestamp) = match merge {
Some(merge) => (
Line::spaced([dim(at_commit).into(), secondary(oid(merge.commit)).into()])
.space(),
timestamp(merge.timestamp),
),
None => {
let mut line = Line::blank();
if !verbose {
const LENGTH_OF_SHORT_COMMIT_HASH: usize = 7;
const LENGTH_OF_SPACES: usize = 2;
line.pad(
2 // alignment
+ 2 // parens
+ LENGTH_OF_SHORT_COMMIT_HASH
+ LENGTH_OF_SPACES,
);
}
(line, "".into())
}
};
Line::blank()
.item(PREFIX_SUCCESS.bold())
.space()
.item(Label::from(positive(MERGED)))
.space()
.extend(commit)
.item(dim("by"))
.space()
.item(alias)
.space()
.item(nid)
.space()
.item(timestamp)
}
};
line.push(term::Label::space());
line.push(term::format::dim(term::format::timestamp(timestamp)));
line
}
}
}