Skip to content

Commit

Permalink
Do not set commit message on merge
Browse files Browse the repository at this point in the history
Let GitHub generate the commit message for the merge type, which
does the right thing ~all of the time.
  • Loading branch information
jvansanten committed Nov 21, 2024
1 parent 54ada45 commit 5e75d57
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 24 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ Available Commands:
Flags:
-a, --approve Pass an optional approve flag as an argument which will only approve and not merge selected repos.
--close Pass an optional argument to close a pull request.
--commit-msg string Add a custom message when approving a pull request.
-c, --config string Pass an optional config file as an argument with list of repositories.
-d, --delay int Set the value of delay, which will determine how long to wait between mergeing pull requests. Default is (6) seconds. (default 6)
-e, --enterprise-base-url string For Github Enterprise users, you can pass your enterprise base. Format: http(s)://[hostname]/
Expand Down
2 changes: 0 additions & 2 deletions pkg/cli/gomerge/gomerge.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func New() (c *cobra.Command) {
c.PersistentFlags().BoolP("close", "", false, "Pass an optional argument to close a pull request.")
c.PersistentFlags().IntP("delay", "d", 6, "Set the value of delay, which will determine how long to wait between mergeing pull requests. Default is (6) seconds.")
c.PersistentFlags().StringP("enterprise-base-url", "e", "", "For Github Enterprise users, you can pass your enterprise base. Format: http(s)://[hostname]/")
c.PersistentFlags().StringP("commit-msg", "", "", "Add a custom message when approving a pull request.")

c.MarkFlagRequired("token")

Expand All @@ -35,7 +34,6 @@ func New() (c *cobra.Command) {
viper.BindPFlag("delay", c.PersistentFlags().Lookup("delay"))
viper.BindPFlag("close", c.PersistentFlags().Lookup("close"))
viper.BindPFlag("enterprise-base-url", c.PersistentFlags().Lookup("enterprise-base-url"))
viper.BindPFlag("commit-msg", c.PersistentFlags().Lookup("commit-msg"))

c.AddCommand(list.NewCommand())
c.AddCommand(version.NewCommand())
Expand Down
1 change: 0 additions & 1 deletion pkg/cli/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func NewCommand() (c *cobra.Command) {

pullRequestsArray := []*gitclient.PullRequest{}
table := initTable()
ctx = commitMsg(ctx, viper.GetString("commit-msg"))

var org string
var repositories []string = nil
Expand Down
12 changes: 3 additions & 9 deletions pkg/gitclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,12 @@ func ApprovePullRequest(ghClient *githubv4.Client, ctx context.Context, prId git
fmt.Printf("PR %v: %v\n", prId, review.State)
}
}
func MergePullRequest(ghClient *githubv4.Client, ctx context.Context, prId githubv4.ID, mergeMethod *githubv4.PullRequestMergeMethod, skip bool) {

commitMessage := githubv4.String(defaultCommitMsg())
func MergePullRequest(ghClient *githubv4.Client, ctx context.Context, prId githubv4.ID, mergeMethod *githubv4.PullRequestMergeMethod, skip bool) {

input := githubv4.MergePullRequestInput{
PullRequestID: prId,
CommitHeadline: &commitMessage,
MergeMethod: mergeMethod,
PullRequestID: prId,
MergeMethod: mergeMethod,
}

var m struct {
Expand Down Expand Up @@ -255,10 +253,6 @@ func ClosePullRequest(ghClient *githubv4.Client, ctx context.Context, prId githu

}

func defaultCommitMsg() string {
return "Merged by gomerge CLI."
}

func DefaultApproveMsg() string {
return `PR has been approved by [GoMerge](https://github.com/Cian911/gomerge) tool. :rocket:`
}
11 changes: 0 additions & 11 deletions pkg/gitclient/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ import (
"testing"
)

func TestDefaultCommitMsg(t *testing.T) {
t.Run("It returns a default commit message", func(t *testing.T) {
got := defaultCommitMsg()
want := "Merged by gomerge CLI."

if got != want {
t.Errorf("got %s, want %s", got, want)
}
})
}

func TestDefaultApproveMsg(t *testing.T) {
t.Run("It returns a default approve message.", func(t *testing.T) {
got := DefaultApproveMsg()
Expand Down

0 comments on commit 5e75d57

Please sign in to comment.