Skip to content

Commit

Permalink
Optionally specify the main git repository
Browse files Browse the repository at this point in the history
Follows git's convention for option naming
  • Loading branch information
lbonn committed Oct 31, 2019
1 parent 0d1806d commit ca40ba7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Archive repository with all its submodules.

--prefix=PREFIX Prepend PREFIX to each filename in the archive. OUTPUT_FILE name is used by default to avoid tarbomb. You can set it to '' in order to explicitly request tarbomb.

-C BASE_REPO Use BASE_REPO as the main repository git working directory to archive. Defaults to current directory when empty
--no-exclude Don't read .gitattributes files for patterns containing export-ignore attributes.

--force-submodules Force a `git submodule init && git submodule update` at each level before iterating submodules
Expand Down
15 changes: 12 additions & 3 deletions git_archive_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ def main():
from optparse import OptionParser, SUPPRESS_HELP

parser = OptionParser(
usage="usage: %prog [-v] [--prefix PREFIX] [--no-exclude] [--force-submodules]"
" [--extra EXTRA1 ...] [--dry-run] [-0 | ... | -9] OUTPUT_FILE",
usage="usage: %prog [-v] [-C BASE_REPO] [--prefix PREFIX] [--no-exclude]"
" [--force-submodules] [--extra EXTRA1 ...] [--dry-run] [-0 | ... | -9] OUTPUT_FILE",
version="%prog {0}".format(__version__)
)

Expand All @@ -497,6 +497,13 @@ def main():
OUTPUT_FILE name is used by default to avoid tarbomb.
You can set it to '' in order to explicitly request tarbomb""")

parser.add_option('-C',
type='string',
dest='base_repo',
default=None,
help="""use BASE_REPO as the main repository git working directory to archive.
Defaults to current directory when empty""")

parser.add_option('-v', '--verbose',
action='store_true',
dest='verbose',
Expand Down Expand Up @@ -561,7 +568,9 @@ def main():
archiver = GitArchiver(options.prefix,
options.exclude,
options.force_sub,
options.extra)
options.extra,
path.abspath(options.base_repo) if options.base_repo is not None else None
)
archiver.create(output_file_path, options.dry_run, compresslevel=options.compresslevel)
except Exception as e:
parser.exit(2, "{0}\n".format(e))
Expand Down

0 comments on commit ca40ba7

Please sign in to comment.