diff --git a/cfg.sample.toml b/cfg.sample.toml index 43fc1cd6..49b80de6 100644 --- a/cfg.sample.toml +++ b/cfg.sample.toml @@ -44,6 +44,13 @@ try_users = [] # Auto-squash commits. Requires the local Git command #autosquash = true +# Whether homu should push a temporary merge commit that causes +# github to think the PR was merged. You need to disable this if +# you have branch protection enabled. Also, leaving this enabled +# means that other people pulling master might transiently see +# the merge commit. +#linear_fake_merge = true + ## branch names (these settings here are the defaults) #[repo.NAME.branch] # diff --git a/homu/main.py b/homu/main.py index a0f0f703..05ce7e18 100644 --- a/homu/main.py +++ b/homu/main.py @@ -214,7 +214,12 @@ def refresh(self): self.body = issue.body def fake_merge(self, repo_cfg): - if repo_cfg.get('linear', False) or repo_cfg.get('autosquash', False): + is_linear_or_autosquash = repo_cfg.get('linear', False) or repo_cfg.get('autosquash', False) + # Backwards compat, though I think this is a terrible default. + fake_merge = repo_cfg.get('linear_fake_merge', True) + if not is_linear_or_autosquash: + return + if fake_merge: msg = '''!!! Temporary commit !!! This commit is artifically made up to mark PR {} as merged. @@ -238,6 +243,16 @@ def fail(err): self.get_issue().close() utils.retry_until(inner, fail, self) + else: + issue = self.get_issue() + title = issue.title + # So unfortunately, we can't yet tell github this PR was + # merged. We need to rework things so that our last + # comment at least includes a link to the master commit. + merged_prefix = '[merged] ' + if not title.startswith(merged_prefix): + title = merged_prefix + title + issue.edit(title=title, state='closed') def sha_cmp(short, full): return len(short) >= 4 and short == full[:len(short)]