Kentzo / git-archive-all

A python script wrapper for git-archive that archives a git superproject and its submodules, if it has any. Takes into account .gitattributes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Advice for exporting starting in a subdirectory

mike-lawrence opened this issue · comments

Very possibly I'm starting from a usage that is non-standard and there's a better way for me to do this, but I have a repo with the file structure:

my_repo
    |- app
        |- my_submodule
        |- other stuff
    |- make_app_zip.sh

Where I have the core code of the repo in the app folder and a shell script that calls git-archive-all at the root of of the repo. I'd like to be able to have a zip where the app folder forms the root of the zip and I've tried both:

git-archive-all -C ./app zipped_app.zip

and

cd app
git-archive-all ../zipped_app.zip

in that shell script, but both seem to yield a zip that has grabbed everything from the repo root down, including the zip shell and the app folder as a subfolder (rather than just the app folder as the root of the zip).

Any suggestions?

The script archives starting from repo's root, -C is here to avoid cd-ing so you can archive /your/repo/path from ~/. Using git-archive-all's CLI alone you cannot have my_repo/app instead of app.

I can suggest two solutions:

  • Switch to tar.* and --strip-component
  • Instead of a shell script write a python script where you can subclass GitArchiver and modify it as needed

You should be able to exclude make_app_zip.sh from the resulting archive: cd repo; echo "make_app_zip.sh export-ignore" >> .gitattributes. You can exclude as many files as you want, see https://git-scm.com/docs/gitattributes#_export_ignore