forked from BugsJS/bug-dataset
-
Notifications
You must be signed in to change notification settings - Fork 1
/
myGit.py
39 lines (33 loc) · 1.33 KB
/
myGit.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
import csv
import myVersion
import os
import subprocess as sp
import sys
def checkout(param_dict):
repository = get_project_repository(param_dict)
clone_repo(repository, param_dict["output"])
checkout_cmd = None
if myVersion.is_buggy(param_dict["version"]):
checkout_cmd = "git checkout tags/Bug-" + str(param_dict["bug-ID"]+"^")
elif myVersion.is_fixed(param_dict["version"]):
checkout_cmd = "git checkout tags/Bug-" + str(param_dict["bug-ID"]) + "-full"
elif myVersion.is_fixed_only_test_change(param_dict["version"]):
checkout_cmd = "git checkout tags/Bug-" + str(param_dict["bug-ID"]) + "-test"
else:
exit()
sp.call(checkout_cmd, shell=True)
def get_project_repository(param_dict):
SCRIPTDIR = os.path.abspath(os.path.dirname(sys.argv[0]))
with open(os.path.join(SCRIPTDIR, "Projects.csv"), 'r') as infile:
reader = csv.DictReader(infile, delimiter=";")
for row in reader:
if str(param_dict["project"]) == str(row["Name"]):
return row["Repository url"]
print("I can't find the project in the csv file")
exit()
def clone_repo(project_repo, folder):
os.makedirs(folder, exist_ok=True)
os.chdir(folder)
clone_cmd = "git clone "+str(project_repo)
sp.call(clone_cmd, shell=True)
os.chdir( os.listdir( "./" )[0] )