2019-07-15 14:46:54 -07:00
|
|
|
from github import Github
|
|
|
|
from subprocess import check_output
|
|
|
|
import shlex
|
|
|
|
from tqdm import tqdm
|
|
|
|
import click
|
2020-05-28 09:37:19 -07:00
|
|
|
from collections import defaultdict
|
2019-07-15 14:46:54 -07:00
|
|
|
|
|
|
|
|
|
|
|
@click.command()
|
|
|
|
@click.option(
|
|
|
|
"--access-token",
|
|
|
|
required=True,
|
|
|
|
help="""
|
|
|
|
Github Access token that has repo:public_repo and user:read:user permission.
|
|
|
|
|
|
|
|
Create them at https://github.com/settings/tokens/new
|
|
|
|
""",
|
|
|
|
)
|
|
|
|
@click.option(
|
2019-12-16 15:51:39 -08:00
|
|
|
"--prev-release-commit",
|
2019-07-15 14:46:54 -07:00
|
|
|
required=True,
|
2022-01-29 18:41:57 -08:00
|
|
|
help="Last commit SHA of the previous release.",
|
|
|
|
)
|
2019-07-15 14:46:54 -07:00
|
|
|
@click.option(
|
2019-12-16 15:51:39 -08:00
|
|
|
"--curr-release-commit",
|
2019-07-15 14:46:54 -07:00
|
|
|
required=True,
|
2022-01-29 18:41:57 -08:00
|
|
|
help="Last commit SHA of the current release.",
|
|
|
|
)
|
2019-12-16 15:51:39 -08:00
|
|
|
def run(access_token, prev_release_commit, curr_release_commit):
|
|
|
|
print("Writing commit descriptions to 'commits.txt'...")
|
|
|
|
check_output(
|
2022-01-29 18:41:57 -08:00
|
|
|
(
|
|
|
|
f"git log {prev_release_commit}..{curr_release_commit} "
|
|
|
|
f"--pretty=format:'%s' > commits.txt"
|
|
|
|
),
|
|
|
|
shell=True,
|
|
|
|
)
|
2019-07-15 14:46:54 -07:00
|
|
|
# Generate command
|
|
|
|
cmd = []
|
2022-01-29 18:41:57 -08:00
|
|
|
cmd.append(
|
|
|
|
(
|
|
|
|
f"git log {prev_release_commit}..{curr_release_commit} "
|
|
|
|
f'--pretty=format:"%s" '
|
|
|
|
f' | grep -Eo "#(\d+)"'
|
|
|
|
)
|
|
|
|
)
|
2019-07-15 14:46:54 -07:00
|
|
|
joined = " && ".join(cmd)
|
|
|
|
cmd = f"bash -c '{joined}'"
|
|
|
|
cmd = shlex.split(cmd)
|
|
|
|
print("Executing", cmd)
|
|
|
|
|
|
|
|
# Sort the PR numbers
|
2022-01-29 18:41:57 -08:00
|
|
|
pr_numbers = [int(line.lstrip("#")) for line in check_output(cmd).decode().split()]
|
2019-07-15 14:46:54 -07:00
|
|
|
print("PR numbers", pr_numbers)
|
|
|
|
|
|
|
|
# Use Github API to fetch the
|
|
|
|
g = Github(access_token)
|
|
|
|
ray_repo = g.get_repo("ray-project/ray")
|
|
|
|
logins = set()
|
|
|
|
for num in tqdm(pr_numbers):
|
|
|
|
try:
|
|
|
|
logins.add(ray_repo.get_pull(num).user.login)
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
|
|
|
|
print()
|
|
|
|
print("Here's the list of contributors")
|
|
|
|
print("=" * 10)
|
|
|
|
print()
|
|
|
|
print("@" + ", @".join(logins))
|
|
|
|
print()
|
|
|
|
print("=" * 10)
|
|
|
|
|
2020-05-28 09:37:19 -07:00
|
|
|
# Organize commits
|
|
|
|
NO_CATEGORY = "[NO_CATEGORY]"
|
|
|
|
|
|
|
|
def get_category(line):
|
|
|
|
if line[0] == "[":
|
|
|
|
return (line.split("]")[0].strip(" ") + "]").upper()
|
|
|
|
else:
|
|
|
|
return NO_CATEGORY
|
|
|
|
|
|
|
|
commits = defaultdict(list)
|
|
|
|
|
|
|
|
with open("commits.txt") as file:
|
|
|
|
for line in file.readlines():
|
|
|
|
commits[get_category(line)].append(line.strip())
|
|
|
|
|
|
|
|
with open("commits.txt", "a") as file:
|
|
|
|
for category, commit_msgs in commits.items():
|
|
|
|
file.write("\n{}\n".format(category))
|
|
|
|
for commit_msg in commit_msgs:
|
|
|
|
file.write("{}\n".format(commit_msg))
|
|
|
|
|
2019-07-15 14:46:54 -07:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
run()
|