Skip to content

Commit

Permalink
fix: commit always run even info is not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
kamontat committed Sep 25, 2019
1 parent cbe9911 commit 7e834ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions cmd/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package cmd

import (
e "github.com/kamontat/gitgo/exception"
"github.com/kamontat/gitgo/model"
"github.com/kamontat/gitgo/util"
"github.com/spf13/viper"
Expand All @@ -46,12 +47,14 @@ var commitCmd = &cobra.Command{

keyQuestion, validates := util.GenerateQuestionViaTypeConfig("Please enter commit type", config.Key, listYAML)
if keyQuestion != nil {
survey.AskOne(keyQuestion, &commitMessage.Type, validates...)
err := survey.AskOne(keyQuestion, &commitMessage.Type, validates...)
e.Error(e.IsCommit, err).ShowMessage().Exit()
}

scopeQuestion, validates := util.GenerateQuestionViaTypeConfig("Please enter commit scope", config.Scope, listYAML)
if scopeQuestion != nil {
survey.AskOne(scopeQuestion, &commitMessage.Scope, validates...)
err := survey.AskOne(scopeQuestion, &commitMessage.Scope, validates...)
e.Error(e.IsCommit, err).ShowMessage().Exit()
}

titleQuestion, validates := util.GenerateQuestionViaTypeConfig("Please enter commit title", config.Title, listYAML)
Expand All @@ -61,7 +64,8 @@ var commitCmd = &cobra.Command{

messageQuestion, validates := util.GenerateQuestionViaTypeConfig("Please enter commit message", config.Message, listYAML)
if messageQuestion != nil {
survey.AskOne(messageQuestion, &commitMessage.Message, validates...)
err := survey.AskOne(messageQuestion, &commitMessage.Message, validates...)
e.Error(e.IsCommit, err).ShowMessage().Exit()
}

commit := repo.GetCommit()
Expand Down
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var repo *model.Repo
var debug bool
var verbose bool

var version = "4.0.0-beta.2"
var version = "4.0.0-beta.3"

// rootCmd represents the base command when called without any subcommands.
var rootCmd = &cobra.Command{
Expand All @@ -55,6 +55,7 @@ This command create by golang with cobra cli.
Motivation by gitmoji and GitFlow,
Force everyone to create the exect same templates of commit and branch
4.0.0-beta.3 - fix commit always call git commit even prompt was exited
4.0.0-beta.2 - refactor how configuration will be loaded
and add more key to configable
4.0.0-beta.1 - remove global configuration settings;
Expand Down

0 comments on commit 7e834ee

Please sign in to comment.