CreateBranch creates a new Branch
(c *config.Branch)
| 695 | |
| 696 | // CreateBranch creates a new Branch |
| 697 | func (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 |
| 716 | func (r *Repository) DeleteBranch(name string) error { |