-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdriver.py
More file actions
65 lines (40 loc) · 1.58 KB
/
driver.py
File metadata and controls
65 lines (40 loc) · 1.58 KB
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
#!/usr/bin/python3
import sys, os, getopt
import logging
import git
from datetime import datetime
import pomMigration
currentDateAndTime = datetime.now()
usage = 'migrate.py -i <input_dir> '
branch = 'junit5-migration'
def main(argv):
cwd = os.getcwd()
input_dir = ''
max_files = '0'
opts, args = getopt.getopt(argv, "hi:m:", ["input_dir=", "max_files="])
for opt, arg in opts:
if opt == '-h':
print(usage)
elif opt in ('-i', '--input_dir'):
input_dir = arg
elif opt in ('-m', '--max_files'):
max_files = arg
else:
print(usage)
logging.info(f"Loading and checking the {input_dir} git repository")
# repo = git.Repo(input_dir)
# if not (branch in [r.name for r in repo.references]):
# repo.git.branch(branch)
# repo.git.checkout(branch)
logging.info("Executing the migrations")
currentTime = currentDateAndTime.strftime("%y%m%d%H%M%S")
os.system(f"java -Xmx4G -Xss1G -jar rascal-shell-stable.jar lang::java::transformations::junit::MainProgram -path {input_dir} -maxFilesOpt {max_files} > output/log-{currentTime}")
os.chdir(input_dir)
logging.info("Formating the source code")
os.system(f"git config --global --add safe.directory '*' ")
os.system(f"git diff -U0 HEAD^ | {cwd}/google-java-format-diff.py -p1 -i --google-java-format-jar {cwd}/google-format.jar")
pom_path = "-i "+input_dir+"pom.xml"
pomMigration.main(argv=[pom_path])
logging.info("done")
if __name__ == "__main__":
main(sys.argv[1:])