Skip to content

Commit

Permalink
feat: Add merge-method option
Browse files Browse the repository at this point in the history
  • Loading branch information
simenandre committed Aug 7, 2021
1 parent 0acfbe8 commit c7e05e2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 5 additions & 1 deletion merge/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c7e05e2

Please sign in to comment.