]>
git.ipfire.org Git - thirdparty/pdns.git/blob - build-scripts/changelog-from-pr.py
9 argp
= argparse
.ArgumentParser()
10 argp
.add_argument('--oneline', action
='store_true',
11 help='Make one-lined changelog entries (for 4.0 and older)')
12 argp
.add_argument('--username',
13 help='Use the specified username for Basic Authentication to the GitHub API, allowing an higher rate limit')
14 argp
.add_argument('pullrequest', metavar
='PULL_REQUEST', nargs
='+',
15 help='Make changelogs for these Pull Request #\'s')
16 arguments
= argp
.parse_args()
18 ticket_regex
= re
.compile(r
'(?:[Cc]loses|[Ff]ixes)? #(\d+)')
22 if arguments
.username
:
23 password
= getpass
.getpass("GitHub password for '" + arguments
.username
+ "': ")
24 httpAuth
= requests
.auth
.HTTPBasicAuth(arguments
.username
, password
)
26 for pr
in arguments
.pullrequest
:
30 res
= requests
.get('https://api.github.com/repos/PowerDNS/pdns/pulls/'
31 '{}'.format(pr
), auth
=httpAuth
)
33 except (requests
.exceptions
.HTTPError
, ValueError) as e
:
38 out
+= '- `#{pr} <{url}>`__: {title}'.format(
39 pr
=pr
, url
=pr_info
['html_url'], title
=pr_info
['title']
42 out
+= ' .. change::\n' + \
43 ' :tags: XXXXXX\n' + \
44 ' :pullreq: {}\n'.format(pr
)
45 tickets
= re
.findall(ticket_regex
, pr_info
['body'])
47 out
+= ' :tickets: {}\n'.format(', '.join(tickets
))
48 out
+= '\n {}'.format(pr_info
['title'].capitalize())
50 if pr_info
['user']['login'].lower() not in ['ahupowerdns', 'habbie',
51 'pieterlexis', 'rgacogne',
52 'aerique', 'chbruyand']:
54 user_info
= requests
.get(pr_info
['user']['url'], auth
=httpAuth
).json()
55 except (requests
.exceptions
.HTTPError
, ValueError) as e
:
58 out
+= ' ({})'.format(user_info
['name'])
61 if not arguments
.oneline
: