cli: Add issue id to `show_issue` function

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez 2023-06-06 10:48:04 +02:00
parent d2202a07ab
commit 6578fedfbb
No known key found for this signature in database
4 changed files with 16 additions and 5 deletions

View File

@ -7,6 +7,7 @@ Let's say the new car you are designing with your peers has a problem with its f
$ rad issue open --title "flux capacitor underpowered" --description "Flux capacitor power requirements exceed current supply" --no-announce $ rad issue open --title "flux capacitor underpowered" --description "Flux capacitor power requirements exceed current supply" --no-announce
╭─────────────────────────────────────────────────────────╮ ╭─────────────────────────────────────────────────────────╮
│ Title flux capacitor underpowered │ │ Title flux capacitor underpowered │
│ Issue 2e8c1bf3fe0532a314778357c886608a966a34bd │
│ Status open │ │ Status open │
│ │ │ │
│ Flux capacitor power requirements exceed current supply │ │ Flux capacitor power requirements exceed current supply │
@ -30,6 +31,7 @@ Show the issue information issue.
$ rad issue show 2e8c1bf $ rad issue show 2e8c1bf
╭─────────────────────────────────────────────────────────╮ ╭─────────────────────────────────────────────────────────╮
│ Title flux capacitor underpowered │ │ Title flux capacitor underpowered │
│ Issue 2e8c1bf3fe0532a314778357c886608a966a34bd │
│ Status open │ │ Status open │
│ │ │ │
│ Flux capacitor power requirements exceed current supply │ │ Flux capacitor power requirements exceed current supply │

View File

@ -11,6 +11,7 @@ We can now show the issue to check whether those tags were added:
$ rad issue show 2e8c1bf3fe0532a314778357c886608a966a34bd $ rad issue show 2e8c1bf3fe0532a314778357c886608a966a34bd
╭─────────────────────────────────────────────────────────╮ ╭─────────────────────────────────────────────────────────╮
│ Title flux capacitor underpowered │ │ Title flux capacitor underpowered │
│ Issue 2e8c1bf3fe0532a314778357c886608a966a34bd │
│ Tags bug, good-first-issue │ │ Tags bug, good-first-issue │
│ Status open │ │ Status open │
│ │ │ │
@ -30,6 +31,7 @@ Notice that the `good-first-issue` tag has disappeared:
$ rad issue show 2e8c1bf3fe0532a314778357c886608a966a34bd $ rad issue show 2e8c1bf3fe0532a314778357c886608a966a34bd
╭─────────────────────────────────────────────────────────╮ ╭─────────────────────────────────────────────────────────╮
│ Title flux capacitor underpowered │ │ Title flux capacitor underpowered │
│ Issue 2e8c1bf3fe0532a314778357c886608a966a34bd │
│ Tags bug │ │ Tags bug │
│ Status open │ │ Status open │
│ │ │ │

View File

@ -7,6 +7,7 @@ Let's say the new car you are designing with your peers has a problem with its f
$ rad issue open --title "flux capacitor underpowered" --description "Flux capacitor power requirements exceed current supply" --no-announce $ rad issue open --title "flux capacitor underpowered" --description "Flux capacitor power requirements exceed current supply" --no-announce
╭─────────────────────────────────────────────────────────╮ ╭─────────────────────────────────────────────────────────╮
│ Title flux capacitor underpowered │ │ Title flux capacitor underpowered │
│ Issue b05e945bb63c11bf80320f4e26ad1d1f7c51f755 │
│ Status open │ │ Status open │
│ │ │ │
│ Flux capacitor power requirements exceed current supply │ │ Flux capacitor power requirements exceed current supply │
@ -52,6 +53,7 @@ In addition, you can see that when you run `rad issue show` you are listed under
$ rad issue show b05e945 $ rad issue show b05e945
╭─────────────────────────────────────────────────────────╮ ╭─────────────────────────────────────────────────────────╮
│ Title flux capacitor underpowered │ │ Title flux capacitor underpowered │
│ Issue b05e945bb63c11bf80320f4e26ad1d1f7c51f755 │
│ Assignees z6Mkt67…v4N1tRk │ │ Assignees z6Mkt67…v4N1tRk │
│ Status open │ │ Status open │
│ │ │ │

View File

@ -284,7 +284,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
} => { } => {
let issue = issues.create(title, description, tags.as_slice(), &[], &signer)?; let issue = issues.create(title, description, tags.as_slice(), &[], &signer)?;
if !options.quiet { if !options.quiet {
show_issue(&issue)?; show_issue(&issue, issue.id())?;
} }
} }
Operation::Show { id } => { Operation::Show { id } => {
@ -292,7 +292,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
let issue = issues let issue = issues
.get(&id)? .get(&id)?
.context("No issue with the given ID exists")?; .context("No issue with the given ID exists")?;
show_issue(&issue)?; show_issue(&issue, &id)?;
} }
Operation::State { id, state } => { Operation::State { id, state } => {
let id = id.resolve(&repo.backend)?; let id = id.resolve(&repo.backend)?;
@ -536,7 +536,7 @@ fn open<G: Signer>(
signer, signer,
)?; )?;
if !options.quiet { if !options.quiet {
show_issue(&issue)?; show_issue(&issue, issue.id())?;
} }
Ok(()) Ok(())
@ -618,12 +618,12 @@ fn edit<G: radicle::crypto::Signer>(
Ok(()) Ok(())
})?; })?;
show_issue(&issue)?; show_issue(&issue, &id)?;
Ok(()) Ok(())
} }
fn show_issue(issue: &issue::Issue) -> anyhow::Result<()> { fn show_issue(issue: &issue::Issue, id: &cob::ObjectId) -> anyhow::Result<()> {
let tags: Vec<String> = issue.tags().cloned().map(|t| t.into()).collect(); let tags: Vec<String> = issue.tags().cloned().map(|t| t.into()).collect();
let assignees: Vec<String> = issue let assignees: Vec<String> = issue
.assigned() .assigned()
@ -640,6 +640,11 @@ fn show_issue(issue: &issue::Issue) -> anyhow::Result<()> {
term::format::bold(issue.title().to_owned()), term::format::bold(issue.title().to_owned()),
]); ]);
attrs.push([
term::format::tertiary("Issue".to_owned()),
term::format::bold(id.to_string()),
]);
if !tags.is_empty() { if !tags.is_empty() {
attrs.push([ attrs.push([
term::format::tertiary("Tags".to_owned()), term::format::tertiary("Tags".to_owned()),