Closed Parkreiner closed 4 months ago
This reminds me of the work we are doing on the Coder git-clone module, we have to parse git URLs there as well.
My idea was to have a set of matchers we can use for figuring out the base repository URL and branch, so it could look something like this:
github = [ "{owner}/{repo}/tree/{branch}" "{owner}/{repo}/blob/{branch}" ]
gitlab = [ "{owner}/{repo}/-/tree/{branch}" "{owner}/{repo}/-/blob/{branch}" ]
bitbucket = [
"{owner}/{repo}/src/{ignore}?at={branch}"
"{owner}/{repo}/src/{branch}"
]
Each matcher is tried in order, this syntax is inspired by go-chi but we could do :var
if we wanted it Express-like. Or we could just directly write them as regular expressions.
Or we use something like https://github.com/IonicaBizau/git-url-parse
Issue comes from a user at a prospective company.
Problem
Likely issue
target
field in theLocationSpec
value includes additional paths at the end that make the URL not valid. The URL becomes valid when those additional pieces are removedOther notes
Brandon provided a sample catalog-info file that isn't working (though he obviously can't share the full repo):
The culprit might be the fact that the
backstage.io/source-location
property has a value ofurl:https://my.gitlab.com/devexportal/sandbox/myreactapp/-/blob/main/
, and that the/~/blob/main/
at the end shouldn't be there?We aren't working with this property directly, but it might be shared with the APIs we are using