mirror of
https://github.com/x-motemen/ghq.git
synced 2026-09-10 07:26:27 -04:00
feat: add partial option support to GitBackend
This commit is contained in:
parent
ed4b406086
commit
a655d1d81f
|
|
@ -15,6 +15,7 @@ type _cloneArgs struct {
|
|||
recursive bool
|
||||
bare bool
|
||||
silent bool
|
||||
partial string
|
||||
}
|
||||
|
||||
type _updateArgs struct {
|
||||
|
|
@ -41,6 +42,7 @@ func withFakeGitBackend(t *testing.T, block func(*testing.T, string, *_cloneArgs
|
|||
recursive: vg.recursive,
|
||||
bare: vg.bare,
|
||||
silent: vg.silent,
|
||||
partial: vg.partial,
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
|
|
|||
7
vcs.go
7
vcs.go
|
|
@ -44,7 +44,7 @@ type vcsGetOption struct {
|
|||
url *url.URL
|
||||
dir string
|
||||
recursive, shallow, silent, bare bool
|
||||
branch string
|
||||
branch, partial string
|
||||
}
|
||||
|
||||
// GitBackend is the VCSBackend of git
|
||||
|
|
@ -70,6 +70,11 @@ var GitBackend = &VCSBackend{
|
|||
if vg.bare {
|
||||
args = append(args, "--bare")
|
||||
}
|
||||
if vg.partial == "blobless" {
|
||||
args = append(args, "--filter=blob:none")
|
||||
} else if vg.partial == "treeless" {
|
||||
args = append(args, "--filter=tree:0")
|
||||
}
|
||||
args = append(args, vg.url.String(), vg.dir)
|
||||
|
||||
return run(vg.silent)("git", args...)
|
||||
|
|
|
|||
20
vcs_test.go
20
vcs_test.go
|
|
@ -136,6 +136,26 @@ func TestVCSBackend(t *testing.T) {
|
|||
})
|
||||
},
|
||||
expect: []string{"git", "clone", "--bare", remoteDummyURL.String(), localDir},
|
||||
}, {
|
||||
name: "[git] (partial) blobless clone",
|
||||
f: func() error {
|
||||
return GitBackend.Clone(&vcsGetOption{
|
||||
url: remoteDummyURL,
|
||||
dir: localDir,
|
||||
partial: "blobless",
|
||||
})
|
||||
},
|
||||
expect: []string{"git", "clone", "--filter=blob:none", remoteDummyURL.String(), localDir},
|
||||
}, {
|
||||
name: "[git] (partial) treeless clone",
|
||||
f: func() error {
|
||||
return GitBackend.Clone(&vcsGetOption{
|
||||
url: remoteDummyURL,
|
||||
dir: localDir,
|
||||
partial: "treeless",
|
||||
})
|
||||
},
|
||||
expect: []string{"git", "clone", "--filter=tree:0", remoteDummyURL.String(), localDir},
|
||||
}, {
|
||||
name: "[git] switch git-svn on update",
|
||||
f: func() error {
|
||||
|
|
|
|||
Loading…
Reference in a new issue