cli: Improve patch and issue outputs

* Add author to `issue show`
* Improve author display with alias
* Fix consistency issues when printing authors
This commit is contained in:
cloudhead 2023-08-30 20:34:23 +02:00
parent aec865a986
commit 6c5cba3ca6
No known key found for this signature in database
19 changed files with 293 additions and 312 deletions

View File

@ -8,6 +8,7 @@ $ rad issue open --title "flux capacitor underpowered" --description "Flux capac
╭─────────────────────────────────────────────────────────╮
│ Title flux capacitor underpowered │
│ Issue 42028af21fabc09bfac2f25490f119f7c7e11542 │
│ Author z6MknSL…StBU8Vi (you) │
│ Status open │
│ │
│ Flux capacitor power requirements exceed current supply │
@ -32,6 +33,7 @@ $ rad issue show 42028af
╭─────────────────────────────────────────────────────────╮
│ Title flux capacitor underpowered │
│ Issue 42028af21fabc09bfac2f25490f119f7c7e11542 │
│ Author z6MknSL…StBU8Vi (you) │
│ Status open │
│ │
│ Flux capacitor power requirements exceed current supply │

View File

@ -12,6 +12,7 @@ $ rad issue show 42028af21fabc09bfac2f25490f119f7c7e11542
╭─────────────────────────────────────────────────────────╮
│ Title flux capacitor underpowered │
│ Issue 42028af21fabc09bfac2f25490f119f7c7e11542 │
│ Author z6MknSL…StBU8Vi (you) │
│ Labels bug, good-first-issue │
│ Status open │
│ │
@ -32,6 +33,7 @@ $ rad issue show 42028af21fabc09bfac2f25490f119f7c7e11542
╭─────────────────────────────────────────────────────────╮
│ Title flux capacitor underpowered │
│ Issue 42028af21fabc09bfac2f25490f119f7c7e11542 │
│ Author z6MknSL…StBU8Vi (you) │
│ Labels bug │
│ Status open │
│ │

View File

