working on merging configs, adding branch/switch/pull commands
This commit is contained in:
25
client/clientcmd/branch.go
Normal file
25
client/clientcmd/branch.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user