summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Mckay <kyle.mckay@codethink.co.uk>2021-10-28 11:30:19 +0100
committerKyle Mckay <kyle.mckay@codethink.co.uk>2021-11-15 09:49:27 +0000
commitbef27f7d13b199bd219828ae9b069fada7535723 (patch)
tree0c862c957b803dedc2cacac97dcc4edfe6af1728
parentc3685b4e5482891e5c342bf1c7072ff5271a66e9 (diff)
downloadlorry-bef27f7d13b199bd219828ae9b069fada7535723.tar.gz
Improve retrieval of most recent commit
- Use of rev-parse more correct since `git log` is porcelain
-rwxr-xr-xlorry.raw-file-importer7
1 files changed, 5 insertions, 2 deletions
diff --git a/lorry.raw-file-importer b/lorry.raw-file-importer
index 1203e20..0a63003 100755
--- a/lorry.raw-file-importer
+++ b/lorry.raw-file-importer
@@ -86,10 +86,13 @@ def commit_lfs_file(raw_file, relative_path, last_commit, fast_import):
def get_last_commit():
# show the full hash of the latest commit
- out = subprocess.run(['git', 'log', '-n1', '--format=format:%H'], capture_output=True, text=True)
+ out = subprocess.run(['git', 'rev-parse', 'HEAD'], capture_output=True, text=True)
if out.returncode != 0:
return None
- return out.stdout.strip()
+
+ # Will be HEAD when no commits exist yet
+ out = out.stdout.strip()
+ return None if out == 'HEAD' else out
def main():