コード例 #1
0
    async def get_queue_status(
        self,
        ctxt: context.Context,
        rule: "rules.EvaluatedRule",
        q: queue.QueueBase,
        is_behind: bool = False,
    ) -> check_api.Result:

        summary = ""
        if self.config["strict"] in (
            StrictMergeParameter.fasttrack,
            StrictMergeParameter.ordered,
        ):
            position = await q.get_position(ctxt)
            if position is None:
                ctxt.log.error("expected queued pull request not found in queue")
                title = "The pull request is queued to be merged"
            else:
                _ord = utils.to_ordinal_numeric(position + 1)
                title = f"The pull request is the {_ord} in the queue to be merged"

            if is_behind:
                summary = "The pull request base branch will be updated before being merged.\n\n"

        elif self.config["strict"] is not StrictMergeParameter.false and is_behind:
            title = "The pull request will be updated with its base branch soon"
        else:
            title = "The pull request will be merged soon"

        summary += await self._get_queue_summary(ctxt, rule, q)

        return check_api.Result(check_api.Conclusion.PENDING, title, summary)
コード例 #2
0
    def get_strict_status(
        self,
        ctxt: context.Context,
        rule: "rules.EvaluatedRule",
        q: queue.Queue,
        is_behind: bool = False,
    ) -> check_api.Result:

        summary = ""
        if self.config["strict"] in ("smart+fasttrack", "smart+ordered"):
            position = q.get_position(ctxt)
            if position is None:
                ctxt.log.error("expected queued pull request not found in queue")
                title = "The pull request is queued to be merged"
            else:
                ord = utils.to_ordinal_numeric(position)
                title = f"The pull request is the {ord} in the queue to be merged"

            if is_behind:
                summary = "\nThe pull request base branch will be updated before being merged."

        elif self.config["strict"] and is_behind:
            title = "The pull request will be updated with its base branch soon"
        else:
            title = "The pull request will be merged soon"

        summary += self.get_queue_summary(ctxt, q)
        conditions, missing_conditions = self.get_merge_conditions(ctxt, rule)

        summary += "\n\nRequired conditions for merge:\n"
        for cond in conditions:
            checked = " " if cond in missing_conditions else "X"
            summary += f"\n- [{checked}] `{cond}`"

        return check_api.Result(check_api.Conclusion.PENDING, title, summary)
コード例 #3
0
ファイル: queue.py プロジェクト: CamClrt/mergify-engine
    async def get_queue_status(
        self,
        ctxt: context.Context,
        rule: "rules.EvaluatedRule",
        q: typing.Optional[queue.QueueBase],
        qf: typing.Optional[freeze.QueueFreeze] = None,
    ) -> check_api.Result:
        if q is None:
            title = "The pull request will be merged soon"
        elif qf is not None:
            title = f'The queue "{qf.name}" is currently frozen, for the following reason: {qf.reason}'
        else:
            position = await q.get_position(ctxt)
            if position is None:
                ctxt.log.error(
                    "expected queued pull request not found in queue")
                title = "The pull request is queued to be merged"
            else:
                _ord = utils.to_ordinal_numeric(position + 1)
                title = f"The pull request is the {_ord} in the queue to be merged"

        summary = await typing.cast(merge_train.Train,
                                    q).get_pull_summary(ctxt, self.queue_rule)
        return check_api.Result(check_api.Conclusion.PENDING, title, summary)
コード例 #4
0
def test_to_ordinal_numeric():
    with pytest.raises(ValueError):
        utils.to_ordinal_numeric(-1)

    assert utils.to_ordinal_numeric(0) == "0th"
    assert utils.to_ordinal_numeric(100) == "100th"
    assert utils.to_ordinal_numeric(1) == "1st"
    assert utils.to_ordinal_numeric(11) == "11st"
    assert utils.to_ordinal_numeric(2) == "2nd"
    assert utils.to_ordinal_numeric(42) == "42nd"
    assert utils.to_ordinal_numeric(6543512) == "6543512nd"
    assert utils.to_ordinal_numeric(3) == "3rd"
    assert utils.to_ordinal_numeric(5743) == "5743rd"
    for i in range(4, 10):
        assert utils.to_ordinal_numeric(i) == f"{i}th"

    assert utils.to_ordinal_numeric(4567) == "4567th"
    assert utils.to_ordinal_numeric(5743) == "5743rd"