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

Method CreateBranch

repository.go:704–720  ·  view source on GitHub ↗

CreateBranch creates a new Branch

(c *config.Branch)

Source from the content-addressed store, hash-verified

702
703// CreateBranch creates a new Branch
704func (r *Repository) CreateBranch(c *config.Branch) error {
705 if err := c.Validate(); err != nil {
706 return err
707 }
708
709 cfg, err := r.Config()
710 if err != nil {
711 return err
712 }
713
714 if _, ok := cfg.Branches[c.Name]; ok {
715 return ErrBranchExists
716 }
717
718 cfg.Branches[c.Name] = c
719 return r.Storer.SetConfig(cfg)
720}
721
722// DeleteBranch delete a Branch from the repository and delete the config
723func (r *Repository) DeleteBranch(name string) error {

Callers 7

cloneMethod · 0.95
TestEmptyCreateBranchMethod · 0.80
TestDeleteBranchMethod · 0.80

Calls 3

ConfigMethod · 0.95
SetConfigMethod · 0.65
ValidateMethod · 0.45

Tested by 6

TestEmptyCreateBranchMethod · 0.64
TestDeleteBranchMethod · 0.64