2019-05-16 10:29:48 +00:00
|
|
|
import argparse
|
|
|
|
import requests
|
2019-06-28 08:24:31 +00:00
|
|
|
import os
|
2019-05-16 10:29:48 +00:00
|
|
|
|
|
|
|
GITLAB_URL = "https://dev.funkwhale.audio"
|
|
|
|
GITLAB_PROJECT_ID = 17
|
|
|
|
WEBLATE_URL = "https://translate.funkwhale.audio"
|
|
|
|
WEBLATE_COMPONENT_ID = "funkwhale/front"
|
|
|
|
|
|
|
|
|
2021-11-06 13:30:58 +00:00
|
|
|
def get_issues(next_release):
|
|
|
|
url = GITLAB_URL + "/api/v4/issues"
|
2021-12-14 18:45:30 +00:00
|
|
|
while url:
|
|
|
|
response = requests.get(
|
|
|
|
url,
|
|
|
|
params={"per_page": 20, "milestone": next_release, "scope": "all"},
|
|
|
|
headers={"PRIVATE-TOKEN": os.environ["PRIVATE_TOKEN"]},
|
|
|
|
)
|
|
|
|
response.raise_for_status()
|
|
|
|
yield from response.json()
|
2019-05-16 10:29:48 +00:00
|
|
|
|
2021-12-14 18:45:30 +00:00
|
|
|
if "next" in response.links:
|
|
|
|
url = response.links["next"]["url"]
|
|
|
|
else:
|
|
|
|
url = None
|
2019-05-16 10:29:48 +00:00
|
|
|
|
|
|
|
|
2021-11-06 13:30:58 +00:00
|
|
|
def get_merge_requests(next_release):
|
|
|
|
url = GITLAB_URL + "/api/v4/merge_requests"
|
2021-12-14 18:45:30 +00:00
|
|
|
while url:
|
|
|
|
response = requests.get(
|
|
|
|
url,
|
|
|
|
params={"per_page": 20, "milestone": next_release, "scope": "all"},
|
|
|
|
headers={"PRIVATE-TOKEN": os.environ["PRIVATE_TOKEN"]},
|
|
|
|
)
|
|
|
|
response.raise_for_status()
|
|
|
|
yield from response.json()
|
|
|
|
|
|
|
|
if "next" in response.links:
|
|
|
|
url = response.links["next"]["url"]
|
|
|
|
else:
|
|
|
|
url = None
|
2019-05-16 10:29:48 +00:00
|
|
|
|
|
|
|
|
2021-11-06 13:30:58 +00:00
|
|
|
def get_participants(project_id, issue_iid, object_type="issues"):
|
|
|
|
if object_type not in ["issues", "merge_requests"]:
|
|
|
|
raise ValueError("object_type needs to be `issues` or `merge_requests`")
|
|
|
|
url = GITLAB_URL + "/api/v4/projects/{}/{}/{}/participants".format(
|
|
|
|
project_id, object_type, issue_iid
|
|
|
|
)
|
2019-05-16 10:29:48 +00:00
|
|
|
|
2021-11-06 13:30:58 +00:00
|
|
|
response = requests.get(
|
|
|
|
url,
|
|
|
|
params={"per_page": 100},
|
|
|
|
headers={"PRIVATE-TOKEN": os.environ["PRIVATE_TOKEN"]},
|
2019-05-16 10:29:48 +00:00
|
|
|
)
|
2019-06-28 08:24:31 +00:00
|
|
|
response.raise_for_status()
|
2021-11-06 13:30:58 +00:00
|
|
|
|
|
|
|
participants = []
|
|
|
|
for participant in response.json():
|
|
|
|
participants.append(participant["name"])
|
|
|
|
|
|
|
|
return participants
|
|
|
|
|
|
|
|
|
|
|
|
def clear_list(inList):
|
|
|
|
outList = list(dict.fromkeys(inList))
|
|
|
|
try:
|
|
|
|
outList.remove("funkwhale-bot")
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
outList.remove("weblate (bot)")
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
outList.sort()
|
|
|
|
return outList
|
2019-06-28 08:24:31 +00:00
|
|
|
|
|
|
|
|
2019-05-16 10:29:48 +00:00
|
|
|
def main():
|
2021-11-06 13:30:58 +00:00
|
|
|
if "PRIVATE_TOKEN" not in os.environ:
|
|
|
|
print("Please configure an Gitlab Access token in $PRIVATE_TOKEN")
|
|
|
|
return
|
2019-05-16 10:29:48 +00:00
|
|
|
parser = argparse.ArgumentParser()
|
2021-11-06 13:30:58 +00:00
|
|
|
parser.add_argument("next_tag")
|
2019-05-16 10:29:48 +00:00
|
|
|
args = parser.parse_args()
|
2021-11-06 13:30:58 +00:00
|
|
|
issues = get_issues(args.next_tag)
|
|
|
|
mrs = get_merge_requests(args.next_tag)
|
|
|
|
|
|
|
|
print("\nContributors to our Issues:\n")
|
|
|
|
issue_participants = []
|
|
|
|
|
|
|
|
for issue in issues:
|
|
|
|
participants = get_participants(issue["project_id"], issue["iid"])
|
|
|
|
issue_participants.extend(participants)
|
|
|
|
|
|
|
|
issue_participants = clear_list(issue_participants)
|
|
|
|
for contributor in issue_participants:
|
|
|
|
print(contributor)
|
|
|
|
|
|
|
|
print("\nContributors to our Merge Requests:\n")
|
|
|
|
mr_participants = []
|
|
|
|
|
|
|
|
for mr in mrs:
|
|
|
|
participants = get_participants(mr["project_id"], mr["iid"], "merge_requests")
|
|
|
|
mr_participants.extend(participants)
|
|
|
|
|
|
|
|
mr_participants = clear_list(mr_participants)
|
|
|
|
for contributor in mr_participants:
|
|
|
|
print(contributor)
|
|
|
|
|
|
|
|
return
|
2019-05-16 10:29:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|