-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_commit.py
More file actions
42 lines (30 loc) · 1.22 KB
/
test_commit.py
File metadata and controls
42 lines (30 loc) · 1.22 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
import argparse
import os
def test_commit(message=None): #pragma: no cover
run_tests_command = "coverage run -m testing.test_all"
make_report_command = "coverage report > coverage.txt"
print(f"running on command line: \n {run_tests_command}")
os.system(run_tests_command)
print(f"running on command line: \n {make_report_command}")
os.system(make_report_command)
with open("coverage.txt", "r") as f:
for line in f.readlines():
if "TOTAL" in line:
summary = line
with open("coverage.txt", "a") as f:
if message is None:
f.write("no additional message")
else:
f.write(f"message: {message}")
git_add_command = "git add coverage.txt"
commit_command = f"git commit -m 'test commit summary: {summary}' "
if message is not None:
commit_command += f"-m '{message}'"
os.system(git_add_command)
os.system(commit_command)
if __name__ == "__main__": #pragma: no cover
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--message", type=str, default=None,\
help="optional, additional message to add to commit")
args = parser.parse_args()
test_commit(message=args.message)