aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2021-12-10 06:51:49 +0100
committerGitHub <noreply@github.com>2021-12-10 06:51:49 +0100
commitfe158cd6e176682e087efea9625ec5409f2956bf (patch)
tree63afb89d42b388316d045820b44972f54e0b8f01 /worktree_test.go
parent589a41ceedfa89e1ff334a969d1beb28cb731de9 (diff)
parent39f97ab86a776dd8acd58a79a660d0cfdb7068c0 (diff)
downloadgo-git-fe158cd6e176682e087efea9625ec5409f2956bf.tar.gz
Merge branch 'master' into jc-push-atomic
Diffstat (limited to 'worktree_test.go')
-rw-r--r--worktree_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/worktree_test.go b/worktree_test.go
index 79cbefd..a8f3187 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -10,6 +10,7 @@ import (
"path/filepath"
"regexp"
"runtime"
+ "strings"
"testing"
"time"
@@ -417,6 +418,37 @@ func (s *WorktreeSuite) TestCheckoutSymlink(c *C) {
c.Assert(err, IsNil)
}
+func (s *WorktreeSuite) TestCheckoutSparse(c *C) {
+ fs := memfs.New()
+ r, err := Clone(memory.NewStorage(), fs, &CloneOptions{
+ URL: s.GetBasicLocalRepositoryURL(),
+ })
+ c.Assert(err, IsNil)
+
+ w, err := r.Worktree()
+ c.Assert(err, IsNil)
+
+ sparseCheckoutDirectories := []string{"go", "json", "php"}
+ c.Assert(w.Checkout(&CheckoutOptions{
+ SparseCheckoutDirectories: sparseCheckoutDirectories,
+ }), IsNil)
+
+ fis, err := fs.ReadDir("/")
+ c.Assert(err, IsNil)
+
+ for _, fi := range fis {
+ c.Assert(fi.IsDir(), Equals, true)
+ var oneOfSparseCheckoutDirs bool
+
+ for _, sparseCheckoutDirectory := range sparseCheckoutDirectories {
+ if strings.HasPrefix(fi.Name(), sparseCheckoutDirectory) {
+ oneOfSparseCheckoutDirs = true
+ }
+ }
+ c.Assert(oneOfSparseCheckoutDirs, Equals, true)
+ }
+}
+
func (s *WorktreeSuite) TestFilenameNormalization(c *C) {
if runtime.GOOS == "windows" {
c.Skip("windows paths may contain non utf-8 sequences")