Support for comments.

This commit is contained in:
Dan 2018-01-04 21:17:26 -08:00
parent fdd1e0a94a
commit 5a03acf33c
1 changed files with 17 additions and 3 deletions

View File

@ -9,7 +9,6 @@ HEADERS = {
'Content-Type': 'application/json',
}
# TODO: Append comments!
def main(input_path, hostname, project_path, username, password):
issues = json.load(open(input_path))['issues']
type_to_label_id = {}
@ -58,8 +57,23 @@ def main(input_path, hostname, project_path, username, password):
headers=HEADERS,
data=json.dumps({'labels': [label_id]}),
)
return # TODO: remove me
# Add comments for the issue.
for entry in issue['history']:
if not entry['comment']:
continue
requests.post(
issue_url + '/comments',
auth=(username, password),
headers=HEADERS,
data=json.dumps({
'body': entry['comment'] + '\n\n---\nComment on {created_at} by {author}.'.format(
created_at=entry['created_at'],
author=entry['user'][1]
),
}),
)
if __name__ == '__main__':