Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added -z flag for creating a compressed gzip tar

  • Loading branch information...
commit db558c8c72ba46f29e8b395fe2323b1101e2a7e8 1 parent 3971250
Justin Israel justinfx authored

Showing 1 changed file with 7 additions and 2 deletions. Show diff stats Hide diff stats

  1. +7 2 git-archive-all
9 git-archive-all
@@ -19,6 +19,7 @@ parser.add_option('--prefix', type='string', dest='prefix',
19 19 default='', help="prepend PREFIX to each filename in the archive")
20 20
21 21 parser.add_option('-o', '--output', type='string', dest='output_file', default='', help='output file')
  22 +parser.add_option('-z', '--gzip', action='store_true', dest='gzip', help='if using tar format, use gzip compression')
22 23 parser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='enable verbose mode')
23 24
24 25 parser.add_option('--no-exclude', action='store_false', dest='exclude',
@@ -92,8 +93,12 @@ if options.format == 'zip':
92 93 output_archive.write(name, options.prefix + arcname, ZIP_DEFLATED)
93 94
94 95 elif options.format == 'tar':
95   - from tarfile import TarFile
96   - output_archive = TarFile(path.abspath(options.output_file), 'w')
  96 + import tarfile
  97 + t_mode = 'w:gz' if options.gzip else 'w'
  98 + output_archive = tarfile.open(path.abspath(options.output_file), t_mode)
97 99 for name, arcname in git_files():
98 100 if options.verbose: print 'Compressing ' + arcname + '...'
99 101 output_archive.add(name, options.prefix + arcname)
  102 + output_archive.close()
  103 +
  104 +

0 comments on commit db558c8

Please sign in to comment.
Something went wrong with that request. Please try again.