Skip to content

Commit 683eb7b

Browse files
authored
Merge pull request #253 from achilleas-k/commit-message
LGTM
2 parents 5c7d971 + 52f39bf commit 683eb7b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gincmd/commitcmd.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ func commit(cmd *cobra.Command, args []string) {
1818
Die(ginerrors.NotInRepo)
1919
}
2020

21+
commitmsg, _ := cmd.Flags().GetString("message")
22+
2123
// TODO: Exit with error if a path argument is neither a file known to git nor a file in the working tree
2224
paths := args
2325
if len(paths) > 0 {
@@ -32,7 +34,10 @@ func commit(cmd *cobra.Command, args []string) {
3234
if prStyle == psDefault {
3335
fmt.Print(":: Recording changes ")
3436
}
35-
err := git.Commit(makeCommitMessage("commit", paths))
37+
if commitmsg == "" {
38+
commitmsg = makeCommitMessage("commit", paths)
39+
}
40+
err := git.Commit(commitmsg)
3641
var stat string
3742
if err != nil {
3843
if err.Error() == "Nothing to commit" {
@@ -69,14 +74,15 @@ func CommitCmd() *cobra.Command {
6974
description := "Record changes made in a local repository. This command must be called from within the local repository clone. Specific files or directories may be specified. All changes made to the files and directories that are specified will be recorded, including addition of new files, modifications and renaming of existing files, and file deletions.\n\nIf no arguments are specified, no changes are recorded."
7075
args := map[string]string{"<filenames>": "One or more directories or files to commit."}
7176
var cmd = &cobra.Command{
72-
Use: "commit [--json | --verbose] [<filenames>]...",
77+
Use: "commit [--json | --verbose] [--message message] [<filenames>]...",
7378
Short: "Record changes in local repository",
7479
Long: formatdesc(description, args),
7580
Args: cobra.ArbitraryArgs,
7681
Run: commit,
7782
DisableFlagsInUseLine: true,
7883
}
7984
cmd.Flags().Bool("json", false, jsonHelpMsg)
85+
cmd.Flags().StringP("message", "m", "", "Commit message")
8086
// cmd.Flags().Bool("verbose", false, verboseHelpMsg)
8187
return cmd
8288
}

0 commit comments

Comments
 (0)