@ -66,12 +66,12 @@ To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkE
```
```
$ rad patch --merged
╭────────────────────────────────────────────────────────────────────────────────────────
│ ● ID Title Author Head + - Updated │
├────────────────────────────────────────────────────────────────────────────────────────
│ ✔ 143bb0c First change z6MknSL…StBU8Vi alice (you) 20aa5dd +0 -0 [ ... ] │
│ ✔ 5d0e608 Second change z6MknSL…StBU8Vi alice (you) daf349f +0 -0 [ ... ] │
╰────────────────────────────────────────────────────────────────────────────────────────
╭─────────────────────────────────────────────────────────────────────────╮
│ ● ID Title Author Head + - Updated │
├─────────────────────────────────────────────────────────────────────────┤
│ ✔ 143bb0c First change alice (you) 20aa5dd +0 -0 [ ... ] │
│ ✔ 5d0e608 Second change alice (you) daf349f +0 -0 [ ... ] │
╰─────────────────────────────────────────────────────────────────────────╯
```
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 69ebafb
╭────────────────────────────────────────────────────────────────────
│ Title Add Alan
│ Patch 69ebafb6f654fb29d23f630cc165d83d6cbf525c
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Head 5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7
│ Base f64fb2c8fe28f7c458c72ec8d700373924794943
│ Branches feature/1
│ Commits ahead 1, behind 1
│ Status open
├────────────────────────────────────────────────────────────────────
│ 5c88a79 Add Alan
├────────────────────────────────────────────────────────────────────
│ ● opened by (you) [ ... ]
╰────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────╮
│ Title Add Alan │
│ Patch 69ebafb6f654fb29d23f630cc165d83d6cbf525c │
│ Author z6MknSL…StBU8Vi (you)
│ Head 5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7 │
│ Base f64fb2c8fe28f7c458c72ec8d700373924794943 │
│ Branches feature/1 │
│ Commits ahead 1, behind 1 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 5c88a79 Add Alan │
├────────────────────────────────────────────────────┤
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
╰────────────────────────────────────────────────────╯
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 53d5f17aba5fd9b7de7a02ecb6f01de561701eeb
╭────────────────────────────────────────────────────────────────────
│ Title Add Mel
│ Patch 53d5f17aba5fd9b7de7a02ecb6f01de561701eeb
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Head 7f63fcbcf23fc39eea784c091ad3d20d7e4bd005
│ Base f64fb2c8fe28f7c458c72ec8d700373924794943
│ Branches feature/2
│ Commits ahead 2, behind 1
│ Status open
├────────────────────────────────────────────────────────────────────
│ 7f63fcb Add Mel
│ 5c88a79 Add Alan
├────────────────────────────────────────────────────────────────────
│ ● opened by (you) [ ... ]
╰────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────╮
│ Title Add Mel │
│ Patch 53d5f17aba5fd9b7de7a02ecb6f01de561701eeb │
│ Author z6MknSL…StBU8Vi (you)
│ Head 7f63fcbcf23fc39eea784c091ad3d20d7e4bd005 │
│ Base f64fb2c8fe28f7c458c72ec8d700373924794943 │
│ Branches feature/2 │
│ Commits ahead 2, behind 1 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 7f63fcb Add Mel │
│ 5c88a79 Add Alan │
├────────────────────────────────────────────────────┤
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
╰────────────────────────────────────────────────────╯
```
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 459dc67a024ff30c3bca02f0f1e5b746459ce32a
╭────────────────────────────────────────────────────────────────────
│ Title Add Mel #2
│ Patch 459dc67a024ff30c3bca02f0f1e5b746459ce32a
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Head 7f63fcbcf23fc39eea784c091ad3d20d7e4bd005
│ Base 5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7
│ Branches feature/2
│ Commits ahead 2, behind 1
│ Status open
├────────────────────────────────────────────────────────────────────
│ 7f63fcb Add Mel
├────────────────────────────────────────────────────────────────────
│ ● opened by (you) [ ... ]
╰────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────╮
│ Title Add Mel #2
│ Patch 459dc67a024ff30c3bca02f0f1e5b746459ce32a │
│ Author z6MknSL…StBU8Vi (you)
│ Head 7f63fcbcf23fc39eea784c091ad3d20d7e4bd005 │
│ Base 5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7 │
│ Branches feature/2 │
│ Commits ahead 2, behind 1 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 7f63fcb Add Mel │
├────────────────────────────────────────────────────┤
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
╰────────────────────────────────────────────────────╯
```

View File

@ -18,19 +18,19 @@ We can confirm it's a draft by running `show`:
```
$ rad patch show 79a1a5138b7f91c6dead5544ecde285dc3d0cb45
╭────────────────────────────────────────────────────────────────────
│ Title Nothing yet
│ Patch 79a1a5138b7f91c6dead5544ecde285dc3d0cb45
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Head 2a465832b5a76abe25be44a3a5d224bbd7741ba7
│ Branches cloudhead/draft
│ Commits ahead 1, behind 0
│ Status draft
├────────────────────────────────────────────────────────────────────
│ 2a46583 Nothing to see here..
├────────────────────────────────────────────────────────────────────
│ ● opened by (you) [ ... ]
╰────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────╮
│ Title Nothing yet │
│ Patch 79a1a5138b7f91c6dead5544ecde285dc3d0cb45 │
│ Author z6MknSL…StBU8Vi (you)
│ Head 2a465832b5a76abe25be44a3a5d224bbd7741ba7 │
│ Branches cloudhead/draft │
│ Commits ahead 1, behind 0 │
│ Status draft │
├────────────────────────────────────────────────────┤
│ 2a46583 Nothing to see here.. │
├────────────────────────────────────────────────────┤
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
╰────────────────────────────────────────────────────╯
```
Once the patch is ready for review, we can use the `ready` command:
@ -41,19 +41,19 @@ $ rad patch ready 79a1a5138b7f91c6dead5544ecde285dc3d0cb45
```
$ rad patch show 79a1a5138b7f91c6dead5544ecde285dc3d0cb45
╭────────────────────────────────────────────────────────────────────
│ Title Nothing yet
│ Patch 79a1a5138b7f91c6dead5544ecde285dc3d0cb45
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Head 2a465832b5a76abe25be44a3a5d224bbd7741ba7
│ Branches cloudhead/draft
│ Commits ahead 1, behind 0
│ Status open
├────────────────────────────────────────────────────────────────────
│ 2a46583 Nothing to see here..
├────────────────────────────────────────────────────────────────────
│ ● opened by (you) [ ... ]
╰────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────╮
│ Title Nothing yet │
│ Patch 79a1a5138b7f91c6dead5544ecde285dc3d0cb45 │
│ Author z6MknSL…StBU8Vi (you)
│ Head 2a465832b5a76abe25be44a3a5d224bbd7741ba7 │
│ Branches cloudhead/draft │
│ Commits ahead 1, behind 0 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 2a46583 Nothing to see here.. │
├────────────────────────────────────────────────────┤
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
╰────────────────────────────────────────────────────╯
```
If for whatever reason, it needed to go back into draft mode, we could use
@ -62,16 +62,16 @@ the `--undo` flag:
```
$ rad patch ready --undo 79a1a5138b7f91c6dead5544ecde285dc3d0cb45
$ rad patch show 79a1a5138b7f91c6dead5544ecde285dc3d0cb45
╭─────────────────────────────────────────────────────────────────────────────────────────
│ Title Nothing yet
│ Patch 79a1a5138b7f91c6dead5544ecde285dc3d0cb45
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Head 2a465832b5a76abe25be44a3a5d224bbd7741ba7
│ Branches cloudhead/draft
│ Commits ahead 1, behind 0
│ Status draft
├─────────────────────────────────────────────────────────────────────────────────────────
│ 2a46583 Nothing to see here..
├─────────────────────────────────────────────────────────────────────────────────────────
│ ● opened by (you) [ ... ]
╰─────────────────────────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────╮
│ Title Nothing yet │
│ Patch 79a1a5138b7f91c6dead5544ecde285dc3d0cb45 │
│ Author z6MknSL…StBU8Vi (you)
│ Head 2a465832b5a76abe25be44a3a5d224bbd7741ba7 │
│ Branches cloudhead/draft │
│ Commits ahead 1, behind 0 │
│ Status draft │
├────────────────────────────────────────────────────┤
│ 2a46583 Nothing to see here.. │
├────────────────────────────────────────────────────┤
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
╰────────────────────────────────────────────────────╯

