Removed unused `ToHttpsUrl` method and corresponding library (#1017)

## Changes
Removed unused ToHttpsUrl method and corresponding library
This commit is contained in:
Andrew Nester 2023-11-28 17:08:27 +01:00 committed by GitHub
parent 1932da0a87
commit b5f34a1181
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 53 deletions

1
go.mod
View File

@ -21,7 +21,6 @@ require (
github.com/spf13/cobra v1.8.0 // Apache 2.0
github.com/spf13/pflag v1.0.5 // BSD-3-Clause
github.com/stretchr/testify v1.8.4 // MIT
github.com/whilp/git-urls v1.0.0 // MIT
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
golang.org/x/mod v0.14.0
golang.org/x/oauth2 v0.14.0

2
go.sum
View File

@ -149,8 +149,6 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/whilp/git-urls v1.0.0 h1:95f6UMWN5FKW71ECsXRUd3FVYiXdrE7aX4NZKcPmIjU=
github.com/whilp/git-urls v1.0.0/go.mod h1:J16SAmobsqc3Qcy98brfl5f5+e0clUvg1krgwk/qCfE=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=

View File

@ -1,28 +0,0 @@
package git
import (
"strings"
giturls "github.com/whilp/git-urls"
)
// Return an origin URL as an HTTPS URL.
// The transformations in this function are not guaranteed to work for all
// Git providers. They are only guaranteed to work for GitHub.
func ToHttpsUrl(url string) (string, error) {
origin, err := giturls.Parse(url)
if err != nil {
return "", err
}
// If this repository is checked out over SSH
if origin.Scheme != "https" {
origin.Scheme = "https"
}
// Basic auth is not applicable for an HTTPS URL.
if origin.User != nil {
origin.User = nil
}
// Remove `.git` suffix, if present.
origin.Path = strings.TrimSuffix(origin.Path, ".git")
return origin.String(), nil
}

View File

@ -1,22 +0,0 @@
package git
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestToHttpsUrlForSsh(t *testing.T) {
for _, e := range []struct {
url string
expected string
}{
{"user@foo.com:org/repo-name.git", "https://foo.com/org/repo-name"},
{"git@github.com:databricks/cli.git", "https://github.com/databricks/cli"},
{"https://github.com/databricks/cli.git", "https://github.com/databricks/cli"},
} {
url, err := ToHttpsUrl(e.url)
assert.NoError(t, err)
assert.Equal(t, e.expected, url)
}
}