Initial import.

This commit is contained in:
Dan 2018-01-03 22:23:05 -08:00
commit e727a1c167
2 changed files with 61 additions and 0 deletions

20
README.md Normal file
View File

@ -0,0 +1,20 @@
## Overview
Simple Python script that takes a JSON file for an exported Taiga projects and
imports its issue into it a Gitea project via API.
It doesn't have much in the way of error handling. Caveat usor.
The script relies on the requests library.
## Usage
```
./import_issues.py [input-path] [hostname] [project-path] [username] [password]
```
Example:
```
./import_issues.py taiga_export.json gitea.example.org bob/cool-project bob password
```

41
import_issues.py Executable file
View File

@ -0,0 +1,41 @@
#!/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:])