diff options
author | Gusted <williamzijl7@hotmail.com> | 2022-01-23 21:19:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-23 22:19:32 +0100 |
commit | c2e13fb763ec4764f8ebbeb25b190b48ac7b99ad (patch) | |
tree | 29572d3dcc4666afe7056847578176370897fb61 /modules | |
parent | 5e5740af69cb0f44ff0c1576a2387388d75bb4c2 (diff) | |
download | gitea-c2e13fb763ec4764f8ebbeb25b190b48ac7b99ad.tar.gz gitea-c2e13fb763ec4764f8ebbeb25b190b48ac7b99ad.zip |
Fix partial cloning a repo (#18373)
- Pass the Global command args into serviceRPC.
- Fixes error with partial cloning.
- Add partial clone test
- Include diff
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/git/diff.go | 2 | ||||
-rw-r--r-- | modules/git/repo.go | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/modules/git/diff.go b/modules/git/diff.go index 38aefabf1a..4723898e37 100644 --- a/modules/git/diff.go +++ b/modules/git/diff.go @@ -81,7 +81,7 @@ func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diff } stderr := new(bytes.Buffer) - cmd := NewCommandContextNoGlobals(repo.Ctx, args...) + cmd := NewCommandContext(repo.Ctx, args...) if err = cmd.RunWithContext(&RunContext{ Timeout: -1, Dir: repo.Path, diff --git a/modules/git/repo.go b/modules/git/repo.go index 6368c6459b..5636405118 100644 --- a/modules/git/repo.go +++ b/modules/git/repo.go @@ -101,6 +101,7 @@ type CloneRepoOptions struct { Shared bool NoCheckout bool Depth int + Filter string } // Clone clones original repository to target path. @@ -136,7 +137,9 @@ func CloneWithArgs(ctx context.Context, from, to string, args []string, opts Clo if opts.Depth > 0 { cmd.AddArguments("--depth", strconv.Itoa(opts.Depth)) } - + if opts.Filter != "" { + cmd.AddArguments("--filter", opts.Filter) + } if len(opts.Branch) > 0 { cmd.AddArguments("-b", opts.Branch) } |