feat: add and filter issue labels by name #13

Open
krishsax wants to merge 1 commit from krishsax/issue-labels into main AGit
Member

Summary

Collar could show issue labels but not set them. This adds label names to the issue commands:

collar issue list --label type/bug --label urgency/high
collar issue create --title 'Preview times out' --label type/bug
collar issue edit 54 --add-label stage/in-progress --remove-label stage/todo
  • Names resolve against repository labels, then organization labels. ScottyLabs repositories mostly use organization labels (type/*, urgency/*, needs/*), so repository-only resolution would miss them. A 404 from orgs/{owner}/labels means a user-owned repository and is treated as having no organization labels; other errors propagate.
  • Unknown names fail with the available names before any issue is listed or changed. This matters for issue list: Forgejo silently discards unknown names in its labels filter, so a typo would list every issue. Names containing commas are rejected for the filter, since the API takes a comma-separated list. Repeated --label requires every label, which matches Forgejo's behavior (checked with live reads on kennel).
  • issue create sends label IDs in the create request, so creation stays a single write.
  • issue edit computes the new label set from the issue it already fetches and replaces it with one PUT .../labels. It sends nothing when the set is unchanged, and rejects a label that is both added and removed before any request. With --title/--body, the PATCH runs first; if the label request then fails, the error states that the title or body was updated and the labels were not. Nothing is retried.
  • client::HttpStatus is a small typed error so callers can recognize one status code. Error messages are unchanged.

Docs: a "Label issues" section in the repository guide, new issue help examples, and a regenerated command reference. The guide notes that labels do not move project board cards, since Forgejo 17 has no projects API.

Validation

  • cargo clippy --all-targets -- -D warnings and treefmt pass.
  • New fixture tests cover organization label resolution for create, filter validation and encoding for list, unknown names and commas failing before requests, a single PUT with the merged set for edit, no write for an unchanged set, and the partial-write error.
  • Live read-only checks on git.cmu.dev: issue list -R kennel --state all --label type/feature --label urgency/high returns the same four issues as the raw API, and --label type/featur fails with the available names. Writes were tested only against fixtures.
  • On macOS the cli test binary aborts on any test that panics (also on main), so the cargo-test hook was skipped for this commit. Running each test in its own process: 147 of 149 pass. The two failures are existing environment tests that compare /var with /private/var temp paths.
## Summary Collar could show issue labels but not set them. This adds label names to the issue commands: ```sh collar issue list --label type/bug --label urgency/high collar issue create --title 'Preview times out' --label type/bug collar issue edit 54 --add-label stage/in-progress --remove-label stage/todo ``` - Names resolve against repository labels, then organization labels. ScottyLabs repositories mostly use organization labels (`type/*`, `urgency/*`, `needs/*`), so repository-only resolution would miss them. A 404 from `orgs/{owner}/labels` means a user-owned repository and is treated as having no organization labels; other errors propagate. - Unknown names fail with the available names before any issue is listed or changed. This matters for `issue list`: Forgejo silently discards unknown names in its `labels` filter, so a typo would list every issue. Names containing commas are rejected for the filter, since the API takes a comma-separated list. Repeated `--label` requires every label, which matches Forgejo's behavior (checked with live reads on kennel). - `issue create` sends label IDs in the create request, so creation stays a single write. - `issue edit` computes the new label set from the issue it already fetches and replaces it with one `PUT .../labels`. It sends nothing when the set is unchanged, and rejects a label that is both added and removed before any request. With `--title`/`--body`, the PATCH runs first; if the label request then fails, the error states that the title or body was updated and the labels were not. Nothing is retried. - `client::HttpStatus` is a small typed error so callers can recognize one status code. Error messages are unchanged. Docs: a "Label issues" section in the repository guide, new `issue` help examples, and a regenerated command reference. The guide notes that labels do not move project board cards, since Forgejo 17 has no projects API. ## Validation - `cargo clippy --all-targets -- -D warnings` and `treefmt` pass. - New fixture tests cover organization label resolution for `create`, filter validation and encoding for `list`, unknown names and commas failing before requests, a single `PUT` with the merged set for `edit`, no write for an unchanged set, and the partial-write error. - Live read-only checks on git.cmu.dev: `issue list -R kennel --state all --label type/feature --label urgency/high` returns the same four issues as the raw API, and `--label type/featur` fails with the available names. Writes were tested only against fixtures. - On macOS the `cli` test binary aborts on any test that panics (also on `main`), so the `cargo-test` hook was skipped for this commit. Running each test in its own process: 147 of 149 pass. The two failures are existing `environment` tests that compare `/var` with `/private/var` temp paths.
feat: add and filter issue labels by name
All checks were successful
nixbot/nix-eval evaluation succeeded in 11s (1 warning)
CI / checks-1 (pull_request) Successful in 17s
CI / checks (pull_request) Successful in 0s
kennel/deploy deployment healthy
nixbot/nix-build 5 attributes built
b79b01bbcc
Owner

Kennel Deployments

Service URL
docs https://collar-docs-pr-13.scottylabs.net

Last updated for commit b79b01b.

<!-- kennel-deployment --> ### Kennel Deployments | Service | URL | | --- | --- | | docs | https://collar-docs-pr-13.scottylabs.net | Last updated for commit `b79b01b`.
All checks were successful
nixbot/nix-eval evaluation succeeded in 11s (1 warning)
Required
Details
CI / checks-1 (pull_request) Successful in 17s
Required
Details
CI / checks (pull_request) Successful in 0s
Required
Details
kennel/deploy deployment healthy
Required
nixbot/nix-build 5 attributes built
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/13/head:krishsax/issue-labels'
git switch 'krishsax/issue-labels'
Sign in to join this conversation.
No description provided.