aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-06-07 23:56:59 +0100
committerGitHub <noreply@github.com>2023-06-07 23:56:59 +0100
commit35f7e6770361a2c16c9b6c44acdc38ae04c75bd3 (patch)
treec26169956c284d3fb7fc21ec0a907997dd3b2739 /repository_test.go
parent42112780406835a867e6e8cce5ccca3adf13c803 (diff)
parent2d6af16bf6d051cb3014c9970f3ea813e54f73b0 (diff)
downloadgo-git-35f7e6770361a2c16c9b6c44acdc38ae04c75bd3.tar.gz
Merge pull request #765 from matejrisek/feature/shallow-submodules-option
git: add a clone option to allow for shallow cloning of submodules
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/repository_test.go b/repository_test.go
index bcfaa93..d18816f 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -932,6 +932,43 @@ func (s *RepositorySuite) TestPlainCloneWithRecurseSubmodules(c *C) {
c.Assert(cfg.Submodules, HasLen, 2)
}
+func (s *RepositorySuite) TestPlainCloneWithShallowSubmodules(c *C) {
+ if testing.Short() {
+ c.Skip("skipping test in short mode.")
+ }
+
+ dir, clean := s.TemporalDir()
+ defer clean()
+
+ path := fixtures.ByTag("submodule").One().Worktree().Root()
+ mainRepo, err := PlainClone(dir, false, &CloneOptions{
+ URL: path,
+ RecurseSubmodules: 1,
+ ShallowSubmodules: true,
+ })
+ c.Assert(err, IsNil)
+
+ mainWorktree, err := mainRepo.Worktree()
+ c.Assert(err, IsNil)
+
+ submodule, err := mainWorktree.Submodule("basic")
+ c.Assert(err, IsNil)
+
+ subRepo, err := submodule.Repository()
+ c.Assert(err, IsNil)
+
+ lr, err := subRepo.Log(&LogOptions{})
+ c.Assert(err, IsNil)
+
+ commitCount := 0
+ for _, err := lr.Next(); err == nil; _, err = lr.Next() {
+ commitCount++
+ }
+ c.Assert(err, IsNil)
+
+ c.Assert(commitCount, Equals, 1)
+}
+
func (s *RepositorySuite) TestPlainCloneNoCheckout(c *C) {
dir, clean := s.TemporalDir()
defer clean()