browse: check commit existence for ambiguous decimal-only short hashes#12943
browse: check commit existence for ambiguous decimal-only short hashes#12943mateenali66 wants to merge 4 commits intocli:trunkfrom
Conversation
Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
The previous comment said '7+ chars' but the length check is inside isCommit(), not at the call site. Reword to make it clear that isCommit() is what enforces both the hex constraint and the 7-64 char minimum. Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
|
Good catch on the comment — the '7+ chars' constraint is actually inside Updated the comment to make it self-explanatory: decimal digits 0–9 are valid hex, so an all-decimal string without a |
I deleted my comment as soon as I realized it was in the |
Fixes #12357
When a short commit hash is all decimal digits (e.g.
309628980),gh browsewas routing it to the issues URL instead of commit URL. This happens becauseisNumber()is checked beforeisCommit(), so any all-decimal string that is also valid hex gets treated as issue number.This PR calls the GitHub API to disambiguate when the arg passes both checks (all-decimal, 7+ chars, no
#prefix). If the API confirms the commit exists on the remote, it use the commit URL. If not, falls back to issue URL.The
#prefix still forces issue behavior as before.Closes #12357