Back to Codeberg

Repo & Issue labels #334

forgejo-contrib-forgejo-cli-pulls-334.md

latest24.2 KB
Original Source

forgejo-contrib/forgejo-cli

Watch20

Star402

Fork

You've already forked forgejo-cli

51

CodeIssues 44Pull requests 8Releases 11Packages 2WikiActivity

Repo & Issue labels #334

Merged

LordMZTEmerged 11 commits from LordMZTE/forgejo-cli:labels into main 2026-02-25 14:48:58 +01:00

Conversation 4Commits 11Files changed 5 +465 -153

LordMZTE commented 2026-02-19 15:07:07 +01:00

Collaborator

Copy link

This adds commands for managing labels on repositories and issues.

Things done

  • Added repo label subcommands to list, create and delete labels
  • Made issue view also show the issue's labels
  • Extracted logic regarding labels from prs into main and re-used it in issues

Things that still need work

  • issue edit labels -r with/slash fails with
text
Error: the response from forgejo was not properly structured

Caused by:
    invalid type: integer `404`, expected struct APINotFound at line 1 column 3

Location:
    src/main.rs:1008:9

even though the label does exist. Bug in forgejo_api? Not sure.

  • There should probably also be a repo label edit, but I'm unsure of what the UI should look like. Perhaps something interactive with crate::editor? Feedback appreciated!

    • There's already org label edit, but I think that's got a rather primitive UI.
  • Maybe find some way to de-duplicate repo label with org label?

Note about #311

While this PR does implement the same thing as #311, all code was written by me with absolutely no AI involved. I have also avoided of looking at the code of #311 as to not accidentally reproduce it.

Closes #280

This adds commands for managing labels on repositories and issues. ## Things done - Added repo label subcommands to list, create and delete labels - Made issue view also show the issue's labels - Extracted logic regarding labels from prs into main and re-used it in issues ## Things that still need work - [x] issue edit labels -r with/slash fails with Error: the response from forgejo was not properly structured Caused by: invalid type: integer `404`, expected struct APINotFound at line 1 column 3 Location: src/main.rs:1008:9 even though the label does exist. Bug in forgejo_api? Not sure. - [x] There should probably also be a repo label edit, but I'm unsure of what the UI should look like. Perhaps something interactive with crate::editor? Feedback appreciated! - There's already org label edit, but I think that's got a rather primitive UI. - [x] Maybe find some way to de-duplicate repo label with org label? ## Note about #311 While this PR does implement the same thing as #311, all code was written by me with absolutely no AI involved. I have also avoided of looking at the code of #311 as to not accidentally reproduce it. Closes #280

❤️ 1 🚀 1

LordMZTE added the Kind/Feature label 2026-02-19 15:07:07 +01:00

LordMZTE requested review from Cyborus 2026-02-19 15:07:22 +01:00

Cyborus requested changes 2026-02-20 18:04:18 +01:00 Dismissed

Cyborus left a comment

Copy link

  • issue edit labels -r X fails with

Hm, I'm not able to reproduce that?

  • There should probably also be a repo label edit, but I'm unsure of what the UI should look like. Perhaps something interactive with crate::editor? Feedback appreciated!
  • There's already org label edit, but I think that's got a rather primitive UI.

org label edit is in-line with how many other edit commands work, so I'd go with repo label edit being similar for now. I wouldn't be opposed to an interactive option too. Could open a yaml file in the editor?

  • Maybe find some way to de-duplicate repo label with org label?

That would be nice, but I'm not immediately sure how to do that given they hit different endpoints.

> * issue edit labels -r X fails with > text \> Error: the response from forgejo was not properly structured \> \> Caused by: \> invalid type: integer `404`, expected struct APINotFound at line 1 column 3 \> \> Location: \> src/main.rs:1008:9 \> > > even though the label does exist. Bug in forgejo_api? Not sure. Hm, I'm not able to reproduce that? > * There should probably also be a repo label edit, but I'm unsure of what the UI should look like. Perhaps something interactive with crate::editor? Feedback appreciated! > * There's already org label edit, but I think that's got a rather primitive UI. org label edit is in-line with how many other edit commands work, so I'd go with repo label edit being similar for now. I wouldn't be opposed to an interactive option too. Could open a yaml file in the editor? > * Maybe find some way to de-duplicate repo label with org label? That would be nice, but I'm not immediately sure how to do that given they hit different endpoints.

