Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions git-rebase-autotags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down