Browse Source

tools: Fix changelog script to be case insensitive and support auth

travis-debug
Christian Decker 5 years ago
parent
commit
5ca938015a
  1. 18
      devtools/changelog.py

18
devtools/changelog.py

@ -1,13 +1,14 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from collections import namedtuple from collections import namedtuple
from datetime import datetime
from mako.template import Template
import argparse
import os
import re import re
import sys import requests
import shlex import shlex
import subprocess import subprocess
import requests import sys
from mako.template import Template
import argparse
from datetime import datetime
# What sections do we support in the changelog: # What sections do we support in the changelog:
sections = [ sections = [
@ -49,7 +50,7 @@ def get_log_entries(commitrange):
commit = m.group(1) commit = m.group(1)
m = re.match( m = re.match(
r'^\s+Changelog-({}): (.*)$'.format("|".join(sections)), l) r'^\s+Changelog-({}): (.*)$'.format("|".join(sections)), l, re.IGNORECASE)
if not m: if not m:
continue continue
@ -58,6 +59,9 @@ def get_log_entries(commitrange):
'Accept': 'application/vnd.github.groot-preview+json', '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) url = 'https://api.github.com/repos/{repo}/commits/{commit}/pulls'.format(repo=repo, commit=commit)
content = requests.get(url, headers=headers).json() content = requests.get(url, headers=headers).json()
if len(content): if len(content):
@ -65,7 +69,7 @@ def get_log_entries(commitrange):
else: else:
pullreq = None 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) entries.append(e)
return entries return entries

Loading…
Cancel
Save