Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/util/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package util
import (
"fmt"
"net/url"
"strings"

"github.com/go-git/go-git/v5"
)
Expand All @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions internal/util/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down