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

Method CreateBranch

repository.go:697–713  ·  view source on GitHub ↗

CreateBranch creates a new Branch

(c *config.Branch)

Source from the content-addressed store, hash-verified

695
696// CreateBranch creates a new Branch
697func (r *Repository) CreateBranch(c *config.Branch) error {
698 if err := c.Validate(); err != nil {
699 return err
700 }
701
702 cfg, err := r.Config()
703 if err != nil {
704 return err
705 }
706
707 if _, ok := cfg.Branches[c.Name]; ok {
708 return ErrBranchExists
709 }
710
711 cfg.Branches[c.Name] = c
712 return r.Storer.SetConfig(cfg)
713}
714
715// DeleteBranch delete a Branch from the repository and delete the config
716func (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