Created
June 11, 2014 20:02
-
-
Save ynsta/0d6e3836347bcdd36221 to your computer and use it in GitHub Desktop.
bashrc: git-delivery shell function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function git-delivery() { | |
git status >/dev/null || return 1 | |
dtag=$(git describe --abbrev=0 --tags 2>/dev/null | git log -1 --pretty='%h') | |
dext='tar' | |
for i; do | |
case $i in | |
-h|--help) | |
cat <<EOF | |
usage: git-delivery [tag] [ext] | |
tag: the tag or revision hash (default: $dtag) | |
ext: the archive extension [zip|tar] (default: $dext) | |
EOF | |
return 1 | |
;; | |
esac | |
done | |
tag=$1; [ ! -z "$tag" ] || tag="${dtag}" | |
ext=$2; [ ! -z "$ext" ] || ext="${dext}" | |
top=$(git rev-parse --show-toplevel) | |
base=$(basename "${top}") | |
cd ${top} | |
top=${top%.git} | |
base=${base%.git} | |
git archive $tag --prefix=$base-$tag/ -o $top-$tag.$ext | |
return $? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment