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

Method CreateRemote

repository.go:637–655  ·  view source on GitHub ↗

CreateRemote creates a new remote

(c *config.RemoteConfig)

Source from the content-addressed store, hash-verified

635
636// CreateRemote creates a new remote
637func (r *Repository) CreateRemote(c *config.RemoteConfig) (*Remote, error) {
638 if err := c.Validate(); err != nil {
639 return nil, err
640 }
641
642 remote := NewRemote(r.Storer, c)
643
644 cfg, err := r.Config()
645 if err != nil {
646 return nil, err
647 }
648
649 if _, ok := cfg.Remotes[c.Name]; ok {
650 return nil, ErrRemoteExists
651 }
652
653 cfg.Remotes[c.Name] = c
654 return remote, r.Storer.SetConfig(cfg)
655}
656
657// CreateRemoteAnonymous creates a new anonymous remote. c.Name must be "anonymous".
658// It's used like 'git fetch git@github.com:src-d/go-git.git master:master'.

Callers 15

cloneMethod · 0.95
TestDeleteRemoteMethod · 0.80
TestFetchMethod · 0.80
TestFetchContextMethod · 0.80
TestPushMethod · 0.80
TestPushContextMethod · 0.80
TestPushWithProgressMethod · 0.80

Calls 4

ConfigMethod · 0.95
NewRemoteFunction · 0.85
SetConfigMethod · 0.65
ValidateMethod · 0.45

Tested by 15

TestDeleteRemoteMethod · 0.64
TestFetchMethod · 0.64
TestFetchContextMethod · 0.64
TestPushMethod · 0.64
TestPushContextMethod · 0.64
TestPushWithProgressMethod · 0.64