fix(git): avoid misclassifying GitLab repository URLs - #4002
Conversation
Signed-off-by: Elvand-Lie <elvandlie@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Elvand-Lie The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @Elvand-Lie. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Changes
Fix automatic Git provider detection so repository path text cannot be mistaken for the provider hostname.
Previously,
GitProviderNamesearched the complete repository URL withstrings.Contains. Because GitHub was checked first, a valid GitLab URL such ashttps://gitlab.com/foo/github-actionscould incorrectly be classified as GitHub.Provider detection now parses normal transport and SCP-style Git URLs using the repository's existing
github.com/chainguard-dev/git-urlsdependency, considers only the parsed hostname, and compares provider names as complete, case-insensitive hostname labels.This preserves GitHub and GitLab detection while preventing repository paths, user information, and partial hostname labels from influencing the result. For example:
Validation completed with Go 1.26.5 in the official
golang:1.26Linux/ARM64 container:go test ./pkg/gitgo vet ./pkg/gitgo test ./cmd/... ./pkg/git/...gofmt -dgit diff --checkmake check-whitespace check-eofNo dependency was added;
github.com/chainguard-dev/git-urlswas already used by the repository./kind bug
Release Note
Docs