summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-01-23 21:46:09 +0000
committerGitHub <noreply@github.com>2022-01-23 21:46:09 +0000
commit42991dc89a7f3dadb7ad3b36d18b1a74628ec272 (patch)
tree82b22104610a0e6b117f34d1e32d18db6a5b6146 /integrations
parent160de9fbdac41580b9cba88061bfaf1b3324d5a8 (diff)
downloadgitea-42991dc89a7f3dadb7ad3b36d18b1a74628ec272.tar.gz
gitea-42991dc89a7f3dadb7ad3b36d18b1a74628ec272.zip
Fix partial cloning a repo (#18373) (#18377)
* Fix partial cloning a repo (#18373) - Backport from: #18373 - Backport isn't 1-1, because the frontport had a refactor in that area, which v1.16 doesn't have. * Include diff & use copy * Add partial clone test * patch * Apply suggestions from code review * globalArgs first * avoid copy but make GlobalCMDArgs append first * please linter Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'integrations')
-rw-r--r--integrations/git_helper_for_declarative_test.go11
-rw-r--r--integrations/git_test.go6
2 files changed, 17 insertions, 0 deletions
diff --git a/integrations/git_helper_for_declarative_test.go b/integrations/git_helper_for_declarative_test.go
index 8105bcab8d..05a3e87775 100644
--- a/integrations/git_helper_for_declarative_test.go
+++ b/integrations/git_helper_for_declarative_test.go
@@ -123,6 +123,17 @@ 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{
+ Filter: "blob:none",
+ }))
+ exist, err := util.IsExist(filepath.Join(dstLocalPath, "README.md"))
+ assert.NoError(t, err)
+ assert.True(t, exist)
+ }
+}
+
func doGitCloneFail(u *url.URL) func(*testing.T) {
return func(t *testing.T) {
tmpDir, err := os.MkdirTemp("", "doGitCloneFail")
diff --git a/integrations/git_test.go b/integrations/git_test.go
index 0d33c786aa..f8e3b8dd3f 100644
--- a/integrations/git_test.go
+++ b/integrations/git_test.go
@@ -69,6 +69,12 @@ func testGit(t *testing.T, u *url.URL) {
t.Run("Clone", doGitClone(dstPath, u))
+ dstPath2, err := os.MkdirTemp("", httpContext.Reponame)
+ assert.NoError(t, err)
+ defer util.RemoveAll(dstPath2)
+
+ t.Run("Partial Clone", doPartialGitClone(dstPath2, u))
+
little, big := standardCommitAndPushTest(t, dstPath)
littleLFS, bigLFS := lfsCommitAndPushTest(t, dstPath)
rawTest(t, &httpContext, little, big, littleLFS, bigLFS)