View File

@ -88,7 +88,7 @@ $ rad patch show 26e3e56
╭──────────────────────────────────────────────────────────────────────────────╮
│ Title Bob's patch │
│ Patch 26e3e563ddc7df8dd0c9f81274c0b3cb1b764568 │
│ Author did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
│ Author bob z6Mkt67…v4N1tRk
│ Head cad2666a8a2250e4dee175ed5044be2c251ff08b │
│ Commits ahead 2, behind 0 │
│ Status open │
@ -96,7 +96,7 @@ $ rad patch show 26e3e56
│ cad2666 Bob's commit #2
│ bdcdb30 Bob's commit #1
├──────────────────────────────────────────────────────────────────────────────┤
│ ● opened by bob (z6Mkt67…v4N1tRk) [ ... ] │
│ ● opened by bob z6Mkt67…v4N1tRk [ ... ]
│ ↑ updated to c04ef81bad734c65a7d5834cefcdd60c4f0484f7 (cad2666) [ ... ] │
╰──────────────────────────────────────────────────────────────────────────────╯
$ git ls-remote rad

View File

@ -13,19 +13,19 @@ To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkE
```
$ rad patch show ea6fa6c274c55d0f4fdf203a192cbf1330b51221
╭────────────────────────────────────────────────────────────────────
│ Title Not a real change
│ Patch ea6fa6c274c55d0f4fdf203a192cbf1330b51221
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Head 51b2f0f77b9849bfaa3e9d3ff68ee2f57771d20c
│ Branches feature/1
│ Commits ahead 1, behind 0
│ Status open
├────────────────────────────────────────────────────────────────────
│ 51b2f0f Not a real change
├────────────────────────────────────────────────────────────────────
│ ● opened by (you) [ ... ]
╰────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────╮
│ Title Not a real change │
│ Patch ea6fa6c274c55d0f4fdf203a192cbf1330b51221 │
│ Author z6MknSL…StBU8Vi (you)
│ Head 51b2f0f77b9849bfaa3e9d3ff68ee2f57771d20c │
│ Branches feature/1 │
│ Commits ahead 1, behind 0 │
│ Status open │
├────────────────────────────────────────────────────┤
│ 51b2f0f Not a real change │
├────────────────────────────────────────────────────┤
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
╰────────────────────────────────────────────────────╯
```
We can make some changes to the repository:
@ -57,7 +57,7 @@ $ rad patch show ea6fa6c274c55d0f4fdf203a192cbf1330b51221
╭──────────────────────────────────────────────────────────────────────────────╮
│ Title Not a real change │
│ Patch ea6fa6c274c55d0f4fdf203a192cbf1330b51221 │
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Author z6MknSL…StBU8Vi (you)
│ Head 4d272148458a17620541555b1f0905c01658aa9f │
│ Branches feature/1 │
│ Commits ahead 2, behind 0 │
@ -66,7 +66,7 @@ $ rad patch show ea6fa6c274c55d0f4fdf203a192cbf1330b51221
│ 4d27214 Rename readme file │
│ 51b2f0f Not a real change │
├──────────────────────────────────────────────────────────────────────────────┤
│ ● opened by (you) [ ... ]
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ]
│ ↑ updated to 59bbb5c5d3c9f18a686113e6354b1372eebafda4 (4d27214) [ ... ] │
╰──────────────────────────────────────────────────────────────────────────────╯
```

View File

@ -17,21 +17,21 @@ We can see a patch was created:
```
$ rad patch show 90c77f2
╭────────────────────────────────────────────────────────────────────
│ Title Add things #1
│ Patch 90c77f2c33b7e472e058de4a586156f8a7fec7d6
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Head 42d894a83c9c356552a57af09ccdbd5587a99045
│ Branches feature/1
│ Commits ahead 1, behind 0
│ Status open
│ See commits for details.
├────────────────────────────────────────────────────────────────────
│ 42d894a Add things
├────────────────────────────────────────────────────────────────────
│ ● opened by (you) [ ... ]
╰────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────╮
│ Title Add things #1
│ Patch 90c77f2c33b7e472e058de4a586156f8a7fec7d6 │
│ Author z6MknSL…StBU8Vi (you)
│ Head 42d894a83c9c356552a57af09ccdbd5587a99045 │
│ Branches feature/1 │
│ Commits ahead 1, behind 0 │
│ Status open │
│ │
│ See commits for details. │
├────────────────────────────────────────────────────┤
│ 42d894a Add things │
├────────────────────────────────────────────────────┤
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
╰────────────────────────────────────────────────────╯
```
If we check our local branch, we can see its upstream is set to track a remote
@ -132,7 +132,7 @@ $ rad patch show fedf0e4
╭──────────────────────────────────────────────────────────────────────────────╮
│ Title Add more things │
│ Patch fedf0e4dcb74ff6db1d5e30a6a254b77f02ff60b │
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Author z6MknSL…StBU8Vi (you)
│ Head 02bef3fac41b2f98bb3c02b868a53ddfecb55b5f │
│ Branches feature/2 │
│ Commits ahead 2, behind 0 │
@ -141,7 +141,7 @@ $ rad patch show fedf0e4
│ 02bef3f Improve code │
│ 8b0ea80 Add more things │
├──────────────────────────────────────────────────────────────────────────────┤
│ ● opened by (you) [ ... ]
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
│ ↑ updated to d0018fcc21d87c91a1ff9155aed6b4e57535566b (02bef3f) [ ... ] │
╰──────────────────────────────────────────────────────────────────────────────╯
```
@ -208,7 +208,7 @@ $ rad patch show fedf0e4
╭──────────────────────────────────────────────────────────────────────────────╮
│ Title Add more things │
│ Patch fedf0e4dcb74ff6db1d5e30a6a254b77f02ff60b │
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Author z6MknSL…StBU8Vi (you)
│ Head 9304dbc445925187994a7a93222a3f8bde73b785 │
│ Branches feature/2 │
│ Commits ahead 2, behind 0 │
@ -217,7 +217,7 @@ $ rad patch show fedf0e4
│ 9304dbc Amended commit │
│ 8b0ea80 Add more things │
├──────────────────────────────────────────────────────────────────────────────┤
│ ● opened by (you) [ ... ]
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
│ ↑ updated to d0018fcc21d87c91a1ff9155aed6b4e57535566b (02bef3f) [ ... ] │
│ ↑ updated to 31ecf28817c44d90686b5c3c624c1f4a534b6478 (9304dbc) [ ... ] │
╰──────────────────────────────────────────────────────────────────────────────╯

