summaryrefslogtreecommitdiff
path: root/lorry.gzip-importer
diff options
context:
space:
mode:
Diffstat (limited to 'lorry.gzip-importer')
-rwxr-xr-xlorry.gzip-importer30
1 files changed, 19 insertions, 11 deletions
diff --git a/lorry.gzip-importer b/lorry.gzip-importer
index 8bc18ed..8d482b7 100755
--- a/lorry.gzip-importer
+++ b/lorry.gzip-importer
@@ -9,19 +9,11 @@ import struct
import sys
-if len(sys.argv) < 2:
- print('usage:', sys.argv[0], '<gzipfile>...')
- sys.exit(1)
-
branch_name = 'master'
branch_ref = 'refs/heads/%s' % branch_name
committer_name = 'Lorry Gzip Importer'
committer_email = 'lorry-gzip-importer@lorry'
-fast_import = os.popen('git fast-import --quiet', 'w')
-def printlines(list):
- for str in list:
- fast_import.write(str + "\n")
# The size of a gzip file is stored in the last 4 bytes
def uncompressedsize(filename):
@@ -29,7 +21,11 @@ def uncompressedsize(filename):
f.seek(-4, 2)
return struct.unpack('I', f.read(4))[0]
-for zipfile in sys.argv[1:]:
+
+def export(zipfile, fast_import):
+ def printlines(list):
+ for str in list:
+ fast_import.write(str + "\n")
# Gzip does have an encoded mtime, however Python's GzipFile
# just ignores it, so we just yank the mtime of the zip file itself.
@@ -57,5 +53,17 @@ for zipfile in sys.argv[1:]:
'from ' + branch_ref, 'tagger ' + committer, \
'data <<EOM', 'Package ' + zipfile, 'EOM', ''))
-if fast_import.close():
- sys.exit(1)
+
+def main():
+ if len(sys.argv) < 2:
+ print('usage:', sys.argv[0], '<gzipfile>...')
+ sys.exit(1)
+
+ fast_import = os.popen('git fast-import --quiet', 'w')
+ for zipfile in sys.argv[1:]:
+ export(zipfile, fast_import)
+ if fast_import.close():
+ sys.exit(1)
+
+
+main()