Skip to content

Instantly share code, notes, and snippets.

@electblake
Last active August 29, 2015 14:07
Show Gist options
  • Save electblake/9a51bc86c0943fd1dd23 to your computer and use it in GitHub Desktop.
Save electblake/9a51bc86c0943fd1dd23 to your computer and use it in GitHub Desktop.
automatically generate RELEASE version and revision
#!/bin/bash
## Automatically generate RELEASE version and revision
##
## Example:
## Given a most recent tag of `0.0.1` in git, this hook maintains a file like `RELEASE` of contents `0.0.1.rev-94`
## Install:
## mv pre-commit.sh .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit
exec 1>&2
revisioncount=`git log --oneline | wc -l`
projectversion=`git describe --tags --long`
cleanversion=${projectversion%%-*}
# VERSION="$projectversion.rev-$revisioncount"
VERSION="$cleanversion.rev-$revisioncount"
FOOTER='RELEASE'
echo $VERSION > $FOOTER
git add RELEASE
@electblake
Copy link
Author

given a most recent tag of v0.0.1 in git, this hook maintains a file like RELEASE of contents v0.0.1.rev-94

@electblake
Copy link
Author

@todo - add a visual print-out to developers after commit (you are on this rev123)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment