From 53b7c05701167dfe59f2d1a98385eec32fd6ab7b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 28 May 2020 13:27:34 +0200 Subject: [PATCH] [IMP] runbot_merge: drop merge method on squash When moving from !squash to squash to !squash, it's a bit odd / risky to keep the merge method as-is. So drop it. --- runbot_merge/models/pull_requests.py | 3 +++ runbot_merge/tests/test_basic.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index 3dca4dcc..fd03822b 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -1055,6 +1055,9 @@ class PullRequests(models.Model): def write(self, vals): oldstate = { pr: pr._tagstate for pr in self } + if vals.get('squash'): + vals['merge_method'] = False + w = super().write(vals) newhead = vals.get('head') diff --git a/runbot_merge/tests/test_basic.py b/runbot_merge/tests/test_basic.py index 3a1e4b53..18112be6 100644 --- a/runbot_merge/tests/test_basic.py +++ b/runbot_merge/tests/test_basic.py @@ -1269,6 +1269,7 @@ class TestMergeMethod: ('repository.name', '=', repo.name), ('number', '=', prx.number), ]) + pr.merge_method = 'rebase-merge' assert not pr.squash, "a PR with a single commit should not be squashed" with repo: @@ -1278,6 +1279,8 @@ class TestMergeMethod: force=True ) assert pr.squash, "a PR with a single commit should be squashed" + assert not pr.merge_method, \ + "resetting a PR to a single commit should remove the merge method" def test_pr_no_method(self, repo, env, users, config): """ a multi-repo PR should not be staged by default, should also get