diff --git a/internal/util/repository.go b/internal/util/repository.go index c9dd90be..036cbada 100644 --- a/internal/util/repository.go +++ b/internal/util/repository.go @@ -19,6 +19,7 @@ package util import ( "fmt" "net/url" + "strings" "github.com/go-git/go-git/v5" ) @@ -42,6 +43,8 @@ func GetRepositoryUrl(path string) (string, error) { repoUrl := remote.Config().URLs[0] repoUrl, err = sanitiseCredentials(repoUrl) + // we need to return an actual URL, not the SSH + repoUrl = strings.Replace(repoUrl, "git@github.com:", "https://github.com/", 1) return repoUrl, err } diff --git a/internal/util/repository_test.go b/internal/util/repository_test.go index 9c48a3ff..c03fb063 100644 --- a/internal/util/repository_test.go +++ b/internal/util/repository_test.go @@ -63,8 +63,8 @@ func Test_GetRepositoryUrl_repo_with_credentials(t *testing.T) { func Test_GetRepositoryUrl_repo_without_credentials(t *testing.T) { // check out a repo and prepare its config to contain credentials in the URL - expectedRepoUrl := "git@github.com:snyk-fixtures/shallow-goof-locked.git" - repoDir, _ := clone(t, expectedRepoUrl) + expectedRepoUrl := "https://github.com/snyk-fixtures/shallow-goof-locked.git" + repoDir, _ := clone(t, "git@github.com:snyk-fixtures/shallow-goof-locked.git") // run method under test actualUrl, err := util.GetRepositoryUrl(repoDir)