You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Backgrounp: I try to clone the sub-dir in a git repo, and i found Chekout with SparseCheckoutDirectories fit me. But when i use it to achive my goal, i found it's useless. i found it work to checkout the specify dirs only when i clone with NoCheckout=false and checkout the same tag/branch like clone.
Reproduce:
code-01:
fs := memfs.New()
r, err := gitv5.Clone(memory.NewStorage(), fs, &gitv5.CloneOptions{
URL: "{{repo url}}",
ReferenceName: plumbing.NewTagReferenceName(tag),
})
require.NoError(t, err)
worktree, err := r.Worktree()
require.NoError(t, err)
err = worktree.Checkout(&gitv5.CheckoutOptions{
SparseCheckoutDirectories: []string{"test"},
Branch: plumbing.NewBranchReferenceName(branch),
})
require.NoError(t, err) // you can found all files are checkouted.
code-02:
fs := memfs.New()
r, err := gitv5.Clone(memory.NewStorage(), fs, &gitv5.CloneOptions{
URL: "{{repo url}}",
ReferenceName: plumbing.NewTagReferenceName(tag),
NoCheckout: true,
})
require.NoError(t, err)
worktree, err := r.Worktree()
require.NoError(t, err)
err = worktree.Checkout(&gitv5.CheckoutOptions{
SparseCheckoutDirectories: []string{"test"},
Branch: plumbing.NewTagReferenceName(tag),
})
require.NoError(t, err) // you can found all files are checkouted.
The text was updated successfully, but these errors were encountered:
Backgrounp: I try to clone the sub-dir in a git repo, and i found Chekout with SparseCheckoutDirectories fit me. But when i use it to achive my goal, i found it's useless. i found it work to checkout the specify dirs only when i clone with NoCheckout=false and checkout the same tag/branch like clone.
Reproduce:
code-01:
code-02:
The text was updated successfully, but these errors were encountered: