Skip to content

Commit aa7e17d

Browse files
fix: repository url computation (#27)
1 parent 399e577 commit aa7e17d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

internal/util/repository.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package util
1919
import (
2020
"fmt"
2121
"net/url"
22+
"strings"
2223

2324
"github.com/go-git/go-git/v5"
2425
)
@@ -42,6 +43,8 @@ func GetRepositoryUrl(path string) (string, error) {
4243
repoUrl := remote.Config().URLs[0]
4344
repoUrl, err = sanitiseCredentials(repoUrl)
4445

46+
// we need to return an actual URL, not the SSH
47+
repoUrl = strings.Replace(repoUrl, "[email protected]:", "https://github.com/", 1)
4548
return repoUrl, err
4649
}
4750

internal/util/repository_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ func Test_GetRepositoryUrl_repo_with_credentials(t *testing.T) {
6363

6464
func Test_GetRepositoryUrl_repo_without_credentials(t *testing.T) {
6565
// check out a repo and prepare its config to contain credentials in the URL
66-
expectedRepoUrl := "git@github.com:snyk-fixtures/shallow-goof-locked.git"
67-
repoDir, _ := clone(t, expectedRepoUrl)
66+
expectedRepoUrl := "https://github.com/snyk-fixtures/shallow-goof-locked.git"
67+
repoDir, _ := clone(t, "[email protected]:snyk-fixtures/shallow-goof-locked.git")
6868

6969
// run method under test
7070
actualUrl, err := util.GetRepositoryUrl(repoDir)

0 commit comments

Comments
 (0)