Package: gittar
Gittar creates a git commit from a directory or an archive, allowing you to
store a sequence of selective filesystem-snapshots as git commits.Why?The initial use case forgittarwas storing a compiled version of an
application in a seperate root inside a git repository. Here’s an example:Assume you have a webapplication that needs to compile its assets before being
deployed. You do not want to have to install a lot of LESS or JS compilers, CSS
minifiers, etc. on your production environment.First, you run your build tool (e.g.sconswhen usingthe scons-tools web
module), now your app is inside the
directorymyapp, including the compiled static files, while the source
files reside outside themyappdirectory.Now, you can run:gittar -b web file:myappThis will create a new commit containing everything inside themyappdirectory. If the branchwebdoes not exist, it will be created and will
point to the new commit, which will have no parent. If the branch did exist
before, the new commit will have it as a parent and the branch will be updated.The hash of the new commit will be printed to stdout. If the-boption is
not specified, this is the only way to reach the commit.A simple application for this is deploying toheroku.
Build your app, add a newgittar-commit to the web branch and push it usinggit push heroku web:master.Schemesgittarcan add files from ZIP-Archives, tar-Archives or plain directories
and files.All sources for inclusion are specified using the following syntax:scheme:arg1:arg2:...:named_arg1=value1:named_arg2=value2:...A scheme is one offile,ziportar. The arguments and named
arguments are passed on to the sources collecting the files and have meanings
depending on the scheme.Multiple schemes can be specified in a single command.The file-schemeA single file or a directory can be added as follows:gittar file:myfile file:/my/home/special_file file:/some/directoryThis will addmyfileto the commit with the pathmyfile. The file/my/home/special_filewill also be added, but namedspecial_file(no
path) inside the commit.Assuming/some/directoryis a directory, all files in it will be added
recursively, without the/some/path prefix. Example: A file/some/directory/foo/barwill be added asdirectory/foo/barto the
commit.Similarities and differences to tarSpecifyingfile:targets is similiar to tar, with one key differences:
Instead of adding absolute paths,gittarwill strip any path information
(but keep subdirectory trees intact).Specifically,gittarwill never change pathnames depending on your current
working directory.Wildcards and directories as rootSince directories are added recursively and always kept in the relative path,
it’s not possible this way to add a directory as the root. One solution is to
use wildcards (note the quotes to prevent wildcard expansion by the shell):gittar 'file:/some/directory/*'If there are three files in/some/directorynameda_file,a_dirandfoo, the command above will be logically expanded to:gittar 'file:/some/directory/a_file' 'file:/some/directory/a_dir' 'file:/some/directory/foo'This will result ina_filebeing added to the root of the commit.Note that wildcard-expansion is done UNIX-style using theglobmodule.
Files starting with a dot (.) are not included using*. To add all
files in a directory/fooand not having them as subdirectories, you need
to use the following command:gittar 'file:/foo/*' 'file:/foo/.*'The zip-schemeAdds the contents of a zip-Archive:gittar zip:/path/to/some/archive.zipThis will add all files inside/path/to/some/archive.zipwith their
relative paths to the commit.The tar-schemeWorks fairly similiar to thezip-scheme, but for tar archives. Automatic
detection of compression is done. Example:gittar tar:somearchive.tar tar:/another/archive.tar.bz2Common OptionsExtra options can be specififed, some are valid for all sources.Inclusion/ExclusionTheincludeandexcludeoptions can be used to specify which files
should be included in the commit. Example:gittar tar:myarchive.tar:include=*.css:include=output/*.html:exclude=~*Note: You will most likely have to enter this with backslash-escaped asterisks
(\*) on your shell.The command above will include all CSS files and all HTML files from the output
folder, provided they do not start with a tilde``~``.If no include option is given all not-excluded files are included.Regular expressionsTheincludeandexcludecommands use UNIX shell patterns. You can use
python (Perl-like) regular expressions by usingrincludeandrexcludeinstead.