fork of go-git with some jj specific features
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #803 from TheHipbot/branch-tracking-on-clone

config: adds branches to config for tracking branches against remotes…

authored by

Máximo Cuadros and committed by
GitHub
0db54e82 40991913

+507 -7
+71
config/branch.go
··· 1 + package config 2 + 3 + import ( 4 + "errors" 5 + 6 + "gopkg.in/src-d/go-git.v4/plumbing" 7 + format "gopkg.in/src-d/go-git.v4/plumbing/format/config" 8 + ) 9 + 10 + var ( 11 + errBranchEmptyName = errors.New("branch config: empty name") 12 + errBranchInvalidMerge = errors.New("branch config: invalid merge") 13 + ) 14 + 15 + // Branch contains information on the 16 + // local branches and which remote to track 17 + type Branch struct { 18 + // Name of branch 19 + Name string 20 + // Remote name of remote to track 21 + Remote string 22 + // Merge is the local refspec for the branch 23 + Merge plumbing.ReferenceName 24 + 25 + raw *format.Subsection 26 + } 27 + 28 + // Validate validates fields of branch 29 + func (b *Branch) Validate() error { 30 + if b.Name == "" { 31 + return errBranchEmptyName 32 + } 33 + 34 + if b.Merge != "" && !b.Merge.IsBranch() { 35 + return errBranchInvalidMerge 36 + } 37 + 38 + return nil 39 + } 40 + 41 + func (b *Branch) marshal() *format.Subsection { 42 + if b.raw == nil { 43 + b.raw = &format.Subsection{} 44 + } 45 + 46 + b.raw.Name = b.Name 47 + 48 + if b.Remote == "" { 49 + b.raw.RemoveOption(remoteSection) 50 + } else { 51 + b.raw.SetOption(remoteSection, b.Remote) 52 + } 53 + 54 + if b.Merge == "" { 55 + b.raw.RemoveOption(mergeKey) 56 + } else { 57 + b.raw.SetOption(mergeKey, string(b.Merge)) 58 + } 59 + 60 + return b.raw 61 + } 62 + 63 + func (b *Branch) unmarshal(s *format.Subsection) error { 64 + b.raw = s 65 + 66 + b.Name = b.raw.Name 67 + b.Remote = b.raw.Options.Get(remoteSection) 68 + b.Merge = plumbing.ReferenceName(b.raw.Options.Get(mergeKey)) 69 + 70 + return b.Validate() 71 + }
+76
config/branch_test.go
··· 1 + package config 2 + 3 + import ( 4 + . "gopkg.in/check.v1" 5 + "gopkg.in/src-d/go-git.v4/plumbing" 6 + ) 7 + 8 + type BranchSuite struct{} 9 + 10 + var _ = Suite(&BranchSuite{}) 11 + 12 + func (b *BranchSuite) TestValidateName(c *C) { 13 + goodBranch := Branch{ 14 + Name: "master", 15 + Remote: "some_remote", 16 + Merge: "refs/heads/master", 17 + } 18 + badBranch := Branch{ 19 + Remote: "some_remote", 20 + Merge: "refs/heads/master", 21 + } 22 + c.Assert(goodBranch.Validate(), IsNil) 23 + c.Assert(badBranch.Validate(), NotNil) 24 + } 25 + 26 + func (b *BranchSuite) TestValidateMerge(c *C) { 27 + goodBranch := Branch{ 28 + Name: "master", 29 + Remote: "some_remote", 30 + Merge: "refs/heads/master", 31 + } 32 + badBranch := Branch{ 33 + Name: "master", 34 + Remote: "some_remote", 35 + Merge: "blah", 36 + } 37 + c.Assert(goodBranch.Validate(), IsNil) 38 + c.Assert(badBranch.Validate(), NotNil) 39 + } 40 + 41 + func (b *BranchSuite) TestMarshall(c *C) { 42 + expected := []byte(`[core] 43 + bare = false 44 + [branch "branch-tracking-on-clone"] 45 + remote = fork 46 + merge = refs/heads/branch-tracking-on-clone 47 + `) 48 + 49 + cfg := NewConfig() 50 + cfg.Branches["branch-tracking-on-clone"] = &Branch{ 51 + Name: "branch-tracking-on-clone", 52 + Remote: "fork", 53 + Merge: plumbing.ReferenceName("refs/heads/branch-tracking-on-clone"), 54 + } 55 + 56 + actual, err := cfg.Marshal() 57 + c.Assert(err, IsNil) 58 + c.Assert(string(actual), Equals, string(expected)) 59 + } 60 + 61 + func (b *BranchSuite) TestUnmarshall(c *C) { 62 + input := []byte(`[core] 63 + bare = false 64 + [branch "branch-tracking-on-clone"] 65 + remote = fork 66 + merge = refs/heads/branch-tracking-on-clone 67 + `) 68 + 69 + cfg := NewConfig() 70 + err := cfg.Unmarshal(input) 71 + c.Assert(err, IsNil) 72 + branch := cfg.Branches["branch-tracking-on-clone"] 73 + c.Assert(branch.Name, Equals, "branch-tracking-on-clone") 74 + c.Assert(branch.Remote, Equals, "fork") 75 + c.Assert(branch.Merge, Equals, plumbing.ReferenceName("refs/heads/branch-tracking-on-clone")) 76 + }
+64 -2
config/config.go
··· 25 25 } 26 26 27 27 var ( 28 - ErrInvalid = errors.New("config invalid remote") 28 + ErrInvalid = errors.New("config invalid key in remote or branch") 29 29 ErrRemoteConfigNotFound = errors.New("remote config not found") 30 30 ErrRemoteConfigEmptyURL = errors.New("remote config: empty URL") 31 31 ErrRemoteConfigEmptyName = errors.New("remote config: empty name") ··· 55 55 // Submodules list of repository submodules, the key of the map is the name 56 56 // of the submodule, should equal to Submodule.Name. 57 57 Submodules map[string]*Submodule 58 - 58 + // Branches list of branches, the key is the branch name and should 59 + // equal Branch.Name 60 + Branches map[string]*Branch 59 61 // Raw contains the raw information of a config file. The main goal is 60 62 // preserve the parsed information from the original format, to avoid 61 63 // dropping unsupported fields. ··· 67 69 config := &Config{ 68 70 Remotes: make(map[string]*RemoteConfig), 69 71 Submodules: make(map[string]*Submodule), 72 + Branches: make(map[string]*Branch), 70 73 Raw: format.New(), 71 74 } 72 75 ··· 83 86 } 84 87 85 88 if err := r.Validate(); err != nil { 89 + return err 90 + } 91 + } 92 + 93 + for name, b := range c.Branches { 94 + if b.Name != name { 95 + return ErrInvalid 96 + } 97 + 98 + if err := b.Validate(); err != nil { 86 99 return err 87 100 } 88 101 } ··· 93 106 const ( 94 107 remoteSection = "remote" 95 108 submoduleSection = "submodule" 109 + branchSection = "branch" 96 110 coreSection = "core" 97 111 packSection = "pack" 98 112 fetchKey = "fetch" ··· 100 114 bareKey = "bare" 101 115 worktreeKey = "worktree" 102 116 windowKey = "window" 117 + mergeKey = "merge" 103 118 104 119 // DefaultPackWindow holds the number of previous objects used to 105 120 // generate deltas. The value 10 is the same used by git command. ··· 121 136 return err 122 137 } 123 138 c.unmarshalSubmodules() 139 + 140 + if err := c.unmarshalBranches(); err != nil { 141 + return err 142 + } 143 + 124 144 return c.unmarshalRemotes() 125 145 } 126 146 ··· 172 192 } 173 193 } 174 194 195 + func (c *Config) unmarshalBranches() error { 196 + bs := c.Raw.Section(branchSection) 197 + for _, sub := range bs.Subsections { 198 + b := &Branch{} 199 + 200 + if err := b.unmarshal(sub); err != nil { 201 + return err 202 + } 203 + 204 + c.Branches[b.Name] = b 205 + } 206 + return nil 207 + } 208 + 175 209 // Marshal returns Config encoded as a git-config file. 176 210 func (c *Config) Marshal() ([]byte, error) { 177 211 c.marshalCore() 178 212 c.marshalPack() 179 213 c.marshalRemotes() 180 214 c.marshalSubmodules() 215 + c.marshalBranches() 181 216 182 217 buf := bytes.NewBuffer(nil) 183 218 if err := format.NewEncoder(buf).Encode(c.Raw); err != nil { ··· 243 278 s.Subsections[i] = section 244 279 i++ 245 280 } 281 + } 282 + 283 + func (c *Config) marshalBranches() { 284 + s := c.Raw.Section(branchSection) 285 + newSubsections := make(format.Subsections, 0, len(c.Branches)) 286 + added := make(map[string]bool) 287 + for _, subsection := range s.Subsections { 288 + if branch, ok := c.Branches[subsection.Name]; ok { 289 + newSubsections = append(newSubsections, branch.marshal()) 290 + added[subsection.Name] = true 291 + } 292 + } 293 + 294 + branchNames := make([]string, 0, len(c.Branches)) 295 + for name := range c.Branches { 296 + branchNames = append(branchNames, name) 297 + } 298 + 299 + sort.Strings(branchNames) 300 + 301 + for _, name := range branchNames { 302 + if !added[name] { 303 + newSubsections = append(newSubsections, c.Branches[name].marshal()) 304 + } 305 + } 306 + 307 + s.Subsections = newSubsections 246 308 } 247 309 248 310 // RemoteConfig contains the configuration for a given remote repository.
+73 -3
config/config_test.go
··· 1 1 package config 2 2 3 - import . "gopkg.in/check.v1" 3 + import ( 4 + . "gopkg.in/check.v1" 5 + "gopkg.in/src-d/go-git.v4/plumbing" 6 + ) 4 7 5 8 type ConfigSuite struct{} 6 9 ··· 47 50 c.Assert(cfg.Submodules["qux"].Name, Equals, "qux") 48 51 c.Assert(cfg.Submodules["qux"].URL, Equals, "https://github.com/foo/qux.git") 49 52 c.Assert(cfg.Submodules["qux"].Branch, Equals, "bar") 50 - 53 + c.Assert(cfg.Branches["master"].Remote, Equals, "origin") 54 + c.Assert(cfg.Branches["master"].Merge, Equals, plumbing.ReferenceName("refs/heads/master")) 51 55 } 52 56 53 57 func (s *ConfigSuite) TestMarshall(c *C) { ··· 65 69 url = git@github.com:mcuadros/go-git.git 66 70 [submodule "qux"] 67 71 url = https://github.com/foo/qux.git 72 + [branch "master"] 73 + remote = origin 74 + merge = refs/heads/master 68 75 `) 69 76 70 77 cfg := NewConfig() ··· 85 92 cfg.Submodules["qux"] = &Submodule{ 86 93 Name: "qux", 87 94 URL: "https://github.com/foo/qux.git", 95 + } 96 + 97 + cfg.Branches["master"] = &Branch{ 98 + Name: "master", 99 + Remote: "origin", 100 + Merge: "refs/heads/master", 88 101 } 89 102 90 103 b, err := cfg.Marshal() ··· 118 131 c.Assert(string(output), DeepEquals, string(input)) 119 132 } 120 133 134 + func (s *ConfigSuite) TestValidateConfig(c *C) { 135 + config := &Config{ 136 + Remotes: map[string]*RemoteConfig{ 137 + "bar": { 138 + Name: "bar", 139 + URLs: []string{"http://foo/bar"}, 140 + }, 141 + }, 142 + Branches: map[string]*Branch{ 143 + "bar": { 144 + Name: "bar", 145 + }, 146 + "foo": { 147 + Name: "foo", 148 + Remote: "origin", 149 + Merge: plumbing.ReferenceName("refs/heads/foo"), 150 + }, 151 + }, 152 + } 153 + 154 + c.Assert(config.Validate(), IsNil) 155 + } 156 + 121 157 func (s *ConfigSuite) TestValidateInvalidRemote(c *C) { 122 158 config := &Config{ 123 159 Remotes: map[string]*RemoteConfig{ ··· 128 164 c.Assert(config.Validate(), Equals, ErrRemoteConfigEmptyURL) 129 165 } 130 166 131 - func (s *ConfigSuite) TestValidateInvalidKey(c *C) { 167 + func (s *ConfigSuite) TestValidateInvalidRemoteKey(c *C) { 132 168 config := &Config{ 133 169 Remotes: map[string]*RemoteConfig{ 134 170 "bar": {Name: "foo"}, ··· 157 193 c.Assert(fetch[0].String(), Equals, "+refs/heads/*:refs/remotes/foo/*") 158 194 } 159 195 196 + func (s *ConfigSuite) TestValidateInvalidBranchKey(c *C) { 197 + config := &Config{ 198 + Branches: map[string]*Branch{ 199 + "foo": { 200 + Name: "bar", 201 + Remote: "origin", 202 + Merge: plumbing.ReferenceName("refs/heads/bar"), 203 + }, 204 + }, 205 + } 206 + 207 + c.Assert(config.Validate(), Equals, ErrInvalid) 208 + } 209 + 210 + func (s *ConfigSuite) TestValidateInvalidBranch(c *C) { 211 + config := &Config{ 212 + Branches: map[string]*Branch{ 213 + "bar": { 214 + Name: "bar", 215 + Remote: "origin", 216 + Merge: plumbing.ReferenceName("refs/heads/bar"), 217 + }, 218 + "foo": { 219 + Name: "foo", 220 + Remote: "origin", 221 + Merge: plumbing.ReferenceName("baz"), 222 + }, 223 + }, 224 + } 225 + 226 + c.Assert(config.Validate(), Equals, errBranchInvalidMerge) 227 + } 228 + 160 229 func (s *ConfigSuite) TestRemoteConfigDefaultValues(c *C) { 161 230 config := NewConfig() 162 231 163 232 c.Assert(config.Remotes, HasLen, 0) 233 + c.Assert(config.Branches, HasLen, 0) 164 234 c.Assert(config.Submodules, HasLen, 0) 165 235 c.Assert(config.Raw, NotNil) 166 236 c.Assert(config.Pack.Window, Equals, DefaultPackWindow)
+77 -2
repository.go
··· 25 25 ) 26 26 27 27 var ( 28 + // ErrBranchExists an error stating the specified branch already exists 29 + ErrBranchExists = errors.New("branch already exists") 30 + // ErrBranchNotFound an error stating the specified branch does not exist 31 + ErrBranchNotFound = errors.New("branch not found") 28 32 ErrInvalidReference = errors.New("invalid reference, should be a tag or a branch") 29 33 ErrRepositoryNotExists = errors.New("repository does not exist") 30 34 ErrRepositoryAlreadyExists = errors.New("repository already exists") 31 35 ErrRemoteNotFound = errors.New("remote not found") 32 - ErrRemoteExists = errors.New("remote already exists ") 36 + ErrRemoteExists = errors.New("remote already exists") 33 37 ErrWorktreeNotProvided = errors.New("worktree should be provided") 34 38 ErrIsBareRepository = errors.New("worktree not available in a bare repository") 35 39 ErrUnableToResolveCommit = errors.New("unable to resolve commit") ··· 428 432 return r.Storer.SetConfig(cfg) 429 433 } 430 434 435 + // Branch return a Branch if exists 436 + func (r *Repository) Branch(name string) (*config.Branch, error) { 437 + cfg, err := r.Storer.Config() 438 + if err != nil { 439 + return nil, err 440 + } 441 + 442 + b, ok := cfg.Branches[name] 443 + if !ok { 444 + return nil, ErrBranchNotFound 445 + } 446 + 447 + return b, nil 448 + } 449 + 450 + // CreateBranch creates a new Branch 451 + func (r *Repository) CreateBranch(c *config.Branch) error { 452 + if err := c.Validate(); err != nil { 453 + return err 454 + } 455 + 456 + cfg, err := r.Storer.Config() 457 + if err != nil { 458 + return err 459 + } 460 + 461 + if _, ok := cfg.Branches[c.Name]; ok { 462 + return ErrBranchExists 463 + } 464 + 465 + cfg.Branches[c.Name] = c 466 + return r.Storer.SetConfig(cfg) 467 + } 468 + 469 + // DeleteBranch delete a Branch from the repository and delete the config 470 + func (r *Repository) DeleteBranch(name string) error { 471 + cfg, err := r.Storer.Config() 472 + if err != nil { 473 + return err 474 + } 475 + 476 + if _, ok := cfg.Branches[name]; !ok { 477 + return ErrBranchNotFound 478 + } 479 + 480 + delete(cfg.Branches, name) 481 + return r.Storer.SetConfig(cfg) 482 + } 483 + 431 484 func (r *Repository) resolveToCommitHash(h plumbing.Hash) (plumbing.Hash, error) { 432 485 obj, err := r.Storer.EncodedObject(plumbing.AnyObject, h) 433 486 if err != nil { ··· 501 554 } 502 555 } 503 556 504 - return r.updateRemoteConfigIfNeeded(o, c, ref) 557 + if err := r.updateRemoteConfigIfNeeded(o, c, ref); err != nil { 558 + return err 559 + } 560 + 561 + if ref.Name().IsBranch() { 562 + branchRef := ref.Name() 563 + branchName := strings.Split(string(branchRef), "refs/heads/")[1] 564 + 565 + b := &config.Branch{ 566 + Name: branchName, 567 + Merge: branchRef, 568 + } 569 + if o.RemoteName == "" { 570 + b.Remote = "origin" 571 + } else { 572 + b.Remote = o.RemoteName 573 + } 574 + if err := r.CreateBranch(b); err != nil { 575 + return err 576 + } 577 + } 578 + 579 + return nil 505 580 } 506 581 507 582 const (
+146
repository_test.go
··· 244 244 c.Assert(alt, IsNil) 245 245 } 246 246 247 + func (s *RepositorySuite) TestCreateBranchAndBranch(c *C) { 248 + r, _ := Init(memory.NewStorage(), nil) 249 + testBranch := &config.Branch{ 250 + Name: "foo", 251 + Remote: "origin", 252 + Merge: "refs/heads/foo", 253 + } 254 + err := r.CreateBranch(testBranch) 255 + 256 + c.Assert(err, IsNil) 257 + cfg, err := r.Config() 258 + c.Assert(err, IsNil) 259 + c.Assert(len(cfg.Branches), Equals, 1) 260 + branch := cfg.Branches["foo"] 261 + c.Assert(branch.Name, Equals, testBranch.Name) 262 + c.Assert(branch.Remote, Equals, testBranch.Remote) 263 + c.Assert(branch.Merge, Equals, testBranch.Merge) 264 + 265 + branch, err = r.Branch("foo") 266 + c.Assert(err, IsNil) 267 + c.Assert(branch.Name, Equals, testBranch.Name) 268 + c.Assert(branch.Remote, Equals, testBranch.Remote) 269 + c.Assert(branch.Merge, Equals, testBranch.Merge) 270 + } 271 + 272 + func (s *RepositorySuite) TestCreateBranchUnmarshal(c *C) { 273 + r, _ := Init(memory.NewStorage(), nil) 274 + 275 + expected := []byte(`[core] 276 + bare = true 277 + [remote "foo"] 278 + url = http://foo/foo.git 279 + fetch = +refs/heads/*:refs/remotes/foo/* 280 + [branch "foo"] 281 + remote = origin 282 + merge = refs/heads/foo 283 + [branch "master"] 284 + remote = origin 285 + merge = refs/heads/master 286 + `) 287 + 288 + _, err := r.CreateRemote(&config.RemoteConfig{ 289 + Name: "foo", 290 + URLs: []string{"http://foo/foo.git"}, 291 + }) 292 + c.Assert(err, IsNil) 293 + testBranch1 := &config.Branch{ 294 + Name: "master", 295 + Remote: "origin", 296 + Merge: "refs/heads/master", 297 + } 298 + testBranch2 := &config.Branch{ 299 + Name: "foo", 300 + Remote: "origin", 301 + Merge: "refs/heads/foo", 302 + } 303 + err = r.CreateBranch(testBranch1) 304 + err = r.CreateBranch(testBranch2) 305 + 306 + c.Assert(err, IsNil) 307 + cfg, err := r.Config() 308 + c.Assert(err, IsNil) 309 + marshaled, err := cfg.Marshal() 310 + c.Assert(string(expected), Equals, string(marshaled)) 311 + } 312 + 313 + func (s *RepositorySuite) TestBranchInvalid(c *C) { 314 + r, _ := Init(memory.NewStorage(), nil) 315 + branch, err := r.Branch("foo") 316 + 317 + c.Assert(err, NotNil) 318 + c.Assert(branch, IsNil) 319 + } 320 + 321 + func (s *RepositorySuite) TestCreateBranchInvalid(c *C) { 322 + r, _ := Init(memory.NewStorage(), nil) 323 + err := r.CreateBranch(&config.Branch{}) 324 + 325 + c.Assert(err, NotNil) 326 + 327 + testBranch := &config.Branch{ 328 + Name: "foo", 329 + Remote: "origin", 330 + Merge: "refs/heads/foo", 331 + } 332 + err = r.CreateBranch(testBranch) 333 + c.Assert(err, IsNil) 334 + err = r.CreateBranch(testBranch) 335 + c.Assert(err, NotNil) 336 + } 337 + 338 + func (s *RepositorySuite) TestDeleteBranch(c *C) { 339 + r, _ := Init(memory.NewStorage(), nil) 340 + testBranch := &config.Branch{ 341 + Name: "foo", 342 + Remote: "origin", 343 + Merge: "refs/heads/foo", 344 + } 345 + err := r.CreateBranch(testBranch) 346 + 347 + c.Assert(err, IsNil) 348 + 349 + err = r.DeleteBranch("foo") 350 + c.Assert(err, IsNil) 351 + 352 + b, err := r.Branch("foo") 353 + c.Assert(err, Equals, ErrBranchNotFound) 354 + c.Assert(b, IsNil) 355 + 356 + err = r.DeleteBranch("foo") 357 + c.Assert(err, Equals, ErrBranchNotFound) 358 + } 359 + 247 360 func (s *RepositorySuite) TestPlainInit(c *C) { 248 361 dir, err := ioutil.TempDir("", "plain-init") 249 362 c.Assert(err, IsNil) ··· 447 560 remotes, err := r.Remotes() 448 561 c.Assert(err, IsNil) 449 562 c.Assert(remotes, HasLen, 1) 563 + cfg, err := r.Config() 564 + c.Assert(err, IsNil) 565 + c.Assert(cfg.Branches, HasLen, 1) 566 + c.Assert(cfg.Branches["master"].Name, Equals, "master") 450 567 } 451 568 452 569 func (s *RepositorySuite) TestPlainCloneContext(c *C) { ··· 480 597 cfg, err := r.Config() 481 598 c.Assert(err, IsNil) 482 599 c.Assert(cfg.Remotes, HasLen, 1) 600 + c.Assert(cfg.Branches, HasLen, 1) 483 601 c.Assert(cfg.Submodules, HasLen, 2) 484 602 } 485 603 ··· 615 733 c.Assert(cfg.Remotes, HasLen, 1) 616 734 c.Assert(cfg.Remotes["origin"].Name, Equals, "origin") 617 735 c.Assert(cfg.Remotes["origin"].URLs, HasLen, 1) 736 + c.Assert(cfg.Branches, HasLen, 1) 737 + c.Assert(cfg.Branches["master"].Name, Equals, "master") 618 738 } 619 739 620 740 func (s *RepositorySuite) TestCloneSingleBranchAndNonHEAD(c *C) { ··· 635 755 remotes, err := r.Remotes() 636 756 c.Assert(err, IsNil) 637 757 c.Assert(remotes, HasLen, 1) 758 + 759 + cfg, err := r.Config() 760 + c.Assert(err, IsNil) 761 + c.Assert(cfg.Branches, HasLen, 1) 762 + c.Assert(cfg.Branches["branch"].Name, Equals, "branch") 763 + c.Assert(cfg.Branches["branch"].Remote, Equals, "origin") 764 + c.Assert(cfg.Branches["branch"].Merge, Equals, plumbing.ReferenceName("refs/heads/branch")) 638 765 639 766 head, err = r.Reference(plumbing.HEAD, false) 640 767 c.Assert(err, IsNil) ··· 672 799 c.Assert(err, IsNil) 673 800 c.Assert(remotes, HasLen, 1) 674 801 802 + cfg, err := r.Config() 803 + c.Assert(err, IsNil) 804 + c.Assert(cfg.Branches, HasLen, 1) 805 + c.Assert(cfg.Branches["master"].Name, Equals, "master") 806 + c.Assert(cfg.Branches["master"].Remote, Equals, "origin") 807 + c.Assert(cfg.Branches["master"].Merge, Equals, plumbing.ReferenceName("refs/heads/master")) 808 + 675 809 head, err = r.Reference(plumbing.HEAD, false) 676 810 c.Assert(err, IsNil) 677 811 c.Assert(head, NotNil) ··· 698 832 }) 699 833 c.Assert(err, IsNil) 700 834 835 + cfg, err := r.Config() 836 + c.Assert(err, IsNil) 837 + c.Assert(cfg.Branches, HasLen, 0) 838 + 701 839 head, err := r.Reference(plumbing.HEAD, false) 702 840 c.Assert(err, IsNil) 703 841 c.Assert(head, NotNil) ··· 720 858 }) 721 859 722 860 c.Assert(err, IsNil) 861 + 862 + cfg, err := r.Config() 863 + c.Assert(err, IsNil) 864 + c.Assert(cfg.Branches, HasLen, 0) 723 865 724 866 head, err := r.Reference(plumbing.HEAD, false) 725 867 c.Assert(err, IsNil) ··· 741 883 ReferenceName: plumbing.ReferenceName("refs/tags/annotated-tag"), 742 884 }) 743 885 c.Assert(err, IsNil) 886 + 887 + cfg, err := r.Config() 888 + c.Assert(err, IsNil) 889 + c.Assert(cfg.Branches, HasLen, 0) 744 890 745 891 head, err := r.Reference(plumbing.HEAD, false) 746 892 c.Assert(err, IsNil)