-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMain.py
71 lines (59 loc) · 2.41 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
59
60
61
62
63
64
65
66
67
68
69
70
71
import MatrixDB as db
import GitCommits as g
import JiraIssues as j
import Matrix
import sys
if __name__ == '__main__':
# Set variables according to the project
PROJECT_NAME = sys.argv[1] # "commons-math"
JIRA_PROJECT_ID = sys.argv[2] # "MATH"
commits_start = None
commits_end = None
USE_DB = True
QUICK_MODE = False
if len(sys.argv) > 3:
window_size = 500
commits_start = int(sys.argv[1]) * window_size
commits_end = commits_start + window_size
PROJECT_NAME = sys.argv[2] # "commons-math"
JIRA_PROJECT_ID = sys.argv[3] # "MATH"
USE_DB = True
if len(sys.argv) > 4:
QUICK_MODE = True
DB_PATH = r"CommitIssueDB.db"
GIT_REPO_PATH_LOCAL = r"local_repo"
JIRA_PATH = r"http://issues.apache.org/jira"
# Get DB connection
db_connection = db.get_connection(DB_PATH, USE_DB)
# Project Handling
db_connection.insert_project(PROJECT_NAME, JIRA_PROJECT_ID)
# Commits Handling
g.set_repo_path(GIT_REPO_PATH_LOCAL)
comms = g.get_commits_files(GIT_REPO_PATH_LOCAL)
all_commits = list(filter(lambda c: c.is_java, comms))
commits = all_commits
if commits_start is not None:
commits = all_commits[commits_start: commits_end]
if len(commits) == 0:
exit()
for ind, commit in enumerate(commits):
db.insert_commit(db_connection, commit, PROJECT_NAME, QUICK_MODE)
if not QUICK_MODE or commits_start == 0:
# Issues Handling
j.set_jira(JIRA_PATH)
jql_features = 'project = {0} AND issuetype = "New Feature" AND statusCategory = Done'.format(JIRA_PROJECT_ID)
jql_bugs_improvements = 'project = {0} AND issuetype in (Bug, Improvement) AND statusCategory = Done'.format(
JIRA_PROJECT_ID)
issues_features = j.get_issues_list(jql_features)
for issue in issues_features:
db_connection.insert_issue(issue, PROJECT_NAME)
issues_bugs_improvements = j.get_issues_list(jql_bugs_improvements)
for issue in issues_bugs_improvements:
db_connection.insert_issue(issue, PROJECT_NAME)
all_issues = issues_bugs_improvements + issues_features # union both issue lists to one
# Matrix Handling
m = Matrix.create_matrix(all_issues, all_commits)
for issue, commit in m:
db_connection.insert_linkage(commit, issue)
# DONE
db.close_connection(db_connection)