aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-01-16 16:09:40 +0100
committerGitHub <noreply@github.com>2017-01-16 16:09:40 +0100
commit241e8ba00ac9533299d62dc38684305af2b6c301 (patch)
tree3d00fe006f69af90553b4adb751740ca214b3c29 /repository_test.go
parente11c23d29833cf2a1483ec6e3120eeff9f671dad (diff)
downloadgo-git-241e8ba00ac9533299d62dc38684305af2b6c301.tar.gz
repository: fix pull when fetch returns up-to-date (#207)
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/repository_test.go b/repository_test.go
index 12ae858..5cbc8dd 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -266,6 +266,34 @@ func (s *RepositorySuite) TestCloneDetachedHEAD(c *C) {
c.Assert(head.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
}
+func (s *RepositorySuite) TestPullUpdateReferencesIfNeeded(c *C) {
+ r := NewMemoryRepository()
+ 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 := NewMemoryRepository()
err := r.Clone(&CloneOptions{
@@ -289,7 +317,7 @@ func (s *RepositorySuite) TestPullSingleBranch(c *C) {
c.Assert(storage.Objects, HasLen, 28)
}
-func (s *RepositorySuite) TestPullA(c *C) {
+func (s *RepositorySuite) TestPullAdd(c *C) {
path := fixtures.Basic().One().Worktree().Base()
r := NewMemoryRepository()