diff options
author | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-07-10 22:24:55 +0100 |
---|---|---|
committer | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-07-10 23:00:21 +0100 |
commit | fea0ced99f95a593a89b52ea218884ad8bad2b8d (patch) | |
tree | f0cb3ceccf8e76c91c284625874749d5b31f45d0 /lorry.zip-importer | |
parent | e756b7ba186917327109780248a9d57820eb55a6 (diff) | |
download | lorry-fea0ced99f95a593a89b52ea218884ad8bad2b8d.tar.gz |
lorry.zip-importer: Interpret zip file timestamps as UTC
Zip file timestamps are in local time, but the time zone offset is
unspecified. We choose to interpret them as UTC so that zip imports
will be reproducible.
Closes #1.
Diffstat (limited to 'lorry.zip-importer')
-rwxr-xr-x | lorry.zip-importer | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lorry.zip-importer b/lorry.zip-importer index cab5e26..3b1ddd6 100755 --- a/lorry.zip-importer +++ b/lorry.zip-importer @@ -10,6 +10,7 @@ ## python import-zips.py *.zip ## git log --stat import-zips +import calendar import os.path import subprocess import sys @@ -55,8 +56,10 @@ def export(zipfile, fast_import): 'data ' + str(info.file_size))) fast_import.write(zip.read(name) + b"\n") + # Zip file timestamps are in local time, but the time zone offset + # is unspecified. We choose to interpret them as UTC. committer = committer_name + ' <' + committer_email + '> %d +0000' % \ - time.mktime(commit_time + (0, 0, 0)) + calendar.timegm(commit_time + (0, 0, 0)) zipfile_basename = os.path.basename(zipfile) printlines(('commit ' + branch_ref, 'committer ' + committer, \ |