From 6d2ab4e9c4b456bf109b01fe9742a7df1bce7c33 Mon Sep 17 00:00:00 2001 From: ScottA38 Date: Sat, 27 Sep 2025 10:20:37 +0100 Subject: [PATCH] migrate from deprecated distutils on Python 3.10 --- git-rebase-autotags.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) 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")