MCPcopy Create free account
hub / github.com/go-git/go-git / TestPushToEmptyRepository

Method TestPushToEmptyRepository

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

Source from the content-addressed store, hash-verified

531}
532
533func (s *RemoteSuite) TestPushToEmptyRepository(c *C) {
534 url, clean := s.TemporalDir()
535 defer clean()
536
537 server, err := PlainInit(url, true)
538 c.Assert(err, IsNil)
539
540 srcFs := fixtures.Basic().One().DotGit()
541 sto := filesystem.NewStorage(srcFs, cache.NewObjectLRUDefault())
542
543 r := NewRemote(sto, &config.RemoteConfig{
544 Name: DefaultRemoteName,
545 URLs: []string{url},
546 })
547
548 rs := config.RefSpec("refs/heads/*:refs/heads/*")
549 err = r.Push(&PushOptions{
550 RefSpecs: []config.RefSpec{rs},
551 })
552 c.Assert(err, IsNil)
553
554 iter, err := r.s.IterReferences()
555 c.Assert(err, IsNil)
556
557 expected := make(map[string]string)
558 iter.ForEach(func(ref *plumbing.Reference) error {
559 if !ref.Name().IsBranch() {
560 return nil
561 }
562
563 expected[ref.Name().String()] = ref.Hash().String()
564 return nil
565 })
566 c.Assert(err, IsNil)
567
568 AssertReferences(c, server, expected)
569
570}
571
572func (s *RemoteSuite) TestPushContext(c *C) {
573 url, clean := s.TemporalDir()

Callers

nothing calls this directly

Calls 14

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

Tested by

no test coverage detected