From 329c19ebd51e0285ac8a023f70ca944a555858a1 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 3 Aug 2020 14:15:56 +0300 Subject: [PATCH] Fix bugs in milestone aggregation --- base-config.yaml | 11 ++++++----- github/webhook/aggregation.py | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/base-config.yaml b/base-config.yaml index 8632842..f33bd06 100644 --- a/base-config.yaml +++ b/base-config.yaml @@ -83,8 +83,8 @@ macros: > {% endif %} {%- endmacro -%} - {%- macro milestone_link(milestone) -%} - milestone {{ milestone.title|e }} + {%- macro milestone_link(milestone, text=True) -%} + {% if text %}milestone {% endif %}{{ milestone.title|e }} {%- endmacro -%} {%- macro repo_link(repo, important=True) -%} @@ -140,12 +140,12 @@ messages: {% elif action == X_LABEL_AGGREGATE %} {{ templates.label_aggregation }} {% elif action == MILESTONED %} added {{ templates.issue_link }} to {{ milestone_link(milestone) }} {% elif action == DEMILESTONED %} removed {{ templates.issue_link }} from {{ milestone_link(milestone) }} - {% elif action == X_MILESTONE_CHANGED %} moved {{ templates.issue_link }} from {{ milestone_link(aggregation.from) }} to {{ milestone_link(aggregation.to) }} + {% elif action == X_MILESTONE_CHANGED %} moved {{ templates.issue_link }} from {{ milestone_link(aggregation.from) }} to {{ milestone_link(aggregation.to, text=False) }} {% elif action == ASSIGNED %} assigned {{ user_link(assignee) }} to {% elif action == UNASSIGNED %} unassigned {{ user_link(assignee) }} from {% else %} {{ action }} {% endif %} - {% if action not in (OPENED, MILESTONED, DEMILESTONED) %} + {% if action not in (OPENED, MILESTONED, DEMILESTONED, X_MILESTONE_CHANGED) %} {{ templates.issue_link }} {% endif %} @@ -165,6 +165,7 @@ messages: {% elif action == X_LABEL_AGGREGATE %} {{ templates.label_aggregation }} {% elif action == MILESTONED %} added {{ templates.pr_link }} to {{ milestone_link(milestone) }} {% elif action == DEMILESTONED %} removed {{ templates.pr_link }} from {{ milestone_link(milestone) }} + {% elif action == X_MILESTONE_CHANGED %} moved {{ templates.pr_link }} from {{ milestone_link(aggregation.from) }} to {{ milestone_link(aggregation.to, text=False) }} {% elif action == ASSIGNED %} assigned {{ personal_link(requested_reviewer) }} to {% elif action == UNASSIGNED %} unassigned {{ personal_link(requested_reviewer) }} from {% elif action == REVIEW_REQUESTED %} @@ -178,7 +179,7 @@ messages: {% elif action == READY_FOR_REVIEW %} marked {{ templates.pr_link }} as ready for review {% else %} {{ action }} {% endif %} - {% if action not in (OPENED, MILESTONED, DEMILESTONED, READY_FOR_REVIEW) %} + {% if action not in (OPENED, MILESTONED, DEMILESTONED, X_MILESTONE_CHANGED, READY_FOR_REVIEW) %} {{ templates.pr_link }} {% endif %} diff --git a/github/webhook/aggregation.py b/github/webhook/aggregation.py index a2cc951..20431f6 100644 --- a/github/webhook/aggregation.py +++ b/github/webhook/aggregation.py @@ -164,6 +164,7 @@ def aggregate(self, evt_type: EventType, evt: Event, delivery_id: str) -> bool: self.aggregation["from"] = evt.milestone else: return False + self.event.action = self.action_type.X_MILESTONE_CHANGED postpone = False else: return False