Skip to content

Commit

Permalink
Merge pull request #1009 from pascalbreuninger/fix/at-symbol-in-sourc…
Browse files Browse the repository at this point in the history
…e-repo

fix(cli): allow @ symbol in git https host string
  • Loading branch information
89luca89 authored Apr 17, 2024
2 parents 3f7e9db + 60b2505 commit 09beb31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ const (
)

var (
branchRegEx = regexp.MustCompile(`^([^@]*(?:git@)?[^@/]+/[^@/]+/?[^@/]+)@([a-zA-Z0-9\./\-\_]+)$`)
commitRegEx = regexp.MustCompile(`^([^@]*(?:git@)?[^@/]+/[^@]+)` + regexp.QuoteMeta(CommitDelimiter) + `([a-zA-Z0-9]+)$`)
prReferenceRegEx = regexp.MustCompile(`^([^@]*(?:git@)?[^@/]+/[^@]+)@(` + PullRequestReference + `)$`)
subPathRegEx = regexp.MustCompile(`^([^@]*(?:git@)?[^@/]+/[^@]+)` + regexp.QuoteMeta(SubPathDelimiter) + `([a-zA-Z0-9\./\-\_]+)$`)
branchRegEx = regexp.MustCompile(`^([^@]*(?:git@)?@?[^@/]+/[^@/]+/?[^@/]+)@([a-zA-Z0-9\./\-\_]+)$`)
commitRegEx = regexp.MustCompile(`^([^@]*(?:git@)?@?[^@/]+/[^@]+)` + regexp.QuoteMeta(CommitDelimiter) + `([a-zA-Z0-9]+)$`)
prReferenceRegEx = regexp.MustCompile(`^([^@]*(?:git@)?@?[^@/]+/[^@]+)@(` + PullRequestReference + `)$`)
subPathRegEx = regexp.MustCompile(`^([^@]*(?:git@)?@?[^@/]+/[^@]+)` + regexp.QuoteMeta(SubPathDelimiter) + `([a-zA-Z0-9\./\-\_]+)$`)
)

func CommandContext(ctx context.Context, args ...string) *exec.Cmd {
Expand Down
8 changes: 8 additions & 0 deletions pkg/git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ func TestNormalizeRepository(t *testing.T) {
expectedCommit: "",
expectedSubpath: "/test/path",
},
{
in: "https://[email protected]/loft-sh/devpod.git@test-branch",
expectedRepo: "https://[email protected]/loft-sh/devpod.git",
expectedPRReference: "",
expectedBranch: "test-branch",
expectedCommit: "",
expectedSubpath: "",
},
}

for _, testCase := range testCases {
Expand Down

0 comments on commit 09beb31

Please sign in to comment.