From 335b7d214a3c3f41ea93e4a322f1212c73945243 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 12 Jan 2020 20:06:14 -0800 Subject: [PATCH] Put gitcheckup directories into a separate config file. --- .gitignore | 1 + gitcheckup.py | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1cb863f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +gitcheckup.txt diff --git a/gitcheckup.py b/gitcheckup.py index c32bee9..49ef137 100644 --- a/gitcheckup.py +++ b/gitcheckup.py @@ -6,17 +6,6 @@ from voussoirkit import winwhich GIT = winwhich.which('git') -DIRECTORIES = [ - r'D:\Git\cmd', - r'D:\Git\epubfile', - r'D:\Git\Etiquette', - r'D:\Git\reddit', - r'D:\Git\reddit\Timesearch', - r'D:\Git\sigilplugins', - r'D:\Git\voussoirkit', - r'D:\Git\YCDL', -] - # https://git-scm.com/docs/git-status#_short_format # Here is an example of typical `git status --short` output: # @@ -77,7 +66,20 @@ def checkup(directory): return {'committed': committed, 'pushed': pushed, 'details': details} def main(argv): - for directory in DIRECTORIES: + directories_file = os.path.join(os.path.dirname(__file__), 'gitcheckup.txt') + try: + handle = open(directories_file, 'r') + except FileNotFoundError: + print(f'Please put your git repo locations in {directories_file}.') + return 1 + + directories = handle.readlines() + handle.close() + + directories = [line.strip() for line in directories] + directories = [line for line in directories if line] + + for directory in directories: result = checkup(directory) committed = 'C' if result['committed'] else ' ' pushed = 'P' if result['pushed'] else ' '