Métriques du dépôt
- Stars
- (44 396 étoiles)
- Métriques de merge PR
- (Métriques PR en attente)
Description
Describe the bug
Minimum short hash is 7 hexadecimal characters which includes the possibility of all 7 being decimal. gh browse seems to assume such a short hash to be an issue number and generates the issue URL.
This of course seems fine when I obtain the long hash but makes a mostly-ok workflow buggy - would be better if gh browse could validate the argument either against the repo hashes or repo issues. The chances then for a conflict still exist if a repo had 10 million issues and likely by that time said repo would probably require more than 7 hexdigits for uniqueness.
Affected version
gh version 2.83.2 (2025-12-10)
https://github.com/cli/cli/releases/tag/v2.83.2
(also observed in 2.78.0)
Steps to reproduce the behavior
While I encountered this in an org-private repo I'm reproducing here with this repo
-
Clone
$ git clone https://github.com/cli/cli /tmp/gh-cli Cloning into '/tmp/gh-cli'... remote: Enumerating objects: 78667, done. remote: Counting objects: 100% (271/271), done. remote: Compressing objects: 100% (159/159), done. remote: Total 78667 (delta 208), reused 114 (delta 112), pack-reused 78396 (from 2) Receiving objects: 100% (78667/78667), 49.48 MiB | 31.78 MiB/s, done. Resolving deltas: 100% (53968/53968), done. $ cd /tmp/gh-cli -
Find decimal-only shorthash (after observing that in this repo the short-hash is 9 characters long)
$ git log --pretty=oneline --abbrev-commit | grep -E '^[[:digit:]]{9}'|head -1 309628980 chore: update licenses -
Type
gh browse -nwith above short hash as the arg -
Observe the URL emitted is a an issue, not a commit URL
$ gh browse -n 309628980 https://github.com/cli/cli/issues/309628980 -
(Optional) repeat without the
-nand observe the 404 page$ gh browse 309628980 Opening https://github.com/cli/cli/issues/309628980 in your browser. ...
Expected vs actual behavior
Expected the short-hash to be recognized as such even if it was comprised solely from decimal characters.
Actual gh browse generated an issue URL.
Logs
$ GH_DEBUG=true gh browse -n 309628980
[git remote -v]
[git config --get-regexp ^remote\..*\.gh-resolved$]
* Request at 2025-12-22 11:54:29.753867646 -0500 EST m=+0.078613018
* Request to https://api.github.com/graphql
* Request took 423.216942ms
* Request at 2025-12-22 11:54:30.178987073 -0500 EST m=+0.503732500
* Request to https://api.github.com/repos/cli/cli
* Request took 235.40005ms
https://github.com/cli/cli/issues/309628980