diff options
Diffstat (limited to 'integrations')
-rw-r--r-- | integrations/git_clone_wiki_test.go | 2 | ||||
-rw-r--r-- | integrations/git_helper_for_declarative_test.go | 24 | ||||
-rw-r--r-- | integrations/git_test.go | 4 |
3 files changed, 7 insertions, 23 deletions
diff --git a/integrations/git_clone_wiki_test.go b/integrations/git_clone_wiki_test.go index 16cee254bc..a73174f6aa 100644 --- a/integrations/git_clone_wiki_test.go +++ b/integrations/git_clone_wiki_test.go @@ -41,7 +41,7 @@ func TestRepoCloneWiki(t *testing.T) { u, _ = url.Parse(r) u.User = url.UserPassword("user2", userPassword) t.Run("Clone", func(t *testing.T) { - assert.NoError(t, git.CloneWithArgs(context.Background(), u.String(), dstPath, allowLFSFilters(), git.CloneRepoOptions{})) + assert.NoError(t, git.CloneWithArgs(context.Background(), u.String(), dstPath, git.AllowLFSFiltersArgs(), git.CloneRepoOptions{})) assertFileEqual(t, filepath.Join(dstPath, "Home.md"), []byte("# Home page\n\nThis is the home page!\n")) assertFileExist(t, filepath.Join(dstPath, "Page-With-Image.md")) assertFileExist(t, filepath.Join(dstPath, "Page-With-Spaced-Name.md")) diff --git a/integrations/git_helper_for_declarative_test.go b/integrations/git_helper_for_declarative_test.go index de96f633c0..e1b6b779e9 100644 --- a/integrations/git_helper_for_declarative_test.go +++ b/integrations/git_helper_for_declarative_test.go @@ -14,7 +14,6 @@ import ( "path" "path/filepath" "strconv" - "strings" "testing" "time" @@ -60,21 +59,6 @@ func createSSHUrl(gitPath string, u *url.URL) *url.URL { return &u2 } -func allowLFSFilters() []string { - // Now here we should explicitly allow lfs filters to run - filteredLFSGlobalArgs := make([]string, len(git.GlobalCommandArgs)) - j := 0 - for _, arg := range git.GlobalCommandArgs { - if strings.Contains(arg, "lfs") { - j-- - } else { - filteredLFSGlobalArgs[j] = arg - j++ - } - } - return filteredLFSGlobalArgs[:j] -} - func onGiteaRunTB(t testing.TB, callback func(testing.TB, *url.URL), prepare ...bool) { if len(prepare) == 0 || prepare[0] { defer prepareTestEnv(t, 1)() @@ -115,7 +99,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) { - assert.NoError(t, git.CloneWithArgs(context.Background(), u.String(), dstLocalPath, allowLFSFilters(), git.CloneRepoOptions{})) + assert.NoError(t, git.CloneWithArgs(context.Background(), u.String(), dstLocalPath, git.AllowLFSFiltersArgs(), git.CloneRepoOptions{})) exist, err := util.IsExist(filepath.Join(dstLocalPath, "README.md")) assert.NoError(t, err) assert.True(t, exist) @@ -124,7 +108,7 @@ func doGitClone(dstLocalPath string, u *url.URL) func(*testing.T) { func doPartialGitClone(dstLocalPath string, u *url.URL) func(*testing.T) { return func(t *testing.T) { - assert.NoError(t, git.CloneWithArgs(context.Background(), u.String(), dstLocalPath, allowLFSFilters(), git.CloneRepoOptions{ + assert.NoError(t, git.CloneWithArgs(context.Background(), u.String(), dstLocalPath, git.AllowLFSFiltersArgs(), git.CloneRepoOptions{ Filter: "blob:none", })) exist, err := util.IsExist(filepath.Join(dstLocalPath, "README.md")) @@ -197,7 +181,7 @@ func doGitCreateBranch(dstPath, branch string) func(*testing.T) { func doGitCheckoutBranch(dstPath string, args ...string) func(*testing.T) { return func(t *testing.T) { - _, err := git.NewCommandNoGlobals(append(append(allowLFSFilters(), "checkout"), args...)...).RunInDir(dstPath) + _, err := git.NewCommandNoGlobals(append(append(git.AllowLFSFiltersArgs(), "checkout"), args...)...).RunInDir(dstPath) assert.NoError(t, err) } } @@ -211,7 +195,7 @@ func doGitMerge(dstPath string, args ...string) func(*testing.T) { func doGitPull(dstPath string, args ...string) func(*testing.T) { return func(t *testing.T) { - _, err := git.NewCommandNoGlobals(append(append(allowLFSFilters(), "pull"), args...)...).RunInDir(dstPath) + _, err := git.NewCommandNoGlobals(append(append(git.AllowLFSFiltersArgs(), "pull"), args...)...).RunInDir(dstPath) assert.NoError(t, err) } } diff --git a/integrations/git_test.go b/integrations/git_test.go index 93ff9d2543..e5a85eb756 100644 --- a/integrations/git_test.go +++ b/integrations/git_test.go @@ -167,7 +167,7 @@ func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS strin err = git.AddChanges(dstPath, false, ".gitattributes") assert.NoError(t, err) - err = git.CommitChangesWithArgs(dstPath, allowLFSFilters(), git.CommitChangesOptions{ + err = git.CommitChangesWithArgs(dstPath, git.AllowLFSFiltersArgs(), git.CommitChangesOptions{ Committer: &git.Signature{ Email: "user2@example.com", Name: "User Two", @@ -346,7 +346,7 @@ func generateCommitWithNewData(size int, repoPath, email, fullName, prefix strin // Commit // Now here we should explicitly allow lfs filters to run - globalArgs := allowLFSFilters() + globalArgs := git.AllowLFSFiltersArgs() err = git.AddChangesWithArgs(repoPath, globalArgs, false, filepath.Base(tmpFile.Name())) if err != nil { return "", err |