]> git.phdru.name Git - git-scripts.git/blobdiff - set-commit-date.py
Feat(get-authors): Add an alternative implementation
[git-scripts.git] / set-commit-date.py
index dc6a5fb732d93a0499323e9197305797a24172d8..7f481f36960251b382b9d0b756fed9563e521619 100755 (executable)
@@ -8,6 +8,10 @@
 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',
@@ -18,10 +22,7 @@ git_log = subprocess.Popen(['git', 'log', '-m', '--first-parent',
 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