Skip to content

Commit e1b8081

Browse files
committed
close #90 wrapup should taken an additional comment
1 parent 7e97849 commit e1b8081

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

cmd/wrapup.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55

66
"github.com/praqma/git-phlow/cmd/cmdperm"
7+
"github.com/praqma/git-phlow/options"
78
"github.com/praqma/git-phlow/phlow"
89
"github.com/praqma/git-phlow/ui"
910
"github.com/spf13/cobra"
@@ -13,7 +14,8 @@ var wrapupCmd = &cobra.Command{
1314
Use: "wrapup",
1415
Short: "Add changes to index and auto commit",
1516
Long: fmt.Sprintf(`
16-
%s commits the currently staged files with a 'close issue' commit message, e.g. "close #42 fetch meaning of life". The commit message will cause the corresponding issue to be closed when the commit is integrated.
17+
%s commits the currently staged files with a 'close issue' commit message, e.g. "close #42 fetch meaning of life". The commit message will cause the corresponding issue to be closed when the commit is integrated. When force is used on the message, the message will replace, the otherwice automatically generated commit message.
18+
1719
`, ui.Format.Bold("wrapup")),
1820
PreRun: func(cmd *cobra.Command, args []string) {
1921
cmdperm.RequiredCurDirRepository()
@@ -25,4 +27,6 @@ var wrapupCmd = &cobra.Command{
2527

2628
func init() {
2729
RootCmd.AddCommand(wrapupCmd)
30+
31+
wrapupCmd.Flags().StringVar(&options.GlobalFlagForceMessage, "force", "", "use a custom commit message in stead")
2832
}

options/option.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ var (
2929
//GlobalFlagPrefixForReady ...
3030
GlobalFlagPrefixForReady string
3131

32+
//GlobalFlagForce ...
33+
GlobalFlagForceMessage string
34+
3235
//Sha1 git commit hash
3336
Sha1 string
3437

phlow/wrapup.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88

99
"github.com/praqma/git-phlow/githandler"
10+
"github.com/praqma/git-phlow/options"
1011
)
1112

1213
//WrapUp ...
@@ -20,11 +21,17 @@ func WrapUp() {
2021

2122
//Retrieve branch info - current branch
2223
info, _ := githandler.Branch()
23-
commitMessage := "close #" + strings.Replace(info.Current, "-", " ", -1)
24+
var cmsg string
2425

25-
if _, err := githandler.Commit(commitMessage); err != nil {
26+
if options.GlobalFlagForceMessage != "" {
27+
cmsg = "close #" + strings.Split(info.Current, "-")[0] + " " + options.GlobalFlagForceMessage
28+
} else {
29+
cmsg = "close #" + strings.Replace(info.Current, "-", " ", -1)
30+
}
31+
32+
if _, err := githandler.Commit(cmsg); err != nil {
2633
fmt.Println("Nothing to commit!")
2734
return
2835
}
29-
fmt.Fprintln(os.Stdout, commitMessage)
36+
fmt.Fprintln(os.Stdout, cmsg)
3037
}

0 commit comments

Comments
 (0)