View File

@ -43,21 +43,21 @@ $ rad patch
```
```
$ rad patch show 73b73f376e93e09e0419664766ac9e433bf7d389 -p
╭────────────────────────────────────────────────────────────────────
│ Title Define power requirements
│ Patch 73b73f376e93e09e0419664766ac9e433bf7d389
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Head 3e674d1a1df90807e934f9ae5da2591dd6848a33
│ Branches flux-capacitor-power
│ Commits ahead 1, behind 0
│ Status open
│ See details.
├────────────────────────────────────────────────────────────────────
│ 3e674d1 Define power requirements
├────────────────────────────────────────────────────────────────────
│ ● opened by (you) [ ... ]
╰────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch 73b73f376e93e09e0419664766ac9e433bf7d389 │
│ Author z6MknSL…StBU8Vi (you)
│ Head 3e674d1a1df90807e934f9ae5da2591dd6848a33 │
│ Branches flux-capacitor-power │
│ Commits ahead 1, behind 0 │
│ Status open │
│ │
│ See details. │
├────────────────────────────────────────────────────┤
│ 3e674d1 Define power requirements │
├────────────────────────────────────────────────────┤
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
╰────────────────────────────────────────────────────╯
commit 3e674d1a1df90807e934f9ae5da2591dd6848a33
Author: radicle <radicle@localhost>
@ -126,7 +126,7 @@ $ rad patch show 73b73f3
╭──────────────────────────────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch 73b73f376e93e09e0419664766ac9e433bf7d389 │
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Author z6MknSL…StBU8Vi (you)
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66 │
│ Branches flux-capacitor-power, patch/73b73f3 │
│ Commits ahead 2, behind 0 │
@ -137,9 +137,9 @@ $ rad patch show 73b73f3
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├──────────────────────────────────────────────────────────────────────────────┤
│ ● opened by (you) [ ... ]
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
│ ↑ updated to 5605784ae81dad91ba47ea55e19dd16f6280d44b (27857ec) [ ... ] │
│ ✓ accepted by (you) [ ... ]
│ ✓ accepted by z6MknSL…StBU8Vi (you) [ ... ] │
╰──────────────────────────────────────────────────────────────────────────────╯
```
@ -151,7 +151,7 @@ $ rad patch show 73b73f3
╭──────────────────────────────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch 73b73f376e93e09e0419664766ac9e433bf7d389 │
│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
│ Author z6MknSL…StBU8Vi (you)
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66 │
│ Branches flux-capacitor-power, patch/73b73f3 │
│ Commits ahead 2, behind 0 │
@ -162,8 +162,8 @@ $ rad patch show 73b73f3
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├──────────────────────────────────────────────────────────────────────────────┤
│ ● opened by (you) [ ... ]
│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │
│ ↑ updated to 5605784ae81dad91ba47ea55e19dd16f6280d44b (27857ec) [ ... ] │
│ ✓ accepted by (you) [ ... ]
│ ✓ accepted by z6MknSL…StBU8Vi (you) [ ... ] │
╰──────────────────────────────────────────────────────────────────────────────╯
```

View File

