Skip to content

Instantly share code, notes, and snippets.

@ynsta
Created June 11, 2014 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ynsta/0d6e3836347bcdd36221 to your computer and use it in GitHub Desktop.
Save ynsta/0d6e3836347bcdd36221 to your computer and use it in GitHub Desktop.
bashrc: git-delivery shell function
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