Skip to content

Commit

Permalink
improve fetch_milestone.py
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Feb 4, 2025
1 parent a0ff16e commit 0e39e63
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions fetch_milestone.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@
args = parser.parse_args()
milestone_title: str = args.milestone_title

milestones = requests.get(f'{BASE_URL}/milestones', timeout=5).json()
matching_milestones = [milestone for milestone in milestones if milestone['title'] == milestone_title]
if not matching_milestones:
print(f'Milestone "{milestone_title}" not found!')
sys.exit(1)
milestone_number = matching_milestones[0]['number']
page = 0
while True:
page += 1
response = requests.get(f'{BASE_URL}/milestones?state=all&page={page}&per_page=100', timeout=5)
milestones = response.json()
if not milestones:
print(f'Milestone "{milestone_title}" not found!')
sys.exit(1)
matching = [m for m in milestones if m['title'] == milestone_title]
if matching:
milestone_number = matching[0]['number']
break


def link(number: int) -> str:
Expand All @@ -32,14 +38,18 @@ def link(number: int) -> str:
'New features and enhancements': [],
'Bugfixes': [],
'Documentation': [],
'Dependencies': [],
'Others': [],
}
for issue in issues:
title: str = issue['title']
user: str = issue['user']['login']
user: str = issue['user']['login'].replace('[bot]', '')
body: str = issue['body'] or ''
labels: List[str] = [label['name'] for label in issue['labels']]
number_patterns = [r'#(\d+)', r'https://github.com/zauberzeug/nicegui/(?:issues|discussions|pulls)/(\d+)']
if user == 'dependabot':
number_patterns = []
else:
number_patterns = [r'#(\d+)', r'https://github.com/zauberzeug/nicegui/(?:issues|discussions|pulls)/(\d+)']
numbers = [issue['number']] + [int(match) for pattern in number_patterns for match in re.findall(pattern, body)]
numbers_str = ', '.join(link(number) for number in sorted(numbers))
note = f'{title.strip()} ({numbers_str} by @{user})'
Expand All @@ -49,6 +59,8 @@ def link(number: int) -> str:
notes['New features and enhancements'].append(note)
elif 'documentation' in labels:
notes['Documentation'].append(note)
elif 'dependencies' in labels:
notes['Dependencies'].append(note)
else:
notes['Others'].append(note)

Expand Down

0 comments on commit 0e39e63

Please sign in to comment.