-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.py
More file actions
53 lines (45 loc) · 1.39 KB
/
interface.py
File metadata and controls
53 lines (45 loc) · 1.39 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
import argparse
import logging
import os
import git
from find_active_branch import find_active_branch
from is_modified import is_modified
from is_last_week import is_last_week
from is_rufus import is_rufus
def is_git_repo(path):
try:
_ = git.Repo(path).git_dir
return True
except:
return False
def driver(pv_git_dir):
# check if git directory is valid
if not is_git_repo(pv_git_dir):
print(f"{pv_git_dir} Not a git repo")
logging.error(f"git_dir is not git repo or invalid")
return -1
find_active_branch(pv_git_dir)
is_modified(pv_git_dir)
is_last_week(pv_git_dir)
is_rufus(pv_git_dir)
logging.info(f"Output on stdout successful")
return 0
def main():
lv_filename = os.path.basename(__file__)
lv_log_filename = os.path.splitext(lv_filename)[0] + ".log"
logging.basicConfig(filename = lv_log_filename,
format='%(asctime)s %(levelname)s:%(message)s',
level=logging.INFO)
parser = argparse.ArgumentParser()
parser.add_argument(
"--git_dir", type=str, required=True,
help="directory in which to assess git status"
)
args = parser.parse_args()
lv_error = driver(args.git_dir)
if lv_error == -1:
logging.info("Exited due to error.")
return
logging.info("Task completed")
if __name__ == '__main__':
main()