X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=changelog.py;h=a6bf2afbc6ee8db6d28e1fa194400fc46bf90584;hb=40e89c41844d8f181087b855307554d77d8ea1d4;hp=91a0c26134b129f9308debb9bc0eed8cfd376e88;hpb=8fcb8ae5a964a07f73a84436f8c79278abbdeb6d;p=icinga2 diff --git a/changelog.py b/changelog.py index 91a0c2613..a6bf2afbc 100755 --- a/changelog.py +++ b/changelog.py @@ -8,6 +8,10 @@ import sys import os from datetime import datetime from collections import defaultdict +from collections import OrderedDict + +################################# +## Env Config try: github_auth_username = os.environ['ICINGA_GITHUB_AUTH_USERNAME'] @@ -27,10 +31,34 @@ except: print "ERROR: Environment variable 'ICINGA_GITHUB_PROJECT' is not set." sys.exit(1) +################################# +## Config + changelog_file = "CHANGELOG.md" # TODO: config param debug = 1 -ignored_labels = ["high", "low", "bug", "enhancement", "feedback", "question", "backported"] +# Keep this in sync with GitHub labels. +ignored_labels = [ + "high-priority", "low-priority", + "bug", "enhancement", + "needs-feedback", "question", "duplicate", "invalid", "wontfix", + "backported", "build-fix" +] + +# Selectively show and collect specific categories +# +# (category, list of case sensitive matching labels) +# The order is important! +# Keep this in sync with GitHub labels. +categories = OrderedDict( +[ + ("Enhancement", ["enhancement"]), + ("Bug", ["bug", "crash"]), + ("ITL", ["ITL"]), + ("Documentation", ["Documentation"]), + ("Support", ["code-quality", "Tests", "Packages", "Installation"]) +] +) ################################# ## Helpers @@ -74,12 +102,17 @@ def fetch_github_resources(uri, params = {}): return resources def issue_type(issue): - if "bug" in [label["name"] for label in issue["labels"]]: - return "Bug" - elif "enhancement" in [label["name"] for label in issue["labels"]]: - return "Enhancement" - else: - return "Support" + issue_labels = [label["name"] for label in issue["labels"]] + + # start with the least important first (e.g. "Support", "Documentation", "Bug", "Enhancement" as order) + for category in reversed(categories): + labels = categories[category] + + for label in labels: + if label in issue_labels: + return category + + return "Support" def escape_markdown(text): #tmp = text.replace('&', '&').replace('<', '<').replace('>', '>') @@ -91,6 +124,10 @@ def escape_markdown(text): def format_labels(issue): labels = filter(lambda label: label not in ignored_labels, [label["name"] for label in issue["labels"]]) + # Mark PRs as custom label + if "pull_request" in issue: + labels.append("PR") + if len(labels): return " (" + ", ".join(labels) + ")" else: @@ -115,7 +152,6 @@ def format_title(title): milestones = {} issues = defaultdict(lambda: defaultdict(list)) -project_name = "icinga2" log(1, "Fetching data from GitHub API for project " + project_name) @@ -153,6 +189,7 @@ for issue in cached_issues: #fetch_github_resources("/issues", { "state": "all" ms_tickets = issues[ms_title][issue_type(issue)] ms_tickets.append(issue) +# TODO: Generic header based on project_name write_changelog("# Icinga 2.x CHANGELOG") write_changelog("") @@ -175,7 +212,7 @@ for milestone in sorted(milestones.values(), key=lambda ms: (ms["due_on"], ms["t if len(ms_description) > 0: write_changelog("### Notes\n\n" + ms_description + "\n") # Don't escape anything, we take care on Github for valid Markdown - for category in ["Enhancement", "Bug", "Support"]: + for category, labels in categories.iteritems(): try: ms_issues = issues[milestone["title"]][category] except KeyError: