remotes regex doesn't match github URLs without username
beahues opened this issue · 3 comments
Describe the bug
When running against local SSH repos the regex at
Line 153 in fdbd0f3
git@
:
~/repos/repo > git remote set-url origin github.com:mycompany/repo
~/repos/repo > gh poi --debug
2023/06/28 10:47:54 [46.767667ms] run git [remote -v] -> "origin\tgithub.com:mycompany/repo (fetch)\norigin\tgithub.com:mycompany/repo (push)\n"
not found
~/repos/repo > git remote set-url origin github.com:mycompany/repo.git
~/repos/repo > gh poi --debug
2023/06/28 10:47:59 [54.521291ms] run git [remote -v] -> "origin\tgithub.com:mycompany/repo.git (fetch)\norigin\tgithub.com:mycompany/repo.git (push)\n"
not found
~/repos/repo > git remote set-url origin git@github.com:mycompany/repo
~/repos/repo > gh poi --debug
2023/06/28 10:48:05 [57.775833ms] run git [remote -v] -> "origin\tgit@github.com:mycompany/repo (fetch)\norigin\tgit@github.com:mycompany/repo (push)\n"
2023/06/28 10:48:05 [18.830916ms] run ssh [-T -G github.com] -> *****
Testing that with the golang regex at https://regex101.com/r/6FqUBq/1 confirms this.
(I realise this is a simple fix my end, set the remote with the git@
in it)
Changing the regex to
^(.+?)\s+(?:\w+@|//)?([a-zA-Z][a-zA-Z0-9-]+\.[a-zA-Z][a-zA-Z0-9-]+?)(?::|/)(.+?/.+?)(?:\.git|)\s+.+$
appears to work for me, and passes tests, but it feels a very much "works for me" fix.
I can happily make beahues@c27e548 in to a PR though?
Your Environment
- OS:
System Version: macOS 13.4.1 (22F82)
Kernel Version: Darwin 22.5.0
> git --version
git version 2.41.0
- gh (Check with
gh --version
):
gh version 2.16.1 (2022-09-26)
https://github.com/cli/cli/releases/tag/v2.16.1
- gh-poi
gh poi seachicken/gh-poi v0.9.3
Thanks for reporting!
We need to modify it so that it works even if the username is missing.
Your regex doesn't support https. (e.g. origin https://github.com/mycompany/repo (fetch)
)
https://regex101.com/r/JwGy8O/1
Feel free to open a PR 🙂
I just released v0.9.4! Please run gh ext upgrade poi
.