"git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "4246abc897aa4547b76bad51357178e5911b803d"
Commit 34b53ee7 authored by Caroline Chen's avatar Caroline Chen Committed by Facebook GitHub Bot
Browse files

Update release notes retrieve PRs script (#2257)

Summary:
as discussed offline w/ nateanl, cherry-picked PRs are currently being included when retrieving PRs between a release branch and newer commits. this PR fixes this by removing duplicates in the commit paths

Pull Request resolved: https://github.com/pytorch/audio/pull/2257

Reviewed By: nateanl

Differential Revision: D34459533

Pulled By: carolineechen

fbshipit-source-id: 3497c1d2dca6f8067e2068146a6e28cce591d3c8
parent 20488dd8
...@@ -32,14 +32,14 @@ def commit_title(commit_hash): ...@@ -32,14 +32,14 @@ def commit_title(commit_hash):
return _run_cmd(cmd) return _run_cmd(cmd)
def parse_pr_number(commit_hash, title): def parse_pr_number(title):
regex = r"(#[0-9]+)" regex = r"(#[0-9]+)"
matches = re.findall(regex, title) matches = re.findall(regex, title)
if len(matches) == 0: if len(matches) == 0:
print(f"[{commit_hash}: {title}] Could not parse PR number, ignoring PR") print(f"[{title}] Could not parse PR number, ignoring PR")
return None return None
if len(matches) > 1: if len(matches) > 1:
print(f"[{commit_hash}: {title}] Got two PR numbers, using the last one") print(f"[{title}] Got two PR numbers, using the last one")
return matches[-1][1:] return matches[-1][1:]
return matches[0][1:] return matches[0][1:]
...@@ -91,24 +91,33 @@ def gh_labels(pr_number): ...@@ -91,24 +91,33 @@ def gh_labels(pr_number):
def get_features(commit_hash): def get_features(commit_hash):
title = commit_title(commit_hash) title = commit_title(commit_hash)
pr_number = parse_pr_number(commit_hash, title) pr_number = parse_pr_number(title)
labels = [] labels = []
if pr_number is not None: if pr_number is not None:
labels = gh_labels(pr_number) labels = gh_labels(pr_number)
return Features(title, pr_number, labels) return Features(title, pr_number, labels)
def get_commits_between(base_version, new_version): def get_merge_base(base_version, new_version):
cmd = ["git", "merge-base", f"{base_version}", f"{new_version}"] cmd = ["git", "merge-base", f"{base_version}", f"{new_version}"]
merge_base = _run_cmd(cmd) merge_base = _run_cmd(cmd)
return merge_base
def get_commits_between(base_version, new_version):
merge_base = get_merge_base(base_version, new_version)
# Returns a list of items in the form # Returns a list of items in the form
# a7854f33 Add HuBERT model architectures (#1769) # a7854f33 Add HuBERT model architectures (#1769)
cmd = ["git", "log", "--reverse", "--oneline", f"{merge_base}..{base_version}"]
base_commits = _run_cmd(cmd).split("\n")
base_prs = [parse_pr_number(commit) for commit in base_commits]
cmd = ["git", "log", "--reverse", "--oneline", f"{merge_base}..{new_version}"] cmd = ["git", "log", "--reverse", "--oneline", f"{merge_base}..{new_version}"]
commits = _run_cmd(cmd) new_commits = _run_cmd(cmd).split("\n")
log_lines = commits.split("\n") commits = [commit for commit in new_commits if parse_pr_number(commit) not in base_prs]
hashes, titles = zip(*[log_line.split(" ", 1) for log_line in log_lines]) hashes, titles = zip(*[commit.split(" ", 1) for commit in commits])
return hashes, titles return hashes, titles
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment