MCPcopy
hub / github.com/go-git/go-git / TestPushToEmptyRepository

Method TestPushToEmptyRepository

remote_test.go:565–601  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

563}
564
565func (s *RemoteSuite) TestPushToEmptyRepository(c *C) {
566 url := c.MkDir()
567
568 server, err := PlainInit(url, true)
569 c.Assert(err, IsNil)
570
571 srcFs := fixtures.Basic().One().DotGit()
572 sto := filesystem.NewStorage(srcFs, cache.NewObjectLRUDefault())
573
574 r := NewRemote(sto, &config.RemoteConfig{
575 Name: DefaultRemoteName,
576 URLs: []string{url},
577 })
578
579 rs := config.RefSpec("refs/heads/*:refs/heads/*")
580 err = r.Push(&PushOptions{
581 RefSpecs: []config.RefSpec{rs},
582 })
583 c.Assert(err, IsNil)
584
585 iter, err := r.s.IterReferences()
586 c.Assert(err, IsNil)
587
588 expected := make(map[string]string)
589 iter.ForEach(func(ref *plumbing.Reference) error {
590 if !ref.Name().IsBranch() {
591 return nil
592 }
593
594 expected[ref.Name().String()] = ref.Hash().String()
595 return nil
596 })
597 c.Assert(err, IsNil)
598
599 AssertReferences(c, server, expected)
600
601}
602
603func (s *RemoteSuite) TestPushContext(c *C) {
604 url := c.MkDir()

Callers

nothing calls this directly

Calls 13

PushMethod · 0.95
NewStorageFunction · 0.92
NewObjectLRUDefaultFunction · 0.92
RefSpecTypeAlias · 0.92
PlainInitFunction · 0.85
NewRemoteFunction · 0.85
AssertReferencesFunction · 0.85
IsBranchMethod · 0.80
IterReferencesMethod · 0.65
ForEachMethod · 0.65
NameMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected