Skip to content

Commit 1a7ffb6

Browse files
committed
fix: only propagate bool flags if set.
Resolves #45.
1 parent 70ac15d commit 1a7ffb6

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

cmd/cli.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ func getGitCommitCmd(cmd *cobra.Command) []string {
3333
message, _ := cmd.Flags().GetStringArray("message")
3434
flags := cmd.Flags()
3535
for _, name := range boolFlags {
36-
flag, _ := flags.GetBool(name)
37-
if flag {
38-
commitCmd = append(commitCmd, "--"+name)
36+
if flags.Lookup(name).Changed {
37+
flag, err := flags.GetBool(name)
38+
if err == nil && flag {
39+
commitCmd = append(commitCmd, "--"+name)
40+
}
3941
}
4042
}
4143
if noEdit || len(message) > 0 {
@@ -299,6 +301,7 @@ func init() {
299301
flags.BoolP("all", "a", false, "see the git-commit docs for --all|-a")
300302
flags.BoolP("signoff", "s", false, "see the git-commit docs for --signoff|-s")
301303
flags.Bool("no-gpg-sign", false, "see the git-commit docs for --no-gpg-sign")
304+
// FIXME: gpg-sign
302305
flags.Bool("no-post-rewrite", false, "Bypass the post-rewrite hook")
303306
flags.Bool("no-edit", false, "Use the selected commit message without launching an editor.")
304307
flags.BoolP("no-verify", "n", false, "Bypass git hooks")
@@ -313,6 +316,9 @@ func init() {
313316
)
314317
flags.Bool("init", false, "initialize a config file if none is present")
315318
flags.String("config-format", "yaml", "The format of the config file to generate. One of: toml, yml, yaml")
319+
320+
Cmd.MarkFlagsMutuallyExclusive("signoff", "no-signoff")
321+
Cmd.MarkFlagsMutuallyExclusive("verify", "no-verify")
316322
}
317323
// { // flags for git-cc init
318324
// flags := initCmd.Flags()

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/charmbracelet/bubbletea v0.22.1
1010
github.com/muesli/reflow v0.3.0
1111
github.com/muesli/termenv v0.13.0
12-
github.com/spf13/cobra v1.7.0
12+
github.com/spf13/cobra v1.9.1
1313
github.com/wk8/go-ordered-map/v2 v2.1.5
1414
gopkg.in/yaml.v3 v3.0.1
1515
)
@@ -20,7 +20,7 @@ require (
2020
github.com/buger/jsonparser v1.1.1 // indirect
2121
github.com/charmbracelet/lipgloss v0.5.0 // indirect
2222
github.com/containerd/console v1.0.3 // indirect
23-
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
23+
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
2424
github.com/davecgh/go-spew v1.1.1 // indirect
2525
github.com/inconshreveable/mousetrap v1.1.0 // indirect
2626
github.com/kr/text v0.2.0 // indirect
@@ -35,7 +35,7 @@ require (
3535
github.com/pmezard/go-difflib v1.0.0 // indirect
3636
github.com/rivo/uniseg v0.2.0 // indirect
3737
github.com/russross/blackfriday/v2 v2.1.0 // indirect
38-
github.com/spf13/pflag v1.0.5 // indirect
38+
github.com/spf13/pflag v1.0.6 // indirect
3939
github.com/stretchr/testify v1.8.1 // indirect
4040
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
4141
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ github.com/charmbracelet/lipgloss v0.5.0 h1:lulQHuVeodSgDez+3rGiuxlPVXSnhth442DA
1818
github.com/charmbracelet/lipgloss v0.5.0/go.mod h1:EZLha/HbzEt7cYqdFPovlqy5FZPj0xFhg5SaqxScmgs=
1919
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
2020
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
21-
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
22-
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
21+
github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0=
22+
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
2323
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
2424
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2525
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -68,10 +68,10 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
6868
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
6969
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
7070
github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
71-
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
72-
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
73-
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
74-
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
71+
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
72+
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
73+
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
74+
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
7575
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
7676
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
7777
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=

0 commit comments

Comments
 (0)