Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add merge-method option #105

Merged
merged 3 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# changelog

HEAD

- Add option to set merge method (merge, squash or rebase). (Example: `mp merge --merge-method squash`)

---

2021-05-22 - v0.0.32

- Adds - `--diff` flag added to `mp plan` to show the diff of the changes made in each repo
Expand Down
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