CreateBranch creates a new Branch
(c *config.Branch)
| 702 | |
| 703 | // CreateBranch creates a new Branch |
| 704 | func (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 |
| 723 | func (r *Repository) DeleteBranch(name string) error { |