fix(git): pick the forge from the remote host, not the whole URL - #1052
Conversation
There was a problem hiding this comment.
The direction is right: matching gitlab against the host instead of the whole URL fixes the repository-name false positive, and the tests cover the scp-like and non-default-port shapes.
One blocking issue in host_of: userinfo containing a password is parsed as the host, which regresses credentialed GitLab remotes. Inline suggestion attached.
SonarQube — aucune nouvelle issueComparaison entre le projet bac à sable de cette PR et la branche par défaut : SonarQube Community n'analyse pas les PR, ce delta est calculé côté CI. Détail |
|
Confirmed and fixed in 754f9e4. The trace is right:
Four cases added: two credentialed remotes, a credentialed remote with an explicit port, and the backslash shape. The gitlab and github lists in the two behaviour tests each gained a credentialed entry as well, so the classification is covered and not just the parser. |
754f9e4 to
34bb979
Compare
Closes #799.
token_for_urldecided the forge withurl.contains("gitlab")against the whole remote URL, so the owner and repository name got a vote.https://github.com/acme/gitlab-migration-tool.gittook the GitLab branch, looked forGITLAB_TOKEN, found none, and pushed with no credential at all whileGITHUB_TOKENsat unused.The match now runs against the host only, via a
host_ofhelper that handles the three remote shapes git accepts:https://,ssh://, and scp-stylegit@host:owner/repo. It strips a port and auser@prefix.Still a substring rather than an exact match, because a self-hosted GitLab is usually
gitlab.acme.comand the previous behaviour accepted that too.Verification
a_repository_name_does_not_pick_the_forgefails on the currentmainimplementation and passes here:a_gitlab_host_still_picks_gitlabcovers the four GitLab remote shapes so the fix cannot regress into never selecting GitLab, andhost_of_handles_the_remote_shapes_git_acceptspins the parser itself.Bottom of a stack of four independent git/release fixes. The layer above is #1053.