aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-24 13:34:40 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-07-24 13:34:40 +0200
commit460a7278e6fff2d58300e1855ef8429fec374fa0 (patch)
tree1ad85aa138fb9e3d9e1eefc3b3de40f5f2e16265 /repository_test.go
parent4ee12ab91dc23ef1f6f04a6326ead904f21baf7b (diff)
downloadgo-git-460a7278e6fff2d58300e1855ef8429fec374fa0.tar.gz
move Repository.Pull to Worktree.Pull
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go165
1 files changed, 13 insertions, 152 deletions
diff --git a/repository_test.go b/repository_test.go
index d95b65e..3cc8d48 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -426,6 +426,19 @@ func (s *RepositorySuite) TestFetch(c *C) {
c.Assert(branch.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
}
+func (s *RepositorySuite) TestCloneWithProgress(c *C) {
+ fs := memfs.New()
+
+ buf := bytes.NewBuffer(nil)
+ _, err := Clone(memory.NewStorage(), fs, &CloneOptions{
+ URL: s.GetBasicLocalRepositoryURL(),
+ Progress: buf,
+ })
+
+ c.Assert(err, IsNil)
+ c.Assert(buf.Len(), Not(Equals), 0)
+}
+
func (s *RepositorySuite) TestCloneDeep(c *C) {
fs := memfs.New()
r, _ := Init(memory.NewStorage(), fs)
@@ -575,158 +588,6 @@ func (s *RepositorySuite) TestCloneDetachedHEAD(c *C) {
c.Assert(head.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
}
-func (s *RepositorySuite) TestPullCheckout(c *C) {
- fs := memfs.New()
- r, _ := Init(memory.NewStorage(), fs)
- r.CreateRemote(&config.RemoteConfig{
- Name: DefaultRemoteName,
- URL: s.GetBasicLocalRepositoryURL(),
- })
-
- err := r.Pull(&PullOptions{})
- c.Assert(err, IsNil)
-
- fi, err := fs.ReadDir("")
- c.Assert(err, IsNil)
- c.Assert(fi, HasLen, 8)
-}
-
-func (s *RepositorySuite) TestCloneWithProgress(c *C) {
- fs := memfs.New()
-
- buf := bytes.NewBuffer(nil)
- _, err := Clone(memory.NewStorage(), fs, &CloneOptions{
- URL: s.GetBasicLocalRepositoryURL(),
- Progress: buf,
- })
-
- c.Assert(err, IsNil)
- c.Assert(buf.Len(), Not(Equals), 0)
-}
-
-func (s *RepositorySuite) TestPullUpdateReferencesIfNeeded(c *C) {
- r, _ := Init(memory.NewStorage(), nil)
- r.CreateRemote(&config.RemoteConfig{
- Name: DefaultRemoteName,
- URL: s.GetBasicLocalRepositoryURL(),
- })
-
- err := r.Fetch(&FetchOptions{})
- c.Assert(err, IsNil)
-
- _, err = r.Reference("refs/heads/master", false)
- c.Assert(err, NotNil)
-
- err = r.Pull(&PullOptions{})
- c.Assert(err, IsNil)
-
- head, err := r.Reference(plumbing.HEAD, true)
- c.Assert(err, IsNil)
- c.Assert(head.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
-
- branch, err := r.Reference("refs/heads/master", false)
- c.Assert(err, IsNil)
- c.Assert(branch.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
-
- err = r.Pull(&PullOptions{})
- c.Assert(err, Equals, NoErrAlreadyUpToDate)
-}
-
-func (s *RepositorySuite) TestPullSingleBranch(c *C) {
- r, _ := Init(memory.NewStorage(), nil)
- err := r.clone(&CloneOptions{
- URL: s.GetBasicLocalRepositoryURL(),
- SingleBranch: true,
- })
-
- c.Assert(err, IsNil)
-
- err = r.Pull(&PullOptions{})
- c.Assert(err, Equals, NoErrAlreadyUpToDate)
-
- branch, err := r.Reference("refs/heads/master", false)
- c.Assert(err, IsNil)
- c.Assert(branch.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
-
- branch, err = r.Reference("refs/remotes/foo/branch", false)
- c.Assert(err, NotNil)
-
- storage := r.Storer.(*memory.Storage)
- c.Assert(storage.Objects, HasLen, 28)
-}
-
-func (s *RepositorySuite) TestPullProgress(c *C) {
- r, _ := Init(memory.NewStorage(), nil)
-
- r.CreateRemote(&config.RemoteConfig{
- Name: DefaultRemoteName,
- URL: s.GetBasicLocalRepositoryURL(),
- })
-
- buf := bytes.NewBuffer(nil)
- err := r.Pull(&PullOptions{
- Progress: buf,
- })
-
- c.Assert(err, IsNil)
- c.Assert(buf.Len(), Not(Equals), 0)
-}
-
-func (s *RepositorySuite) TestPullProgressWithRecursion(c *C) {
- path := fixtures.ByTag("submodule").One().Worktree().Root()
-
- dir, err := ioutil.TempDir("", "plain-clone-submodule")
- c.Assert(err, IsNil)
- defer os.RemoveAll(dir)
-
- r, _ := PlainInit(dir, false)
- r.CreateRemote(&config.RemoteConfig{
- Name: DefaultRemoteName,
- URL: path,
- })
-
- err = r.Pull(&PullOptions{
- RecurseSubmodules: DefaultSubmoduleRecursionDepth,
- })
- c.Assert(err, IsNil)
-
- cfg, err := r.Config()
- c.Assert(cfg.Submodules, HasLen, 2)
-}
-
-func (s *RepositorySuite) TestPullAdd(c *C) {
- path := fixtures.Basic().ByTag("worktree").One().Worktree().Root()
-
- r, err := Clone(memory.NewStorage(), nil, &CloneOptions{
- URL: filepath.Join(path, ".git"),
- })
-
- c.Assert(err, IsNil)
-
- storage := r.Storer.(*memory.Storage)
- c.Assert(storage.Objects, HasLen, 28)
-
- branch, err := r.Reference("refs/heads/master", false)
- c.Assert(err, IsNil)
- c.Assert(branch.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
-
- ExecuteOnPath(c, path,
- "touch foo",
- "git add foo",
- "git commit -m foo foo",
- )
-
- err = r.Pull(&PullOptions{RemoteName: "origin"})
- c.Assert(err, IsNil)
-
- // the commit command has introduced a new commit, tree and blob
- c.Assert(storage.Objects, HasLen, 31)
-
- branch, err = r.Reference("refs/heads/master", false)
- c.Assert(err, IsNil)
- c.Assert(branch.Hash().String(), Not(Equals), "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
-}
-
func (s *RepositorySuite) TestPush(c *C) {
url := c.MkDir()
server, err := PlainInit(url, true)