diff --git a/Readme.md b/Readme.md index 1b8c603..e2c96e1 100644 --- a/Readme.md +++ b/Readme.md @@ -65,6 +65,7 @@ $ brew install git-extras - `git bug` - `git promote` - `git local-commits` + - `git archive-file` ## git-extras @@ -524,3 +525,7 @@ git obliterate secrets.json ## git-local-commits List all commits on the local branch that have not yet been sent to origin. Any additional arguments will be passed directly to git log. + +## git-archive-file + +Creates an zip archive of the current git repository. The name of the archive will depend on the current HEAD of your git respository. diff --git a/bin/git-archive-file b/bin/git-archive-file new file mode 100755 index 0000000..e9dca7d --- /dev/null +++ b/bin/git-archive-file @@ -0,0 +1,34 @@ +#!/bin/bash + +# extract current branch name +BRANCH=$(git name-rev HEAD 2> /dev/null | awk "{ print \$2 }") + +# get name of the most top folder of current directory, used for the +# output filename +ARCHIVE_NAME=$(basename $(pwd)) + +if [[ $BRANCH = tags* ]]; then + BRANCH=$(git describe) + echo Building for tag \"$BRANCH\" + FILENAME=$ARCHIVE_NAME.$BRANCH.zip +else + echo Building archive on branch \"$BRANCH\" + # get a version string, so archives will not be overwritten when creating + # many of them + VERSION=$(git describe --always --long) + # if not on master append branch name into the filename + if [ "$BRANCH" = "master" ]; then + FILENAME=$ARCHIVE_NAME.$VERSION.zip + else + FILENAME=$ARCHIVE_NAME.$VERSION.$BRANCH.zip + fi +fi + +# combine path and filename +OUTPUT=$(pwd)/$FILENAME + +# building archive +git archive --format zip --output $OUTPUT $BRANCH + +# also display size of the resulting file +echo Saved to \"$FILENAME\" \(`du -h $OUTPUT | cut -f1`\) \ No newline at end of file diff --git a/man/git-archive-file.1 b/man/git-archive-file.1 new file mode 100644 index 0000000..62de801 --- /dev/null +++ b/man/git-archive-file.1 @@ -0,0 +1,37 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "GIT\-ARCHIVE\-FILE" "1" "February 2013" "" "Git Extras" +. +.SH "NAME" +\fBgit\-archive\-file\fR \- Export the current HEAD of the git repository to a archive +. +.SH "SYNOPSIS" +\fBgit\-archive\-file\fR +. +.SH "DESCRIPTION" +Export the current HEAD of the repository into a archive with a identifiable and unique name\. +. +.SH "OPTIONS" +This command does not take any options\. +. +.SH "EXAMPLES" +Archive naming conventions: +. +.P +On any branch: \fBgit\-extras\.1\.7\.0\-110\-gafefba7\.branch\-name\.zip\fR +. +.P +On master branch: \fBgit\-extras\.1\.7\.0\-110\-gafefba7\.zip\fR +. +.P +On a detached HEAD (e\.g\. a tag): \fBgit\-extras\.1\.7\.0\.zip\fR +. +.SH "AUTHOR" +Written by Philipp Klose <\fIme@thehippo\.de\fR> +. +.SH "REPORTING BUGS" +<\fIhttps://github\.com/visionmedia/git\-extras/issues\fR> +. +.SH "SEE ALSO" +<\fIhttps://github\.com/visionmedia/git\-extras\fR> diff --git a/man/git-archive-file.html b/man/git-archive-file.html new file mode 100644 index 0000000..e7f2cf7 --- /dev/null +++ b/man/git-archive-file.html @@ -0,0 +1,120 @@ + + +
+ + +
+ git-archive-file - Export the current HEAD of the git repository to a archive
+
git-archive-file
Export the current HEAD of the repository into a archive with a identifiable and unique name.
+ +This command does not take any options.
+ +Archive naming conventions:
+ +On any branch: git-extras.1.7.0-110-gafefba7.branch-name.zip
On master branch: git-extras.1.7.0-110-gafefba7.zip
On a detached HEAD (e.g. a tag): git-extras.1.7.0.zip
Written by Philipp Klose <me@thehippo.de>
+ +<https://github.com/visionmedia/git-extras/issues>
+ +<https://github.com/visionmedia/git-extras>
+ + +