X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=set-commit-date.py;h=7f481f36960251b382b9d0b756fed9563e521619;hb=85bb1ca14fceb299bc688a926fcafe6011dcaf9a;hp=c5d49d4225e7864bfdc7710e83179da805d0289b;hpb=889d6017bcc7c94e667bb4ef2ffbc003131dabf5;p=git-scripts.git diff --git a/set-commit-date.py b/set-commit-date.py index c5d49d4..7f481f3 100755 --- a/set-commit-date.py +++ b/set-commit-date.py @@ -8,19 +8,21 @@ import os import subprocess +git_root = subprocess.check_output(['git', 'rev-parse', '--show-toplevel'], + universal_newlines=True).rstrip('\n') +os.chdir(git_root) + separator = '----- GIT LOG SEPARATOR -----' git_log = subprocess.Popen(['git', 'log', '-m', '--first-parent', '--name-only', '--no-color', '--format=%s%%n%%ct' % separator], - stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + universal_newlines=True) filenames = set() # stages: 1 - start of commit, 2 - timestamp, 3 - empty line, 4 - files stage = 1 -while True: - line = git_log.stdout.readline() - if not line: # EOF - break +for line in git_log.stdout: line = line.strip() if (stage in (1, 4)) and (line == separator): # Start of a commit stage = 2