diff --git a/git-rebase-autotags.py b/git-rebase-autotags.py index 0a7cd1a..4ad0326 100644 --- a/git-rebase-autotags.py +++ b/git-rebase-autotags.py @@ -16,23 +16,22 @@ import sys import subprocess -import distutils.util +from git import Repo args = sys.stdin.read().split() commits = zip(*[iter(args)]*2) rewrite_cmd = sys.argv[1] -try: - stdoutput = subprocess.check_output(['git', 'config', '--get', '--bool', 'rewrite.autotags.enabled']) - autotags = bool(distutils.util.strtobool(stdoutput.decode().strip())) -except subprocess.CalledProcessError: - autotags = False - -try: - stdoutput = subprocess.check_output(['git', 'config', '--get', '--bool', 'rewrite.autotags.warnings']) - warnings = bool(distutils.util.strtobool(stdoutput.decode().strip())) -except subprocess.CalledProcessError: - warnings = True +repo = Repo('.') +cfg = repo.config_reader() +autotags = None +warnings = None + +if cfg.has_option('rewrite "autotags', 'enabled'): + autotags = cfg.get_boolean('rewrite "autotags"', 'enabled') and cfg.get_boolean('push', 'followTags') + +if cfg.has_option('rewrite "autotags"', 'warnings'): + warnings = cfg.get_boolean('rewrite "autotags"', 'warnings') if not autotags and warnings: print("\033[33mWARNING: rewrite.autotags hook configure in this repository has not been activated\033[0m")