dailymotion-oss / octopilot

Automate your Gitops workflow, by automatically creating/merging GitHub Pull Requests
https://dailymotion-oss.github.io/octopilot/
MIT License
173 stars 23 forks source link

Add dynamic/smart `--pr-merge-method` (trying several methods) #281

Open MPV opened 11 months ago

MPV commented 11 months ago

As it's possible to select which kinds of methods for "merging" a PR is allowed, i.e. any/all of these:

Thus one can run into problems such as this one (if a repo has disallowed "merge commits"):

failed to merge Pull Request https://github.com/my-org/my-repo/pull/310: PUT https://api.github.com/repos/my-org/my-repo/pulls/310/merge: 405 Merge commits are not allowed on this repository. []" repository=my-org/my-repo

Full log row: time="2023-11-20T10:39:22Z" level=error msg="Repository update failed" error="failed to merge Pull Request https://github.com/my-org/my-repo/pull/310: failed to merge Pull Request https://github.com/my-org/my-repo/pull/310: PUT https://api.github.com/repos/my-org/my-repo/pulls/310/merge: 405 Merge commits are not allowed on this repository. []" repository=my-org/my-repo

Showing on the PR like this in the web UI:

Skärmavbild 2023-11-20 kl  11 46 39

But it's only possible to select one to try with, as per:

--pr-merge-method (string): the merge method to use. Either merge, squash, or rebase. Default to merge.

-- https://dailymotion-oss.github.io/octopilot/v1.5.3/index.html#merging-pull-requests

...and in an organization with hundreds/thousands or repositories it might not be feasible to know/decide with merge method is allowed on the repos 🙈.


Hence I'd like to suggest we add either:

  1. a "smart/auto" --pr-merge-method (which tries all of them, in some kind of order)
  2. --pr-merge-methods with a list (of the ones to try, and in which order)
  3. allow passing a list to --pr-merge-methods (ditto)
vbehar commented 11 months ago

thanks, nice idea! I'll have a look at implementing it, I think with a list of methods, and trying each one until one works - or everything fail