Skip to content

Update create-release.py to find github issues without the full url #13150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions tools/devops/create-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import re
import os
import backoff
import functools
from git import Repo
from urllib.parse import urlparse

Expand Down Expand Up @@ -45,6 +46,12 @@ def main(version: str, previous: str, max_message_lines: int, publish: bool, ass
if pr_description is not None:
issues = issues.union(find_github_issues(pr_description))

if github_token is not None:
issues = filter_github_issues(issues, github_token)

if len(issues) > 1:
print(f'WARNING: found more than 1 github issues in message: {message}. Issues: {issues}', file=sys.stderr)

message = e.message[:-1] if e.message.endswith('\n') else e.message

# Shrink the message if it's too long
Expand Down Expand Up @@ -103,17 +110,36 @@ def get_previous_release(version: tuple) -> str:
return '.'.join(str(e) for e in max(previous_versions))

def find_github_issues(message: str):
# Look for urls first
urls = [urlparse(e) for e in re.findall(r"https?://[^\s^\)]+", message)]

issue_urls = [e for e in urls if e.hostname == 'github.com' and e.path.lower().startswith('/microsoft/wsl/issues/')]

issues = set(['#' + e.path.split('/')[-1] for e in issue_urls])

if len(issues) > 1:
print(f'WARNING: found more than 1 github issues in message: {message}. Issues: {issues}', file=sys.stderr)
# Then add issue numbers
for e in re.findall(r"#\d+", message):
issues.add(e)

return issues

def filter_github_issues(issues: list, token: str) -> list:

@functools.cache
def is_pr(number: str):
headers = {
'Accept': 'application/vnd.github+json',
'Authorization': 'Bearer ' + token,
'X-GitHub-Api-Version': '2022-11-28'
}

response = requests.get(f'https://api.github.com/repos/microsoft/wsl/issues/{number}', timeout=30, headers=headers)
response.raise_for_status()

return response.json().get('pull_request') is not None

return [e for e in issues if not is_pr(e.replace('#', ''))]


def get_change_list(version: str, previous: str, fetch: bool) -> list:
repo = Repo('.')
Expand Down