Skip to content

Add a bunch of aliases to align with gh#91

Merged
andrew merged 6 commits into
git-pkgs:mainfrom
untitaker:gh-aliases
May 22, 2026
Merged

Add a bunch of aliases to align with gh#91
andrew merged 6 commits into
git-pkgs:mainfrom
untitaker:gh-aliases

Conversation

@untitaker
Copy link
Copy Markdown
Contributor

@untitaker untitaker commented May 21, 2026

  • Fix Aligning with GitHub CLI? #86
  • Add a few more command aliases (ls/list, new/create)
  • Add --web flag to open in browser
  • Add --force flag to upsert labels

Those were all things that I either 1) depend on in my wrapper scripts in my dotfiles 2) extracted from failed tool calls in my claude history.

Let me know if you want me to split that up, but I think the changes are simple enough and splitting them up, then merging them back together causes merge conflicts.

untitaker and others added 3 commits May 21, 2026 15:33
Aligns with gh CLI which supports:
- gh pr ls / gh issue ls / gh label ls
- gh pr new / gh issue new

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Opens the resource in the browser instead of displaying it in the
terminal. Aligns with gh CLI behavior.

Supported commands:
- forge pr view --web
- forge pr list --web
- forge issue view --web
- forge issue list --web
- forge label list --web

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When --force is set and the label already exists, update it instead of
failing. Aligns with gh CLI behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@andrew andrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, the gh-compat direction is very welcome. A few things before merging:

Blocking

--web URLs are GitHub-only (internal/cli/pr.go, internal/cli/issue.go)

pr view --web builds https://{domain}/{owner}/{repo}/pull/{N}. That path is wrong for every non-GitHub forge we support: Gitea/Forgejo use /pulls/{N}, GitLab uses /-/merge_requests/{N}, Bitbucket uses /pull-requests/{N}.

The fix is right there though: three lines below, the code already fetches the PR, which has pr.HTMLURL populated by each backend. Move the flagWeb check after the Get() call and open pr.HTMLURL instead. Same for issue view --web with issue.HTMLURL.

pr list --web and label list --web have the same problem but no object to read from. browse.go already hardcodes /pulls so this is at least consistent with an existing bug; happy to accept it for now and push URL construction into the Forge interface in a follow-up.

Should fix

--labels alias registration

Binding a second StringSliceVar to the same &flagLabels has two side effects:

  • Both --label and --labels show in --help with identical descriptions
  • --label foo --labels bar yields ["bar"], not ["foo","bar"], because each pflag slice value tracks its own changed bit and resets on first Set

Cleaner would be a SetNormalizeFunc that rewrites labels to label, or at minimum cmd.Flags().MarkHidden("labels") after registering it.

Notes (no change needed)

  • repoFromFlag now rejects 4+ segments. GitLab subgroups (gitlab.com/group/sub/project) hit this, but the old LastIndex code parsed them wrong anyway and gh itself only does 3 parts, so not a regression. The explicit error is an improvement.
  • isLabelExistsError string-matching is brittle (a forge with different wording falls through) but there's no typed error to check and the failure mode is just "didn't upsert", so acceptable.
  • --force with neither --color nor --description sends an empty update; that's a no-op on most forges and matches gh label create --force.
  • --forge-type is silently ignored when --repo includes a host segment. Probably correct (explicit host wins), just flagging.

The repoFromFlag tests look good and stay hermetic since codeberg.org is in the pre-registered map.

@untitaker
Copy link
Copy Markdown
Contributor Author

--web URLs are GitHub-only (internal/cli/pr.go, internal/cli/issue.go)

Thanks. forge browse had the same issue, so I fixed it there too. URL builder is now within each forge impl. It's a bit more than asked for but I do think it's cleaner.

Addressed the rest too.

@untitaker
Copy link
Copy Markdown
Contributor Author

untitaker commented May 22, 2026

isLabelExistsError string-matching is brittle (a forge with different wording falls through) but there's no typed error to check and the failure mode is just "didn't upsert", so acceptable.

Fixed. I eyeballed the status codes for bitbucket/gitlab tbh and didn't test them, but tbf I didn't test the error message pattern matching on those forges either.

@andrew
Copy link
Copy Markdown
Contributor

andrew commented May 22, 2026

No problem, I appreciate the eyeballs!

@andrew andrew merged commit 0dfc81c into git-pkgs:main May 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aligning with GitHub CLI?

2 participants