src/issues.rs Outdated

Show resolved Hide resolved

| | | | @ -493,6 +505,8 @@ pub async fn view_issue(repo: &RepoName, api: &Forgejo, id: i64) -> eyre::Result | | | | | | StateType::Closed => println!("{bright_red}Closed{reset}"), | | | | | | }; | | | | | | | | | | | | crate::render_label_list(&issue.labels.unwrap_or_default())?; |

Cyborus commented 2026-02-20 16:56:44 +01:00

Member

Copy link

I like this being here! pr view should probably get the same.

I like this being here! pr view should probably get the same.

LordMZTE commented 2026-02-21 15:45:07 +01:00

Author

Collaborator

Copy link

Do you think it makes sense to even keep pr view labels around then? It would now just show a subset of pr view body.

Do you think it makes sense to even keep pr view labels around then? It would now just show a subset of pr view body.

LordMZTE marked this conversation as resolved

src/main.rs Outdated

Show resolved Hide resolved

| | | | @ -870,0 +932,4 @@ | | | | | | ) | | | | | | } | | | | | | | | | | | | pub fn render_label_list(labels: &[forgejo_api::structs::Label]) -> eyre::Result<()> { |

Cyborus commented 2026-02-20 17:30:08 +01:00

Member

Copy link

This should get something like

rust
if labels.is_empty() {
    return Ok(());
}

because currently this always adds an extra newline to issue that don't have any labels.

Example:

This should get something like rust if labels.is_empty() { return Ok(()); } because currently this always adds an extra newline to issue that don't have any labels. Example:

[image.png](https://codeberg.org/attachments/8cf3c5ca-77be-4c6c-acdf-cd2f8eebe3b1 "Click to see "image.png" in a new tab")

9.3 KiB

LordMZTE marked this conversation as resolved

src/repo.rs Outdated

Show resolved Hide resolved

| | | | @ -446,1 +446,4 @@ | | | | | | }, | | | | | | | | | | | | /// Manage a repo's issue labels | | | | | | Label { |

Cyborus commented 2026-02-20 17:32:50 +01:00

Member

Copy link

I think Labels would be more fitting.

I think Labels would be more fitting.

LordMZTE commented 2026-02-20 18:50:03 +01:00

Author

Collaborator

Copy link

Good point! I think it does make sense to keep label as an alias, because in some cases such as label create it seems more natural.

Good point! I think it does make sense to keep label as an alias, because in some cases such as label create it seems more natural.

👍 1

LordMZTE marked this conversation as resolved

src/repo.rs Outdated

Show resolved Hide resolved

| | | | @ -1180,0 +1269,4 @@ | | | | | | for label in labels { | | | | | | let label_str = crate::render_label(&label)?; | | | | | | println!( | | | | | | "{} {label_str}{}\n {}", |

Cyborus commented 2026-02-20 17:13:16 +01:00

Member

Copy link

  • I don't feel the label ID is of much value to the end user

  • I find adding an extra newline between the labels makes it easier to read, compare:

    vs.

  • I don't feel the label ID is of much value to the end user - I find adding an extra newline between the labels makes it easier to read, compare: vs.

[image.png](https://codeberg.org/attachments/1b99f263-c27c-4033-bd64-5dfd83e5a12c "Click to see "image.png" in a new tab")

53 KiB

[image.png](https://codeberg.org/attachments/2ac03fb5-094d-4f14-9ea6-edf848703678 "Click to see "image.png" in a new tab")

49 KiB

LordMZTE commented 2026-02-20 18:48:05 +01:00

Author

Collaborator

Copy link

The main reason for including the ID here is that the user can use the ID to delete/edit a label with repo label edit later instead of having to type the whole label name. Thoughts?

The main reason for including the ID here is that the user can use the ID to delete/edit a label with repo label edit later instead of having to type the whole label name. Thoughts?

Cyborus commented 2026-02-20 19:29:10 +01:00

Member

Copy link

That makes sense. I'd suggest moving it after the label name, but I'm cool with keeping it then.

That makes sense. I'd suggest moving it after the label name, but I'm cool with keeping it then.

LordMZTE marked this conversation as resolved

src/repo.rs Outdated

Show resolved Hide resolved

| | | | @ -1180,0 +1271,4 @@ | | | | | | println!( | | | | | | "{} {label_str}{}\n {}", | | | | | | DisplayOptional(label.id, "?"), | | | | | | if label.is_archived.unwrap_or_default() { |

Cyborus commented 2026-02-20 17:13:37 +01:00

Member

Copy link

Archived labels could be hidden behind a --include-archived flag, I would imagine they don't need to be shown by default.

Archived labels could be hidden behind a --include-archived flag, I would imagine they don't need to be shown by default.

LordMZTE marked this conversation as resolved

src/repo.rs Outdated

Show resolved Hide resolved

| | | | @ -1180,0 +1321,4 @@ | | | | | | | | | | | | println!( | | | | | | "Successfully created label with ID {}.", | | | | | | DisplayOptional(id, "?") |

Cyborus commented 2026-02-20 17:39:34 +01:00

Member

Copy link

I think render_label would look better here.

I think render_label would look better here.

LordMZTE marked this conversation as resolved

src/repo.rs Outdated

Show resolved Hide resolved

| | | | @ -1180,0 +1344,4 @@ | | | | | | api.issue_delete_label(repo.owner(), repo.name(), id) | | | | | | .await?; | | | | | | | | | | | | println!("Successfully deleted label with ID {id}."); |

Cyborus commented 2026-02-20 17:42:48 +01:00

Member

Copy link

Same here

Same here

LordMZTE commented 2026-02-21 16:04:53 +01:00

Author

Collaborator

Copy link

We don't have the label available here without sending an extra request. Do you think that'd be worth it?

We don't have the label available here without sending an extra request. Do you think that'd be worth it?

Cyborus commented 2026-02-21 16:28:58 +01:00

Member

Copy link

Ohh, I hadn't realized that. In that case maybe can repeat back what the user entered? Possibly the ID, possibly the name.

Ohh, I hadn't realized that. In that case maybe can repeat back what the user entered? Possibly the ID, possibly the name.

LordMZTE marked this conversation as resolved

Cyborus added this to the v0.5.0 milestone 2026-02-20 18:17:13 +01:00

LordMZTE commented 2026-02-20 18:54:44 +01:00

Author

Collaborator

Copy link

Hm, I'm not able to reproduce that?

It might be because I tested on a private repo (on my instance). Maybe some authentication headers are missing? I wouldn't know why, though, since adding labels on the same repo and issue worked. Maybe it's also some API difference due to a different Forgejo version. Would you mind giving it a go on my server, since you already have an account there?

> Hm, I'm not able to reproduce that? It might be because I tested on a private repo (on my instance). Maybe some authentication headers are missing? I wouldn't know why, though, since adding labels on the same repo and issue worked. Maybe it's also some API difference due to a different Forgejo version. Would you mind giving it a go on my server, since you already have an account there?

Cyborus commented 2026-02-20 20:19:06 +01:00

Member

Copy link

Still not able to reproduce, even on your instance with the repo set to private

Still not able to reproduce, even on your instance with the repo set to private

LordMZTE requested review from Cyborus 2026-02-21 17:21:26 +01:00

LordMZTE force-pushed labels from 21daa37961

All checks were successful

ci/woodpecker/pr/check Pipeline was successful

Details

to 76b5ea732a

All checks were successful

ci/woodpecker/pr/check Pipeline was successful

Details

2026-02-22 09:29:30 +01:00 Compare

tobiasbrennecke commented 2026-02-23 20:47:33 +01:00

First-time contributor

Copy link

I really would love to see this merged!

I really would love to see this merged!

Cyborus approved these changes 2026-02-24 23:17:55 +01:00

Cyborus left a comment

Copy link

Looks great! Feel free to merge.

Looks great! Feel free to merge.

LordMZTE merged commit f0862bb0d4 into main 2026-02-25 14:48:58 +01:00

LordMZTE referenced this pull request from a commit 2026-02-25 14:48:58 +01:00 Merge pull request 'Repo & Issue labels' (#334) from LordMZTE/forgejo-cli:labels into main

LordMZTE deleted branch labels 2026-02-25 14:48:59 +01:00

stalecontext referenced this pull request from stalecontext/forgejo-cli-plus 2026-03-30 22:06:38 +02:00 Add --label flag to issue create and pr create #36

LordMZTE referenced this pull request 2026-05-05 08:22:06 +02:00 Error message when adding a label to an issue #451

stalecontext referenced this pull request from stalecontext/forgejo-cli-plus 2026-07-02 23:41:22 +02:00 Feature batch: milestone edit, --label, auth status, release --attach, --body-file, actions watch #53

Sign in to join this conversation.

Reviewers

No reviewers

Cyborus

Labels

Clear labels[ Kind/Breaking Breaking change that won't be backward compatible

](#)[ Kind/Bug Something is not working

](#)[ Kind/Design Discussion about UI/UX design

](#)[ Kind/Documentation Documentation changes

](#)[ Kind/Enhancement Improve existing functionality

](#)[ Kind/Feature New functionality

](#)[ Kind/Security This is security issue

](#)[ Kind/Testing Issue or pull request related to testing

](#)[ Kind/Upstream This is an issue with upstream software (Forgejo) that is probably not our fault

](#)

[ Priority

Critical The priority is critical

](#)[ Priority

High The priority is high

](#)[ Priority

Low The priority is low

](#)[ Priority

Medium The priority is medium

](#)

[ Reviewed

Confirmed Issue has been confirmed

](#)[ Reviewed

Duplicate This issue or pull request already exists

](#)[ Reviewed

Invalid Invalid issue

](#)[ Reviewed

Won't Fix This issue won't be fixed

](#)

[ Status

Abandoned Somebody has started to work on this but abandoned work

](#)[ Status

Blocked Something is blocking this issue or pull request

](#)[ Status

Need More Info Feedback is required to reproduce issue or to continue work

](#)

[ Suspicious

](#)

No labels Kind/Breaking Kind/Bug Kind/Design Kind/Documentation Kind/Enhancement Kind/Feature Kind/Security Kind/Testing Kind/Upstream [ Priority

Critical ](/forgejo-contrib/forgejo-cli/pulls?labels=173012) [ Priority

High ](/forgejo-contrib/forgejo-cli/pulls?labels=173013) [ Priority

Low ](/forgejo-contrib/forgejo-cli/pulls?labels=173015) [ Priority

Medium ](/forgejo-contrib/forgejo-cli/pulls?labels=173014) [ Reviewed

Confirmed ](/forgejo-contrib/forgejo-cli/pulls?labels=173007) [ Reviewed

Duplicate ](/forgejo-contrib/forgejo-cli/pulls?labels=173005) [ Reviewed

Invalid ](/forgejo-contrib/forgejo-cli/pulls?labels=173006) [ Reviewed

Won't Fix ](/forgejo-contrib/forgejo-cli/pulls?labels=173008) [ Status

Abandoned ](/forgejo-contrib/forgejo-cli/pulls?labels=173011) [ Status

Blocked ](/forgejo-contrib/forgejo-cli/pulls?labels=173010) [ Status

Need More Info ](/forgejo-contrib/forgejo-cli/pulls?labels=173009) Suspicious

Milestone

Clear milestone

No items

No milestone v0.5.0

Projects

Clear projects

No items

No project

Assignees

Clear assignees

No assignees

3 participants

Notifications Subscribe

Due date

The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference

forgejo-contrib/forgejo-cli!334

WritePreview

Loading…

Add table

| Rows | | | Columns | |

CancelOK

Add a link

Url Description Hint: With a URL in your clipboard, you can paste directly into the editor to create a link.

CancelOK

CancelSave

Reference in a new issue

Repository

forgejo-contrib/forgejo-cli

Title

Body

Create issue

No description provided.

Delete branch "LordMZTE/forgejo-cli:labels"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?

No Yes