|
|
@ -14,7 +14,6 @@ import ( |
|
|
|
"path" |
|
|
|
"path" |
|
|
|
"path/filepath" |
|
|
|
"path/filepath" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
@ -60,21 +59,6 @@ func createSSHUrl(gitPath string, u *url.URL) *url.URL { |
|
|
|
return &u2 |
|
|
|
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) { |
|
|
|
func onGiteaRunTB(t testing.TB, callback func(testing.TB, *url.URL), prepare ...bool) { |
|
|
|
if len(prepare) == 0 || prepare[0] { |
|
|
|
if len(prepare) == 0 || prepare[0] { |
|
|
|
defer prepareTestEnv(t, 1)() |
|
|
|
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) { |
|
|
|
func doGitClone(dstLocalPath string, u *url.URL) func(*testing.T) { |
|
|
|
return func(t *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")) |
|
|
|
exist, err := util.IsExist(filepath.Join(dstLocalPath, "README.md")) |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.True(t, exist) |
|
|
|
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) { |
|
|
|
func doPartialGitClone(dstLocalPath string, u *url.URL) func(*testing.T) { |
|
|
|
return func(t *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", |
|
|
|
Filter: "blob:none", |
|
|
|
})) |
|
|
|
})) |
|
|
|
exist, err := util.IsExist(filepath.Join(dstLocalPath, "README.md")) |
|
|
|
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) { |
|
|
|
func doGitCheckoutBranch(dstPath string, args ...string) func(*testing.T) { |
|
|
|
return func(t *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) |
|
|
|
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) { |
|
|
|
func doGitPull(dstPath string, args ...string) func(*testing.T) { |
|
|
|
return func(t *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) |
|
|
|
assert.NoError(t, err) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|