working on merging configs, adding branch/switch/pull commands

This commit is contained in:
2020-06-10 22:45:15 -04:00
parent c4aa5a1c66
commit 2cbdf21a81
12 changed files with 269 additions and 66 deletions

View File

@@ -0,0 +1,25 @@
package clientcmd
import (
"fmt"
clientconfig "github.com/deranjer/gvc/client/clientconfig"
)
// CreateBranch creates a new branch with the supplied name
func CreateBranch(conf *clientconfig.Gvcconfig, branchName string) error {
branches := conf.LocalBranches
for _, branch := range branches {
if branch == branchName {
return fmt.Errorf("Branch already exists, unable to create, use the switch command to switch to this branch: %s", branchName)
}
}
conf.LocalBranches = append(conf.LocalBranches, branchName) //add the branch to the config
// TODO Create the branch
//If success, switch to new branch
err := SwitchBranch(conf, branchName)
if err != nil {
return fmt.Errorf("error switching to new branch: %s", err)
}
return nil
}