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

Method CreateRemote

repository.go:630–648  ·  view source on GitHub ↗

CreateRemote creates a new remote

(c *config.RemoteConfig)

Source from the content-addressed store, hash-verified

628
629// CreateRemote creates a new remote
630func (r *Repository) CreateRemote(c *config.RemoteConfig) (*Remote, error) {
631 if err := c.Validate(); err != nil {
632 return nil, err
633 }
634
635 remote := NewRemote(r.Storer, c)
636
637 cfg, err := r.Config()
638 if err != nil {
639 return nil, err
640 }
641
642 if _, ok := cfg.Remotes[c.Name]; ok {
643 return nil, ErrRemoteExists
644 }
645
646 cfg.Remotes[c.Name] = c
647 return remote, r.Storer.SetConfig(cfg)
648}
649
650// CreateRemoteAnonymous creates a new anonymous remote. c.Name must be "anonymous".
651// 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
TestPullCheckoutMethod · 0.64