diff options
author | Kyle Mckay <kyle.mckay@codethink.co.uk> | 2021-10-28 11:30:19 +0100 |
---|---|---|
committer | Kyle Mckay <kyle.mckay@codethink.co.uk> | 2021-11-15 09:49:27 +0000 |
commit | bef27f7d13b199bd219828ae9b069fada7535723 (patch) | |
tree | 0c862c957b803dedc2cacac97dcc4edfe6af1728 | |
parent | c3685b4e5482891e5c342bf1c7072ff5271a66e9 (diff) | |
download | lorry-bef27f7d13b199bd219828ae9b069fada7535723.tar.gz |
Improve retrieval of most recent commit
- Use of rev-parse more correct since `git log` is
porcelain
-rwxr-xr-x | lorry.raw-file-importer | 7 |
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(): |