This repository has been archived on 2023-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
taiga-to-gitea-issues/import_issues.py

42 lines
1.3 KiB
Python
Raw Normal View History

2018-01-04 06:23:05 +00:00
#!/usr/bin/python3
import json
import requests
import sys
# TODO: Append comments!
def main(input_path, hostname, project_path, username, password):
issues = json.load(open(input_path))['issues']
# Reverse issues so they're actually ordered by ID.
for issue in reversed(issues):
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
payload = {
'body': issue['description'] + '\n\n---\nImported from Taiga issue {taiga_id}: {status} {type}. Created on {created_date} by {author}.'.format(
taiga_id=issue['ref'],
status=issue['status'].lower(),
type=issue['type'].lower(),
created_date=issue['created_date'],
author=issue['history'][0]['user'][1],
),
'closed': bool(issue['status'] in ('Done', 'Won\'t fix')),
'title': issue['subject'],
}
response = requests.post(
'https://{}/api/v1/repos/{}/issues'.format(hostname, project_path),
auth=(username, password),
headers=headers,
data=json.dumps(payload),
)
return # TODO
if __name__ == '__main__':
main(*sys.argv[1:])