Skip to content

Commit

Permalink
Remove manipulation of .git suffix, which is just a conventional part…
Browse files Browse the repository at this point in the history
… of the directory name
  • Loading branch information
KnVerey committed Jan 18, 2023
1 parent 0020839 commit 7cbe735
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 180 deletions.
32 changes: 1 addition & 31 deletions api/internal/git/repospec.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ type RepoSpec struct {
// Branch or tag reference.
Ref string

// e.g. .git or empty in case of _git is present
GitSuffix string

// Submodules indicates whether or not to clone git submodules.
Submodules bool

Expand All @@ -58,10 +55,7 @@ type RepoSpec struct {

// CloneSpec returns a string suitable for "git clone {spec}".
func (x *RepoSpec) CloneSpec() string {
if isAzureHost(x.Host) || isAWSHost(x.Host) {
return x.Host + x.RepoPath
}
return x.Host + x.RepoPath + x.GitSuffix
return x.Host + x.RepoPath
}

func (x *RepoSpec) CloneDir() filesys.ConfirmedDir {
Expand Down Expand Up @@ -124,17 +118,6 @@ func NewRepoSpecFromURL(n string) (*RepoSpec, error) {
return nil, err
}

// If the repo name ends in .git, isolate it. It will be added back by the clone spec function.
if idx := strings.Index(repoSpec.RepoPath, gitSuffix); idx >= 0 {
repoSpec.GitSuffix = gitSuffix
repoSpec.RepoPath = repoSpec.RepoPath[:idx]
}
// Force the .git suffix URLs for services whose clone URL is the repo URL + .git.
// This allows us to support the repo URL as an input instead of the actual clone URL.
if legacyAddGitSuffix(repoSpec.Host, repoSpec.RepoPath) {
repoSpec.GitSuffix = gitSuffix
}

return repoSpec, nil
}

Expand Down Expand Up @@ -410,16 +393,3 @@ func normalizeGithubHostParts(scheme, username string) (string, string, string)
}
return httpsScheme, "", "github.com/"
}

// The format of Azure repo URL is documented
// https://docs.microsoft.com/en-us/azure/devops/repos/git/clone?view=vsts&tabs=visual-studio#clone_url
func isAzureHost(host string) bool {
return strings.Contains(host, "dev.azure.com") ||
strings.Contains(host, "visualstudio.com")
}

// The format of AWS repo URL is documented
// https://docs.aws.amazon.com/codecommit/latest/userguide/regions.html
func isAWSHost(host string) bool {
return strings.Contains(host, "amazonaws.com")
}
Loading

0 comments on commit 7cbe735

Please sign in to comment.