forked from python-telegram-bot/ptb-changelog-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_github.py
More file actions
38 lines (28 loc) · 1.02 KB
/
fetch_github.py
File metadata and controls
38 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
from configparser import ConfigParser
from github import Github
config = ConfigParser()
config.read('config.ini')
token = config['GitHub']['token']
username = config['GitHub']['username']
password = config['GitHub']['password']
if token:
github = Github(token)
else:
github = Github(username, password)
REPO = github.get_repo('python-telegram-bot/python-telegram-bot')
ORG = github.get_organization('python-telegram-bot')
DEVELOPERS = [m for m in ORG.get_members()]
def get_changelog():
return REPO.get_contents('CHANGES.rst').decoded_content.decode('utf-8')
def get_commits_since_release():
pattern = re.compile(r"^Bump (version|) to v[0-9.]*$", flags=re.IGNORECASE)
all_commits = REPO.get_commits()
relevant_commits = []
for commit in all_commits:
if re.match(pattern, commit.commit.message):
break
relevant_commits.append(commit.commit.message.split('\n')[0])
return [f'- {commit}' for commit in relevant_commits]