@ -8,6 +8,7 @@ $ rad issue open --title "flux capacitor underpowered" --description "Flux capac
╭─────────────────────────────────────────────────────────╮
│ Title flux capacitor underpowered │
│ Issue 2f6eb49efac492327f71437b6bfc01b49afa0981 │
│ Author bob (you) │
│ Status open │
│ │
│ Flux capacitor power requirements exceed current supply │
@ -18,11 +19,11 @@ The issue is now listed under our project.
```
$ rad issue list
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ ● ID Title Author Labels Assignees Opened │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ ● 2f6eb49 flux capacitor underpowered z6Mkt67…v4N1tRk bob (you) [ .. ] │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ● ID Title Author Labels Assignees Opened │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ● 2f6eb49 flux capacitor underpowered bob (you) [ .. ] │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
```
Great! Now we've documented the issue for ourselves and others.
@ -40,11 +41,11 @@ It will now show in the list of issues assigned to us.
```
$ rad issue list --assigned
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ ● ID Title Author Labels Assignees Opened │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ ● 2f6eb49 flux capacitor underpowered z6Mkt67…v4N1tRk bob (you) bob (z6Mkt67…v4N1tRk) [ .. ] │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ● ID Title Author Labels Assignees Opened │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ● 2f6eb49 flux capacitor underpowered bob (you) bob [ .. ] │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
```
In addition, you can see that when you run `rad issue show` you are listed under the `Assignees`.
@ -54,6 +55,7 @@ $ rad issue show 2f6eb49
╭─────────────────────────────────────────────────────────╮
│ Title flux capacitor underpowered │
│ Issue 2f6eb49efac492327f71437b6bfc01b49afa0981 │
│ Author bob (you) │
│ Assignees z6Mkt67…v4N1tRk │
│ Status open │
│ │

View File

@ -35,27 +35,27 @@ It will now be listed as one of the project's open patches.
```
$ rad patch
╭──────────────────────────────────────────────────────────────────────────────────────────────────
│ ● ID Title Author Head + - Updated │
├──────────────────────────────────────────────────────────────────────────────────────────────────
│ ● 69e881c Define power requirements z6Mkt67…v4N1tRk bob (you) 3e674d1 +0 -0 [ ... ] │
╰──────────────────────────────────────────────────────────────────────────────────────────────────
╭─────────────────────────────────────────────────────────────────────────────────────╮
│ ● ID Title Author Head + - Updated │
├─────────────────────────────────────────────────────────────────────────────────────┤
│ ● 69e881c Define power requirements bob (you) 3e674d1 +0 -0 [ ... ] │
╰─────────────────────────────────────────────────────────────────────────────────────╯
$ rad patch show 69e881c606639691330051d7d8f013854f32fb87
╭────────────────────────────────────────────────────────────────────
│ Title Define power requirements
│ Patch 69e881c606639691330051d7d8f013854f32fb87
│ Author did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
│ Head 3e674d1a1df90807e934f9ae5da2591dd6848a33
│ Branches flux-capacitor-power
│ Commits ahead 1, behind 0
│ Status open
│ See details.
├────────────────────────────────────────────────────────────────────
│ 3e674d1 Define power requirements
├────────────────────────────────────────────────────────────────────
│ ● opened by bob (you) [ ... ]
╰────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch 69e881c606639691330051d7d8f013854f32fb87 │
│ Author bob (you)
│ Head 3e674d1a1df90807e934f9ae5da2591dd6848a33 │
│ Branches flux-capacitor-power │
│ Commits ahead 1, behind 0 │
│ Status open │
│ │
│ See details. │
├────────────────────────────────────────────────────┤
│ 3e674d1 Define power requirements │
├────────────────────────────────────────────────────┤
│ ● opened by bob (you) [ ... ] │
╰────────────────────────────────────────────────────╯
```
We can also confirm that the patch branch is in storage:

View File

@ -37,7 +37,7 @@ $ rad patch show 69e881c
╭──────────────────────────────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch 69e881c606639691330051d7d8f013854f32fb87 │
│ Author did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
│ Author bob z6Mkt67…v4N1tRk
│ Head 27857ec9eb04c69cacab516e8bf4b5fd36090f66 │
│ Commits ahead 2, behind 0 │
│ Status open │
@ -47,7 +47,7 @@ $ rad patch show 69e881c
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├──────────────────────────────────────────────────────────────────────────────┤
│ ● opened by bob (z6Mkt67…v4N1tRk) [ ... ] │
│ ● opened by bob z6Mkt67…v4N1tRk [ ... ]
│ ↑ updated to dcf3e6dd97c95cf8653cbb8ce47df20d28eb1821 (27857ec) [ ... ] │
╰──────────────────────────────────────────────────────────────────────────────╯
```
@ -97,7 +97,7 @@ $ rad patch show 69e881c
╭──────────────────────────────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch 69e881c606639691330051d7d8f013854f32fb87 │
│ Author did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
│ Author bob z6Mkt67…v4N1tRk
│ Head f567f695d25b4e8fb63b5f5ad2a584529826e908 │
│ Branches master, patch/69e881c │
│ Commits up to date │
@ -109,7 +109,7 @@ $ rad patch show 69e881c
│ 27857ec Add README, just for the fun │
│ 3e674d1 Define power requirements │
├──────────────────────────────────────────────────────────────────────────────┤
│ ● opened by bob (z6Mkt67…v4N1tRk) [ ... ] │
│ ● opened by bob z6Mkt67…v4N1tRk [ ... ]
│ ↑ updated to dcf3e6dd97c95cf8653cbb8ce47df20d28eb1821 (27857ec) [ ... ] │
│ ↑ updated to ab05fcdca93cf4d5b22da8913e2fe0b6d8c79338 (f567f69) [ ... ] │
│ ✓ merged by alice (you) [ ... ] │

View File

@ -10,14 +10,15 @@ use radicle::cob::issue;
use radicle::cob::issue::{CloseReason, Issues, State};
use radicle::cob::thread;
use radicle::crypto::Signer;
use radicle::node::{AliasStore, Handle};
use radicle::node::Handle;
use radicle::prelude::Did;
use radicle::profile;
use radicle::storage;
use radicle::storage::{WriteRepository, WriteStorage};
use radicle::Profile;
use radicle::{cob, Node};
use radicle_term::table::TableOptions;
use radicle_term::{Paint, Table, VStack};
use radicle_term::{Table, VStack};
use crate::git::Rev;
use crate::terminal as term;
@ -288,7 +289,15 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
title,
description,
} => {
edit(&mut issues, &signer, &repo, id, title, description)?;
edit(
&mut issues,
&signer,
&repo,
id,
title,
description,
&profile,
)?;
}
Operation::Open {
title: Some(title),
@ -297,7 +306,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
} => {
let issue = issues.create(title, description, labels.as_slice(), &[], [], &signer)?;
if !options.quiet {
show_issue(&issue, issue.id())?;
show_issue(&issue, issue.id(), &profile)?;
}
}
Operation::Show { id } => {
@ -305,7 +314,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
let issue = issues
.get(&id)?
.context("No issue with the given ID exists")?;
show_issue(&issue, &id)?;
show_issue(&issue, &id, &profile)?;
}
Operation::State { id, state } => {
let id = id.resolve(&repo.backend)?;
@ -338,6 +347,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
&options,
&mut issues,
&signer,
&profile,
)?;
}
Operation::List { assigned, state } => {
@ -412,24 +422,20 @@ fn list<R: WriteRepository + cob::Store>(
term::format::bold(String::from("ID")).into(),
term::format::bold(String::from("Title")).into(),
term::format::bold(String::from("Author")).into(),
term::format::bold(String::new()).into(),
term::Line::blank(),
term::format::bold(String::from("Labels")).into(),
term::format::bold(String::from("Assignees")).into(),
term::format::bold(String::from("Opened")).into(),
]);
table.divider();
let aliases = profile.aliases();
for (id, issue) in all {
let assigned: String = issue
.assigned()
.map(|p| {
if let Some(alias) = aliases.alias(p) {
format!("{alias} ({})", term::format::did(p))
} else {
term::format::did(p).to_string()
}
.map(|did| {
let (alias, _) = Author::new(did.as_key(), profile).labels();
alias.content().to_owned()
})
.collect::<Vec<_>>()
.join(", ");
@ -438,8 +444,7 @@ fn list<R: WriteRepository + cob::Store>(
labels.sort();
let author = issue.author().id;
let alias = aliases.alias(&author);
let display = Author::new(&author, alias, profile);
let (alias, did) = Author::new(&author, profile).labels();
table.push([
match issue.state() {
@ -450,13 +455,13 @@ fn list<R: WriteRepository + cob::Store>(
.to_owned()
.into(),
term::format::default(issue.title().to_owned()).into(),
term::format::did(&issue.author().id).dim().into(),
display.alias(),
alias.into(),
did.into(),
term::format::secondary(labels.join(", ")).into(),
if assigned.is_empty() {
term::format::dim(String::default()).into()
} else {
term::format::default(assigned.to_string()).into()
term::format::primary(assigned.to_string()).dim().into()
},
term::format::timestamp(&issue.timestamp())
.dim()
@ -554,6 +559,7 @@ fn open<R: WriteRepository + cob::Store, G: Signer>(
options: &Options,
issues: &mut Issues<R>,
signer: &G,
profile: &Profile,
) -> anyhow::Result<()> {
let Some((meta, description)) = prompt_issue(
&title.unwrap_or_default(),
@ -573,7 +579,7 @@ fn open<R: WriteRepository + cob::Store, G: Signer>(
signer,
)?;
if !options.quiet {
show_issue(&issue, issue.id())?;
show_issue(&issue, issue.id(), profile)?;
}
Ok(())
@ -586,6 +592,7 @@ fn edit<R: WriteRepository + cob::Store, G: radicle::crypto::Signer>(
id: Rev,
title: Option<String>,
description: Option<String>,
profile: &Profile,
) -> anyhow::Result<()> {
let id = id.resolve(&repo.backend)?;
let mut issue = issues.get_mut(&id)?;
@ -629,56 +636,65 @@ fn edit<R: WriteRepository + cob::Store, G: radicle::crypto::Signer>(
Ok(())
})?;
show_issue(&issue, &id)?;
show_issue(&issue, &id, profile)?;
Ok(())
}
fn show_issue(issue: &issue::Issue, id: &cob::ObjectId) -> anyhow::Result<()> {
fn show_issue(issue: &issue::Issue, id: &cob::ObjectId, profile: &Profile) -> anyhow::Result<()> {
let labels: Vec<String> = issue.labels().cloned().map(|t| t.into()).collect();
let assignees: Vec<String> = issue
.assigned()
.map(|a| term::format::did(a).to_string())
.collect();
let author = issue.author();
let did = author.id();
let author = Author::new(did, profile);
let mut attrs = Table::<2, Paint<String>>::new(TableOptions {
let mut attrs = Table::<2, term::Line>::new(TableOptions {
spacing: 2,
..TableOptions::default()
});
attrs.push([
term::format::tertiary("Title".to_owned()),
term::format::bold(issue.title().to_owned()),
term::format::tertiary("Title".to_owned()).into(),
term::format::bold(issue.title().to_owned()).into(),
]);
attrs.push([
term::format::tertiary("Issue".to_owned()),
term::format::bold(id.to_string()),
term::format::tertiary("Issue".to_owned()).into(),
term::format::bold(id.to_string()).into(),
]);
attrs.push([
term::format::tertiary("Author".to_owned()).into(),
author.line(),
]);
if !labels.is_empty() {
attrs.push([
term::format::tertiary("Labels".to_owned()),
term::format::secondary(labels.join(", ")),
term::format::tertiary("Labels".to_owned()).into(),
term::format::secondary(labels.join(", ")).into(),
]);
}
if !assignees.is_empty() {
attrs.push([
term::format::tertiary("Assignees".to_owned()),
term::format::dim(assignees.join(", ")),
term::format::tertiary("Assignees".to_owned()).into(),
term::format::dim(assignees.join(", ")).into(),
]);
}
attrs.push([
term::format::tertiary("Status".to_owned()),
term::format::tertiary("Status".to_owned()).into(),
match issue.state() {
issue::State::Open => term::format::positive("open".to_owned()),
issue::State::Open => term::format::positive("open".to_owned()).into(),
issue::State::Closed { reason } => term::format::default(format!(
"{} {}",
term::format::negative("closed"),
term::format::default(format!("as {reason}"))
)),
))
.into(),
},
]);

View File

@ -36,7 +36,7 @@ fn print_table(entries: impl IntoIterator<Item = (Id, NodeId)>) {
for (rid, nid) in entries {
t.push([
term::format::highlight(rid.to_string()),
term::format::default(term::format::node(&nid)),
term::format::node(&nid),
]);
}
t.print();

View File

@ -1,6 +1,5 @@
use radicle::cob::patch;
use radicle::cob::patch::{Patch, PatchId, Patches, Verdict};
use radicle::node::AliasStore;
use radicle::prelude::*;
use radicle::profile::Profile;
use radicle::storage::git::Repository;
@ -48,7 +47,7 @@ pub fn run(
term::format::bold(String::from("ID")).into(),
term::format::bold(String::from("Title")).into(),
term::format::bold(String::from("Author")).into(),
term::format::bold(String::new()).into(),
term::Line::blank(),
term::format::bold(String::from("Head")).into(),
term::format::bold(String::from("+")).into(),
term::format::bold(String::from("-")).into(),
@ -65,13 +64,9 @@ pub fn run(
is_me.then(by_rev_time).then(by_id)
});
let aliases = profile.aliases();
let mut errors = Vec::new();
for (id, patch) in &mut all {
let author_id = patch.author().id();
let alias = aliases.alias(author_id);
match row(profile, alias, id, patch, repository) {
match row(id, patch, repository, profile) {
Ok(r) => table.push(r),
Err(e) => errors.push((patch.title(), id, e.to_string())),
}
@ -92,18 +87,17 @@ pub fn run(
/// Patch row.
pub fn row(
profile: &Profile,
alias: Option<Alias>,
id: &PatchId,
patch: &Patch,
repository: &Repository,
profile: &Profile,
) -> anyhow::Result<[term::Line; 9]> {
let state = patch.state();
let (_, revision) = patch.latest();
let (from, to) = patch.range(repository)?;
let stats = common::diff_stats(repository.raw(), &from, &to)?;
let author = patch.author().id;
let display = Author::new(&author, alias, profile);
let (alias, did) = Author::new(&author, profile).labels();
Ok([
match state {
@ -114,8 +108,8 @@ pub fn row(
},
term::format::tertiary(term::format::cob(id)).into(),
term::format::default(patch.title().to_owned()).into(),
term::format::did(&author).dim().into(),
display.alias(),
alias.into(),
did.into(),
term::format::secondary(term::format::oid(revision.head())).into(),
term::format::positive(format!("+{}", stats.insertions())).into(),
term::format::negative(format!("-{}", stats.deletions())).into(),
@ -132,14 +126,12 @@ pub fn timeline(
patch: &Patch,
repository: &Repository,
) -> anyhow::Result<Vec<term::Line>> {
let aliases = profile.aliases();
let alias = aliases.alias(patch.author().id());
let open = term::Line::spaced([
term::format::positive("").into(),
term::format::default("opened by").into(),
])
.space()
.extend(Author::new(patch.author().id(), alias, profile));
.extend(Author::new(patch.author().id(), profile).line());
let mut timeline = vec![(patch.timestamp(), open)];
@ -165,14 +157,13 @@ pub fn timeline(
for (nid, merge) in patch.merges().filter(|(_, m)| m.revision == *revision_id) {
let peer = repository.remote(nid)?;
let alias = aliases.alias(&peer.id);
let line = term::Line::spaced([
term::format::primary("").bold().into(),
term::format::default("merged").into(),
term::format::default("by").into(),
])
.space()
.extend(Author::new(&peer.id, alias, profile));
.extend(Author::new(&peer.id, profile).line());
timeline.push((merge.timestamp, line));
}
@ -189,14 +180,13 @@ pub fn timeline(
None => term::format::default("reviewed"),
};
let peer = repository.remote(reviewer)?;
let alias = aliases.alias(&peer.id);
let line = term::Line::spaced([
verdict_symbol.into(),
verdict_verb.into(),
term::format::default("by").into(),
])
.space()
.extend(Author::new(&peer.id, alias, profile));
.extend(Author::new(&peer.id, profile).line());
timeline.push((review.timestamp(), line));
}

View File

@ -74,6 +74,8 @@ pub fn run(
*revision.head(),
*patch.target().head(stored)?,
)?;
let author = patch.author();
let author = term::format::Author::new(author.id(), profile);
let mut attrs = Table::<2, term::Line>::new(TableOptions {
spacing: 2,
@ -89,7 +91,7 @@ pub fn run(
]);
attrs.push([
term::format::tertiary("Author".to_owned()).into(),
term::format::default(patch.author().id().to_string()).into(),
author.line(),
]);
attrs.push([
term::format::tertiary("Head".to_owned()).into(),

View File

@ -12,12 +12,12 @@ use radicle_term::element::Line;
use crate::terminal as term;
/// Format a node id to be more compact.
pub fn node(node: &NodeId) -> String {
pub fn node(node: &NodeId) -> Paint<String> {
let node = node.to_human();
let start = node.chars().take(7).collect::<String>();
let end = node.chars().skip(node.len() - 7).collect::<String>();
format!("{start}{end}")
Paint::new(format!("{start}{end}"))
}
/// Format a git Oid.
@ -120,7 +120,7 @@ impl<'a> fmt::Display for Identity<'a> {
let nid = self.profile.id();
let alias = self.profile.aliases().alias(nid);
let node_id = match self.short {
true => self::node(nid),
true => self::node(nid).to_string(),
false => nid.to_human(),
};
@ -140,88 +140,45 @@ impl<'a> fmt::Display for Identity<'a> {
}
/// This enum renders (nid, alias) in terminal depending on user variant.
pub enum Author<'a> {
Author {
nid: &'a NodeId,
alias: Option<Alias>,
},
Me {
alias: Option<Alias>,
},
pub struct Author<'a> {
nid: &'a NodeId,
alias: Option<Alias>,
you: bool,
}
impl<'a> Author<'a> {
pub fn new(nid: &'a NodeId, alias: Option<Alias>, me: &Profile) -> Author<'a> {
if nid == me.id() {
Self::Me { alias }
pub fn new(nid: &'a NodeId, profile: &Profile) -> Author<'a> {
let alias = profile.aliases().alias(nid);
Self {
nid,
alias,
you: nid == profile.id(),
}
}
pub fn labels(self) -> (term::Label, term::Label) {
let alias = match &self.alias {
Some(alias) => term::format::primary(alias).into(),
None => term::format::primary(term::format::node(self.nid))
.dim()
.into(),
};
if self.you {
(alias, term::format::primary("(you)").dim().italic().into())
} else {
Self::Author { nid, alias }
(
alias,
term::format::primary(term::format::node(self.nid))
.dim()
.into(),
)
}
}
/// Author: `<alias>` || ``
/// Me : `<alias> (you)` || `(you)`
pub fn alias(&self) -> Line {
match self {
Self::Me { alias } => {
if let Some(alias) = alias {
term::Line::spaced([
term::format::primary(alias).into(),
term::format::primary("(you)").dim().into(),
])
} else {
term::format::primary("(you)").into()
}
}
Self::Author { alias, .. } => {
if let Some(alias) = alias {
term::format::primary(alias).into()
} else {
term::format::default(String::new()).into()
}
}
}
}
}
impl<'a> IntoIterator for Author<'a> {
type Item = term::Label;
type IntoIter = std::vec::IntoIter<Self::Item>;
/// Author : `<alias> (<compact-nid>)` || `<nid>`
/// Me : `<alias> (you)` || `(you)`
fn into_iter(self) -> Self::IntoIter {
let mut line = Vec::new();
match self {
Self::Me { alias } => {
if let Some(alias) = alias {
line.push(term::format::primary(alias).into());
line.push(term::Label::space());
line.push(term::format::primary("(you)").dim().into());
} else {
line.push(term::format::primary("(you)").into());
}
}
Self::Author { nid, alias } => {
if let Some(alias) = alias {
line.push(term::format::primary(alias).into());
line.push(term::Label::space());
line.push(
term::format::tertiary(term::format::parens(
term::format::node(nid).into(),
))
.into(),
);
} else {
line.push(term::format::tertiary(nid).into());
}
}
}
line.into_iter()
pub fn line(self) -> Line {
let (first, second) = self.labels();
Line::spaced([first, second])
}
}

View File

@ -92,6 +92,11 @@ impl Line {
}
}
/// Create a blank line.
pub fn blank() -> Self {
Self { items: vec![] }
}
pub fn spaced(items: impl IntoIterator<Item = Label>) -> Self {
let mut line = Self::default();
for item in items.into_iter() {

View File

@ -17,6 +17,11 @@ impl Label {
Self(Paint::default())
}
/// Get unstyled content.
pub fn content(&self) -> &str {
self.0.content()
}
/// Create a single space label
pub fn space() -> Self {
Self(Paint::new(" ".to_owned()))