italia/publiccode-parser-go

Gitlab sometime adds a dash in raw url

Closed this issue · 4 comments

On Gitlab platform trying to get raw file for publiccode.yml sometimes a /- is added before filename, see example below:

https://gitlab.com/org/repo/-/raw/master/publiccode.yml

instead of:

https://gitlab.com/org/repo/raw/master/publiccode.yml

This will cause a validation fail:

validation ko:
url: declared url (https://gitlab.com/org/repo) does not match the actual 
publiccode.yml source URL (https://gitlab.com/org/repo/-/raw/master/)

Here regex used to do that match
https://github.com/alranel/go-vcsurl/blob/master/vcsurl.go#L217

GitLab has started moving routes under the - scope around 12.0.
https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/config/routes/project.rb#L26
https://gitlab.com/gitlab-org/gitlab/-/issues/28848

Paths with no - are considered legacy and can be found on older versions (older than a year, which for GitLab's standards is quite a long time). The hosted version at gitlab.com uses the new paths, of course.

Yes, considering we support also self-hosted instances we should be compatible for both versions.

This should be solved by alranel/go-vcsurl#4, @sebbalex what was the original command line triggering the bug?

Confimed solved.