Skip to content

Commit

Permalink
[Patch helper] update to not have to checkout main (huggingface#34006)
Browse files Browse the repository at this point in the history
add more support
  • Loading branch information
ArthurZucker authored Oct 9, 2024
1 parent 698b36d commit e783f12
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions utils/patch_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
def get_merge_commit(repo, pr_number, since_tag):
try:
# Use git log to find the merge commit for the PR within the given tag range
merge_commit = next(repo.iter_commits(f"v{since_tag}...HEAD", grep=f"#{pr_number}"))
merge_commit = next(repo.iter_commits(f"v{since_tag}...origin/main", grep=f"#{pr_number}"))
return merge_commit
except StopIteration:
print(f"No merge commit found for PR #{pr_number} between tags {since_tag} and {main}")
Expand All @@ -71,6 +71,7 @@ def main(pr_numbers):
major_minor = f"{last_tag.major}.{last_tag.minor}.0"
# Iterate through tag ranges to find the merge commits
for pr in pr_numbers:
pr = pr.split("https://github.com/huggingface/transformers/pull/")[-1]
commit = get_merge_commit(repo, pr, major_minor)
if commit:
merge_commits.append(commit)
Expand All @@ -86,7 +87,9 @@ def main(pr_numbers):

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Find and sort merge commits for specified PRs.")
parser.add_argument("--prs", nargs="+", required=True, type=int, help="PR numbers to find merge commits for")
parser.add_argument("--prs", nargs="+", required=False, type=str, help="PR numbers to find merge commits for")

args = parser.parse_args()
if args.prs is None:
args.prs = "https://github.com/huggingface/transformers/pull/33753 https://github.com/huggingface/transformers/pull/33861 https://github.com/huggingface/transformers/pull/33906 https://github.com/huggingface/transformers/pull/33761 https://github.com/huggingface/transformers/pull/33586 https://github.com/huggingface/transformers/pull/33766 https://github.com/huggingface/transformers/pull/33958 https://github.com/huggingface/transformers/pull/33965".split()
main(args.prs)

0 comments on commit e783f12

Please sign in to comment.