Skip to content

Commit

Permalink
test(e2e): update git submodule remote tests to use submodule url (ar…
Browse files Browse the repository at this point in the history
…goproj#15701)

Signed-off-by: Chris Fry <[email protected]>
  • Loading branch information
ChristopherFry authored and ymktmk committed Oct 29, 2023
1 parent 262e2e4 commit 98637fe
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions test/e2e/fixture/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,6 @@ func Declarative(filename string, values interface{}) (string, error) {
}

func CreateSubmoduleRepos(repoType string) {
oldEnv := os.Getenv("GIT_ALLOW_PROTOCOL")
CheckError(os.Setenv("GIT_ALLOW_PROTOCOL", "file"))

// set-up submodule repo
FailOnErr(Run("", "cp", "-Rf", "testdata/git-submodule/", submoduleDirectory()))
FailOnErr(Run(submoduleDirectory(), "chmod", "777", "."))
Expand All @@ -893,7 +890,18 @@ func CreateSubmoduleRepos(repoType string) {
FailOnErr(Run(submoduleParentDirectory(), "chmod", "777", "."))
FailOnErr(Run(submoduleParentDirectory(), "git", "init"))
FailOnErr(Run(submoduleParentDirectory(), "git", "add", "."))
FailOnErr(Run(submoduleParentDirectory(), "git", "submodule", "add", "-b", "master", "../submodule.git", "submodule/test"))
if IsRemote() {
FailOnErr(Run(submoduleParentDirectory(), "git", "submodule", "add", "-b", "master", os.Getenv("ARGOCD_E2E_GIT_SERVICE_SUBMODULE"), "submodule/test"))
} else {
oldAllowProtocol, isAllowProtocolSet := os.LookupEnv("GIT_ALLOW_PROTOCOL")
CheckError(os.Setenv("GIT_ALLOW_PROTOCOL", "file"))
FailOnErr(Run(submoduleParentDirectory(), "git", "submodule", "add", "-b", "master", "../submodule.git", "submodule/test"))
if isAllowProtocolSet {
CheckError(os.Setenv("GIT_ALLOW_PROTOCOL", oldAllowProtocol))
} else {
CheckError(os.Unsetenv("GIT_ALLOW_PROTOCOL"))
}
}
if repoType == "ssh" {
FailOnErr(Run(submoduleParentDirectory(), "git", "config", "--file=.gitmodules", "submodule.submodule/test.url", RepoURL(RepoURLTypeSSHSubmodule)))
} else if repoType == "https" {
Expand All @@ -906,8 +914,6 @@ func CreateSubmoduleRepos(repoType string) {
FailOnErr(Run(submoduleParentDirectory(), "git", "remote", "add", "origin", os.Getenv("ARGOCD_E2E_GIT_SERVICE_SUBMODULE_PARENT")))
FailOnErr(Run(submoduleParentDirectory(), "git", "push", "origin", "master", "-f"))
}

CheckError(os.Setenv("GIT_ALLOW_PROTOCOL", oldEnv))
}

func RemoveSubmodule() {
Expand Down

0 comments on commit 98637fe

Please sign in to comment.