diff --git a/cmd/merge.go b/cmd/merge.go index fdf8a14..d1199c4 100644 --- a/cmd/merge.go +++ b/cmd/merge.go @@ -19,6 +19,7 @@ import ( var mergeFlagThrottle string var mergeFlagIgnoreReviewApproval bool var mergeFlagIgnoreBuildStatus bool +var mergeMethod string // rate limits the # of PR merges. used to prevent load on CI system var mergeThrottle *time.Ticker @@ -92,6 +93,7 @@ func mergeOneRepo(r lib.Repo, ctx context.Context) error { CommitSHA: pushOutput.CommitSHA, RequireReviewApproval: !mergeFlagIgnoreReviewApproval, RequireBuildSuccess: !mergeFlagIgnoreBuildStatus, + MergeMethod: mergeMethod, } var output merge.Output if r.IsGitlab() { diff --git a/cmd/root.go b/cmd/root.go index e7d2786..d0aa497 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -34,6 +34,7 @@ func init() { mergeCmd.Flags().StringVarP(&mergeFlagThrottle, "throttle", "t", "30s", "Throttle number of merges, e.g. '30s' means 1 merge per 30 seconds") mergeCmd.Flags().BoolVar(&mergeFlagIgnoreReviewApproval, "ignore-review-approval", false, "Ignore whether or not the review has been approved") mergeCmd.Flags().BoolVar(&mergeFlagIgnoreBuildStatus, "ignore-build-status", false, "Ignore whether or not builds are passing") + mergeCmd.Flags().StringVarP(&mergeMethod, "merge-method", "m", "merge", "Merge method to use. Possible values include: merge, squash, and rebase") rootCmd.AddCommand(planCmd) planCmd.Flags().StringVarP(&planFlagBranch, "branch", "b", "", "Git branch to commit to") diff --git a/merge/merge.go b/merge/merge.go index 5780e74..36668d6 100644 --- a/merge/merge.go +++ b/merge/merge.go @@ -23,6 +23,8 @@ type Input struct { RequireReviewApproval bool // RequireBuildSuccess specifies if the PR must have a successful build before merging RequireBuildSuccess bool + // Merge method to use. Possible values include: "merge", "squash", and "rebase" + MergeMethod string } // Output from Push() @@ -95,7 +97,9 @@ func GitHubMerge(ctx context.Context, input Input, repoLimiter *time.Ticker, mer } // Merge the PR - options := &github.PullRequestOptions{} + options := &github.PullRequestOptions{ + MergeMethod: input.MergeMethod, + } commitMsg := "" <-mergeLimiter.C <-repoLimiter.C