diff --git a/CHANGELOG.md b/CHANGELOG.md index bc6a402..35f1879 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### Other * Internal: splits up the `Processor` mega-struct (#218, #219) -* Command `init` supports remote repos cloned with SSL (#221) +* Command `init` supports remote repos cloned with SSL (#221, #223) ## [[v0.11.0]](https://github.com/mlange-42/modo/compare/v0.10.1...v0.11.0) diff --git a/internal/document/util.go b/internal/document/util.go index 49232a7..6a03211 100644 --- a/internal/document/util.go +++ b/internal/document/util.go @@ -170,7 +170,7 @@ func GetGitOrigin(outDir string) (*GitInfo, error) { if !ok { fmt.Printf("WARNING: No Git repository or no remote 'origin' found.\n Using dummy %s\n", url) } - url, err := getRepoUrl(url) + url, err := getRepoURL(url) if err != nil { url = "https://github.com/your/package" fmt.Printf("WARNING: Git remote 'origin' could not be parsed.\n Using dummy %s\n", url) @@ -188,7 +188,8 @@ func GetGitOrigin(outDir string) (*GitInfo, error) { }, nil } -func getRepoUrl(url string) (string, error) { +func getRepoURL(url string) (string, error) { + url = strings.TrimSuffix(url, "/") if strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") { return strings.TrimSuffix(url, ".git"), nil } diff --git a/internal/document/util_test.go b/internal/document/util_test.go index 1a82c65..727373f 100644 --- a/internal/document/util_test.go +++ b/internal/document/util_test.go @@ -50,11 +50,15 @@ func TestGetGitOrigin(t *testing.T) { } func TestGetRepoUrl(t *testing.T) { - url, err := getRepoUrl("https://github.com/mlange-42/modo.git") + url, err := getRepoURL("https://github.com/mlange-42/modo.git") assert.Nil(t, err) assert.Equal(t, "https://github.com/mlange-42/modo", url) - url, err = getRepoUrl("git@github.com:mlange-42/modo") + url, err = getRepoURL("https://github.com/mlange-42/modo.git/") + assert.Nil(t, err) + assert.Equal(t, "https://github.com/mlange-42/modo", url) + + url, err = getRepoURL("git@github.com:mlange-42/modo") assert.Nil(t, err) assert.Equal(t, "https://github.com/mlange-42/modo", url) }