forked from csandeep/jira-issues-importer
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
58 lines (43 loc) · 1.62 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import getpass
from collections import namedtuple
from lxml import objectify
from project import Project
from importer import Importer
from labelcolourselector import LabelColourSelector
def read_xml_sourcefile(file_names):
files = list()
for file_name in file_names.split(';'):
all_text = open(file_name).read()
files.append(objectify.fromstring(all_text))
return files
file_names = input(
'Path to JIRA XML query file (semi-colon separate for multiple files): ')
all_xml_files = read_xml_sourcefile(file_names)
jira_proj = input('JIRA project name: ')
jira_done_id = input('JIRA Done statusCategory ID [default "3"]: ') or '3'
ac = input('GitHub account name: ')
repo = input('GitHub project name: ')
pat = input('GitHub personal access token: ')
start_from_issue = input('Start from [default "0" (beginning)]: ') or '0'
Options = namedtuple("Options", "accesstoken account repo")
opts = Options(accesstoken=pat, account=ac, repo=repo)
project = Project(jira_proj, jira_done_id)
for f in all_xml_files:
for item in f.channel.item:
project.add_item(item)
project.prettify()
input('Press any key to begin...')
'''
Steps:
1. Create any milestones
2. Create any labels
3. Create each issue with comments, linking them to milestones and labels
4: Post-process all comments to replace issue id placeholders with the real ones
'''
importer = Importer(opts, project)
colourSelector = LabelColourSelector(project)
importer.import_milestones()
if int(start_from_issue) == 0:
importer.import_labels(colourSelector)
importer.import_issues(int(start_from_issue))
# importer.post_process_comments()