devpod
devpod copied to clipboard
Check if URL contains basic auth in URL
Fixes https://github.com/loft-sh/devpod/issues/1515 by checking if the URL contains basic auth (detected from the presence of : in the first part of the URL). The URL is then parsed again in case both basic auth AND a branch were specified.
If there is a fancier way of doing this with regex let me know :)
My test below shows the original problem with the URL parsed, then building my changes and testing the same URL and again with a branch (note the lines with URL: and Branch:)
➜ devpod git:(main) devpod up https://gitlab-ci-token:[email protected]/my-group/my-repo.git
10:16:13 info Creating devcontainer...
10:16:14 info Clone repository
10:16:14 info URL: https://gitlab-ci-token:my-token-here
10:16:14 info Branch: gitlab.com/my-group/my-repo.git
...
➜ devpod git:(main) CGO_ENABLED=0 go build -ldflags "-s -w" -o devpod-cli
➜ devpod git:(main) ✗ ./devpod-cli up https://gitlab-ci-token:[email protected]/my-group/my-repo.git
10:23:42 info Creating devcontainer...
10:23:43 info Delete old workspace 'gitlab-com-my-group-my-repo'
10:23:43 info Clone repository
10:23:43 info URL: https://gitlab-ci-token:[email protected]/my-group/my-repo.git
...
➜ devpod git:(main) ✗ ./devpod-cli up https://gitlab-ci-token:[email protected]/my-group/my-repo.git@branch
10:25:30 info Creating devcontainer...
10:25:30 info Delete old workspace 'my-repo-git-branch'
10:25:30 info Clone repository
10:25:30 info URL: https://gitlab-ci-token:[email protected]/my-group/my-repo.git
10:25:30 info Branch: branch
...