Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 1cd347e

Browse files
committed
Merge pull request #47 from TripleDogDare/fix-repository-pulldefault
Fix PullDefault to not cause panics.
2 parents 36d1445 + 4cd57d7 commit 1cd347e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

repository.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func (r *Repository) Pull(remoteName, branch string) (err error) {
6767
return err
6868
}
6969

70+
if branch == "" {
71+
branch = remote.DefaultBranch()
72+
}
73+
7074
ref, err := remote.Ref(branch)
7175
if err != nil {
7276
return err
@@ -93,12 +97,7 @@ func (r *Repository) Pull(remoteName, branch string) (err error) {
9397

9498
// PullDefault like Pull but retrieve the default branch from the default remote
9599
func (r *Repository) PullDefault() (err error) {
96-
remote, ok := r.Remotes[DefaultRemoteName]
97-
if !ok {
98-
return fmt.Errorf("unable to find default remote %q", DefaultRemoteName)
99-
}
100-
101-
return r.Pull(DefaultRemoteName, remote.DefaultBranch())
100+
return r.Pull(DefaultRemoteName, "")
102101
}
103102

104103
// Commit return the commit with the given hash

0 commit comments

Comments
 (0)