Skip to content

Commit

Permalink
feat: allows navigate and edit the commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanCapistrano committed Jul 20, 2023
1 parent 91f92e9 commit 3327fea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
14 changes: 3 additions & 11 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Copyright © 2023 Allan Capistrano <allan.capistrano3@gmail.com>
package cmd

import (
"bufio"
"fmt"
"os"
"os/exec"
Expand All @@ -14,6 +13,7 @@ import (
"github.com/spf13/cobra"

"github.com/allancapistrano/gbc/config"
"github.com/allancapistrano/user-input"
)

const GBC_VERSION = "1.0.0"
Expand Down Expand Up @@ -116,23 +116,15 @@ simple way to write commits following the Conventional Commits
)
}

buffer := bufio.NewReader(os.Stdin)

fmt.Print("What commit message do you want? ")

commitMessage, err := buffer.ReadString('\n')
if err != nil {
fmt.Println("Unable to read commit message! Try again.")
os.Exit(0)
}
commitMessage := userinput.GetUserInput("What commit message do you want? ", true)

commandString := fmt.Sprintf(
`git commit -m "%s: %s"`, commitType, commitMessage,
)

command := exec.Command("/bin/bash", "-c", commandString)

err = command.Run()
err := command.Run()
if err != nil {
fmt.Println(
"\nCould not create the commit! Make sure you have files to commit.",
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ module github.com/allancapistrano/gbc
go 1.20

require (
github.com/allancapistrano/user-input v1.1.1
github.com/kyokomi/emoji/v2 v2.2.12
github.com/nexidian/gocliselect v1.0.0
github.com/spf13/cobra v1.7.0
)

require (
github.com/buger/goterm v1.0.4 // indirect
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/pkg/term v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
)
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
github.com/allancapistrano/user-input v1.1.1 h1:9j/3qLHHl9hLkBXZLJwGqsa8p/9FWMcaiZYWX6PgHns=
github.com/allancapistrano/user-input v1.1.1/go.mod h1:Pq0pSXYv417hEe2Bha44qY/Z1xm36Au0NhowDWpo2ak=
github.com/buger/goterm v1.0.4 h1:Z9YvGmOih81P0FbVtEYTFF6YsSgxSUKEhf/f9bTMXbY=
github.com/buger/goterm v1.0.4/go.mod h1:HiFWV3xnkolgrBV3mY8m0X0Pumt4zg4QhbdOzQtB8tE=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203 h1:XBBHcIb256gUJtLmY22n99HaZTz+r2Z51xUPi01m3wg=
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203/go.mod h1:E1jcSv8FaEny+OP/5k9UxZVw9YFWGj7eI4KR/iOBqCg=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/kyokomi/emoji/v2 v2.2.12 h1:sSVA5nH9ebR3Zji1o31wu3yOwD1zKXQA2z0zUyeit60=
Expand All @@ -16,7 +20,7 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744 h1:KzbpndAYEM+4oHRp9JmB2ewj0NHHxO3Z0g7Gus2O1kk=
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit 3327fea

Please sign in to comment.