def run( self, installation_id, installation_token, event_type, data, pull, missing_conditions, ): LOG.debug("process merge", config=self.config, pull=pull) output = helpers.merge_report(pull) if output: return output output = helpers.output_for_mergeable_state(pull, self.config["strict"]) if output: return output if self.config["strict"] and pull.is_behind(): return self._sync_with_base_branch(pull, installation_id) else: try: return self._merge(pull, installation_id) finally: if self.config["strict"] == "smart": queue.remove_pull(pull)
def _handle_first_pull_in_queue(queue, pull): _, installation_id, owner, reponame, branch = queue.split("~") old_checks = [c for c in check_api.get_checks(pull.g_pull) if (c.name.endswith(" (merge)") and c._rawData['app']['id'] == config.INTEGRATION_ID)] merge_output = helpers.merge_report(pull) mergeable_state_output = helpers.output_for_mergeable_state(pull, True) if merge_output or mergeable_state_output: remove_pull(pull) conclusion, title, summary = merge_output or mergeable_state_output else: LOG.debug("updating base branch of pull request", pull=pull) redis = utils.get_redis_for_cache() method = redis.get(_get_update_method_cache_key(pull)) or "merge" conclusion, title, summary = helpers.update_pull_base_branch( pull, installation_id, method) if pull.g_pull.state == "closed": remove_pull(pull) elif conclusion == "failure": _move_pull_at_end(pull) status = "completed" if conclusion else "in_progress" for c in old_checks: check_api.set_check_run( pull.g_pull, c.name, status, conclusion, output={"title": title, "summary": summary})
def run(self, installation_id, installation_token, event_type, data, pull, missing_conditions): LOG.debug("process merge", config=self.config, pull=pull) output = helpers.merge_report(pull) if output: return output output = helpers.output_for_mergeable_state(pull, self.config["strict"]) if output: return output if self.config["strict"] and pull.is_behind(): # NOTE(sileht): Almost ready, one last rebase/update if not pull.base_is_modifiable(): return ("failure", "Pull request can't be updated with latest " "base branch changes, owner doesn't allow " "modification", "") elif self.config["strict"] == "smart": queue.add_pull(pull, self.config["strict_method"]) return (None, "Base branch will be updated soon", "The pull request base branch will " "be updated soon, and then merged.") else: return helpers.update_pull_base_branch( pull, installation_id, self.config["strict_method"]) else: # NOTE(sileht): Ready to merge! if self.config["strict"] == "smart": queue.remove_pull(pull) if (self.config["method"] != "rebase" or pull.g_pull.raw_data['rebaseable']): return self._merge(pull, self.config["method"]) elif self.config["rebase_fallback"]: return self._merge(pull, self.config["rebase_fallback"]) else: return ("action_required", "Automatic rebasing is not " "possible, manual intervention required", "")