From 5ca938015adf0b2e36eb70bc960f583770608160 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 11 Dec 2019 20:40:00 +0100 Subject: [PATCH] tools: Fix changelog script to be case insensitive and support auth --- devtools/changelog.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/devtools/changelog.py b/devtools/changelog.py index c3a1b6204..de731e24b 100755 --- a/devtools/changelog.py +++ b/devtools/changelog.py @@ -1,13 +1,14 @@ #!/usr/bin/env python3 from collections import namedtuple +from datetime import datetime +from mako.template import Template +import argparse +import os import re -import sys +import requests import shlex import subprocess -import requests -from mako.template import Template -import argparse -from datetime import datetime +import sys # What sections do we support in the changelog: sections = [ @@ -49,7 +50,7 @@ def get_log_entries(commitrange): commit = m.group(1) m = re.match( - r'^\s+Changelog-({}): (.*)$'.format("|".join(sections)), l) + r'^\s+Changelog-({}): (.*)$'.format("|".join(sections)), l, re.IGNORECASE) if not m: continue @@ -58,6 +59,9 @@ def get_log_entries(commitrange): 'Accept': 'application/vnd.github.groot-preview+json', } + if os.environ.get('GH_TOKEN'): + headers['Authorization'] = 'token ' + os.environ.get('GH_TOKEN') + url = 'https://api.github.com/repos/{repo}/commits/{commit}/pulls'.format(repo=repo, commit=commit) content = requests.get(url, headers=headers).json() if len(content): @@ -65,7 +69,7 @@ def get_log_entries(commitrange): else: pullreq = None - e = Entry(commit, pullreq, m.group(2), m.group(1)) + e = Entry(commit, pullreq, m.group(2), m.group(1).lower()) entries.append(e) return entries