starting on the commit logic

This commit is contained in:
2020-06-21 22:26:03 -04:00
parent 1ec7b436da
commit e4ac7f70e6
7 changed files with 90 additions and 28 deletions

View File

@@ -110,7 +110,7 @@ func main() {
pullCommand(cli, &conf)
// Adding the "commit" command
commitCommand(cli, &conf)
commitCommand(cli, &conf, m)
err = cli.Run()
if err != nil {
@@ -689,10 +689,10 @@ func pullCommand(cli *clir.Cli, conf *config.Gvcconfig) {
})
}
func commitCommand(cli *clir.Cli, conf *config.Gvcconfig) {
func commitCommand(cli *clir.Cli, conf *config.Gvcconfig, m *manager.Manager) {
commitCommand := cli.NewSubCommand("commit", "commits the changes to the repo")
var commitMessage string
commitMessageFlag := pullCommand.StringFlag("message", "adds a message to a commit", &commitMessage)
commitMessageFlag := commitCommand.StringFlag("message", "adds a message to a commit", &commitMessage)
commitMessageFlag.FlagShortCut("message", "m")
commitCommand.Action(func() error {
isRepo := validateRepo()
@@ -700,13 +700,15 @@ func commitCommand(cli *clir.Cli, conf *config.Gvcconfig) {
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
os.Exit(0)
}
if len(commitCommand.OtherArgs()) == 0 {
commitCommand.PrintHelp()
fmt.Println("branch name required..")
os.Exit(0)
// if len(commitCommand.OtherArgs()) == 0 {
// commitCommand.PrintHelp()
// fmt.Println("branch name required..")
// os.Exit(0)
// }
if commitMessage != "" {
}
branchName := commitCommand.OtherArgs()[0]
err := clientcmd.SwitchBranch(conf, branchName)
err := clientcmd.Commit(conf, commitMessage, m)
if err != nil {
return fmt.Errorf("unable to pull branch: %s", err)
}