summaryrefslogtreecommitdiffstats
path: root/integrations/git_helper_for_declarative_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-11-27 08:35:52 +0800
committerAntoine GIRARD <sapk@users.noreply.github.com>2019-11-27 01:35:52 +0100
commit7b7d382b8b414e7da67dfec7c7e1ef9e0e269d68 (patch)
treeea2bd9ccb5ba69da61fbf463c4f87409e98307b7 /integrations/git_helper_for_declarative_test.go
parent9d9e6ac4117b8efd2f85fc625a4ccfdcf73c4fc3 (diff)
downloadgitea-7b7d382b8b414e7da67dfec7c7e1ef9e0e269d68.tar.gz
gitea-7b7d382b8b414e7da67dfec7c7e1ef9e0e269d68.zip
Fix datarace on git.GlobalCommandArgs on tests (#9162)
* fix datarace on git.GlobalCommandArgs on tests * fix tests * fix tests * fix tests
Diffstat (limited to 'integrations/git_helper_for_declarative_test.go')
-rw-r--r--integrations/git_helper_for_declarative_test.go17
1 files changed, 4 insertions, 13 deletions
diff --git a/integrations/git_helper_for_declarative_test.go b/integrations/git_helper_for_declarative_test.go
index 024bf87a3c..1eb1f1dc8b 100644
--- a/integrations/git_helper_for_declarative_test.go
+++ b/integrations/git_helper_for_declarative_test.go
@@ -63,7 +63,6 @@ func createSSHUrl(gitPath string, u *url.URL) *url.URL {
func allowLFSFilters() []string {
// Now here we should explicitly allow lfs filters to run
- globalArgs := git.GlobalCommandArgs
filteredLFSGlobalArgs := make([]string, len(git.GlobalCommandArgs))
j := 0
for _, arg := range git.GlobalCommandArgs {
@@ -74,9 +73,7 @@ func allowLFSFilters() []string {
j++
}
}
- filteredLFSGlobalArgs = filteredLFSGlobalArgs[:j]
- git.GlobalCommandArgs = filteredLFSGlobalArgs
- return globalArgs
+ return filteredLFSGlobalArgs[:j]
}
func onGiteaRun(t *testing.T, callback func(*testing.T, *url.URL), prepare ...bool) {
@@ -107,9 +104,7 @@ func onGiteaRun(t *testing.T, callback func(*testing.T, *url.URL), prepare ...bo
func doGitClone(dstLocalPath string, u *url.URL) func(*testing.T) {
return func(t *testing.T) {
- oldGlobals := allowLFSFilters()
- assert.NoError(t, git.Clone(u.String(), dstLocalPath, git.CloneRepoOptions{}))
- git.GlobalCommandArgs = oldGlobals
+ assert.NoError(t, git.CloneWithArgs(u.String(), dstLocalPath, allowLFSFilters(), git.CloneRepoOptions{}))
assert.True(t, com.IsExist(filepath.Join(dstLocalPath, "README.md")))
}
}
@@ -170,9 +165,7 @@ func doGitCreateBranch(dstPath, branch string) func(*testing.T) {
func doGitCheckoutBranch(dstPath string, args ...string) func(*testing.T) {
return func(t *testing.T) {
- oldGlobals := allowLFSFilters()
- _, err := git.NewCommand(append([]string{"checkout"}, args...)...).RunInDir(dstPath)
- git.GlobalCommandArgs = oldGlobals
+ _, err := git.NewCommandNoGlobals(append(append(allowLFSFilters(), "checkout"), args...)...).RunInDir(dstPath)
assert.NoError(t, err)
}
}
@@ -186,9 +179,7 @@ func doGitMerge(dstPath string, args ...string) func(*testing.T) {
func doGitPull(dstPath string, args ...string) func(*testing.T) {
return func(t *testing.T) {
- oldGlobals := allowLFSFilters()
- _, err := git.NewCommand(append([]string{"pull"}, args...)...).RunInDir(dstPath)
- git.GlobalCommandArgs = oldGlobals
+ _, err := git.NewCommandNoGlobals(append(append(allowLFSFilters(), "pull"), args...)...).RunInDir(dstPath)
assert.NoError(t, err)
}
}