Example #1
0
    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", "")
Example #2
0
 def _sync_with_base_branch(self, pull):
     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, self.config["strict_method"])