Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remotes regex doesn't match github URLs without username #107

Closed
beahues opened this issue Jun 28, 2023 · 3 comments
Closed

remotes regex doesn't match github URLs without username #107

beahues opened this issue Jun 28, 2023 · 3 comments

Comments

@beahues
Copy link
Contributor

beahues commented Jun 28, 2023

Describe the bug

When running against local SSH repos the regex at

r := regexp.MustCompile(`^(.+?)\s+.+(?:@|//)(.+?)(?::|/)(.+?/.+?)(?:\.git|)\s+.+$`)
doesn't match my remotes that do not start with 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\tgitpro.ttaallkk.top:mycompany/repo (fetch)\norigin\tgitpro.ttaallkk.top: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\tgitpro.ttaallkk.top:mycompany/repo.git (fetch)\norigin\tgitpro.ttaallkk.top: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
@seachicken
Copy link
Owner

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 🙂

@beahues
Copy link
Contributor Author

beahues commented Jul 3, 2023

Made #108 which passes tests at the very least 😸

@seachicken
Copy link
Owner

I just released v0.9.4! Please run gh ext upgrade poi.

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

No branches or pull requests

2 participants