Skip to content

Instantly share code, notes, and snippets.

@mgax
Created November 4, 2010 10:21
Show Gist options
  • Save mgax/662307 to your computer and use it in GitHub Desktop.
Save mgax/662307 to your computer and use it in GitHub Desktop.
Extract an SVN revision number from `git log` and then invoke `python setup.py sdist`
#!/bin/bash
# Extract an SVN revision number from `git log` and then invoke `python setup.py sdist`
prepare_cmd() {
[[ $PYTHON = '' ]] && {
PYTHON='python'
}
REV=`git log -1 | grep -n git-svn-id | perl -e '$_ = <> and /@(\d+) / and print $1'` || {
echo 'failed extract_gitsvn_version'
exit
}
CMD="$PYTHON setup.py egg_info -bdev-$REV sdist"
}
case "$1" in
-h)
echo "usage: $0 [-n | -h]"
echo " -n Dry-run"
echo " -h Print help message"
;;
-n)
prepare_cmd
echo $CMD
;;
*)
prepare_cmd
echo $CMD
$CMD
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment