summaryrefslogtreecommitdiff
path: root/lorry.zip-importer
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2020-07-10 22:24:55 +0100
committerBen Hutchings <ben.hutchings@codethink.co.uk>2020-07-10 23:00:21 +0100
commitfea0ced99f95a593a89b52ea218884ad8bad2b8d (patch)
treef0cb3ceccf8e76c91c284625874749d5b31f45d0 /lorry.zip-importer
parente756b7ba186917327109780248a9d57820eb55a6 (diff)
downloadlorry-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-xlorry.zip-importer5
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, \