snitch icon indicating copy to clipboard operation
snitch copied to clipboard

Repo detection breaks on repositories on GitLab's subgroups

Open miko007 opened this issue 2 years ago • 0 comments

Tasks

  • [ ] update regex, so it covers nested namespaces
  • [ ] update following code to assemble the reported repo URL correctly

Description

On an GitLab instance, it is possible to have nested groups of arbitrary depth. The regex on line 269 in main.go does not cover this case:

s := creds.getHost() + "[:/]([-\\.\\w]+)\\/([-\\.\\w]+)"

This regex does not match on an repository URL in the format of:
[email protected]:organisation/subgroup/subsubgroup/repository.git.

snitch will discover the repository at organisation/subgroup.

This is addressed by #176, but the human that proposed that pull request seems not to be further interested in getting it merged, as @rexim's request for change in form of unit tests has been ignored for almost three years now.

Steps to reproduce

  1. make sure you have credentials for gitlab.com in your .config/snitch/gitlab.ini
  2. run git clone https://gitlab.com/mikotests/tsoding/golang/snitch.git
  3. go inside the folder of the repository (cd snitch)
  4. run snitch report in the folder of the cloned repository

Result: Detected project: https://gitlab.com/mikotests/tsoding

(for review and notice: @rexim)

miko007 avatar Mar 29 '23 12:03 miko007