Convert assignees listing from dicts to strings

This commit is contained in:
benjamin melançon 2023-10-04 21:14:10 -04:00
parent e82c747636
commit 9ec60e1c4d

View file

@ -34,6 +34,16 @@ def move_issue(source_owner, source_repo, issue_number, destination_owner, desti
print(f"We have removed the milestone {milestone['title']} from this issue (milestones are specific to repositories).") print(f"We have removed the milestone {milestone['title']} from this issue (milestones are specific to repositories).")
# Note that pop has already thrown out the milestone from json_response # Note that pop has already thrown out the milestone from json_response
assignees = json_response.pop('assignees', {})
if assignees:
# 'assignee' is deprecated; remove it.
json_response.pop('assignee', None)
# Forgejo's API *gives* us assignee objects but only *accepts* strings.
# Specifically, we need to replace the dict with its 'login' key.
json_response['assignees'] = []
for assignee in assignees:
json_response['assignees'].append(assignee['login'])
print(f"Creating issue {json_response['title']} now…") print(f"Creating issue {json_response['title']} now…")
create_issue_url = API_CREATE_ISSUE.format(instance=FORGEJO_INSTANCE, owner=destination_owner, repo=destination_repo) create_issue_url = API_CREATE_ISSUE.format(instance=FORGEJO_INSTANCE, owner=destination_owner, repo=destination_repo)