Skip to content

Instantly share code, notes, and snippets.

@briandk
Created October 3, 2014 22:11
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 briandk/2787f3ee4047e1279fa4 to your computer and use it in GitHub Desktop.
Save briandk/2787f3ee4047e1279fa4 to your computer and use it in GitHub Desktop.
a precommit hook for naive build versioning in R package development
#!/bin/bash
D=`date +%Y%m%d%H%M%S`
branch=`git status|grep -ie 'on branch master'`
if [ -z "$branch" ]; then
cat DESCRIPTION | sed -e 's/^\(Version: [0-9]*\.[0-9]*\).*/\1.'$D'/' > DESCRIPTION.temp
rm DESCRIPTION
mv DESCRIPTION.temp DESCRIPTION
git add DESCRIPTION
fi
@briandk
Copy link
Author

briandk commented Oct 3, 2014

So basically, we're appending the datetime stamp (down to the second) to the version number in the DESCRIPTION file.

Why check whether the branch is master or not? Because in our original workflow all development was done on the dev branch, and we only merged to master for releases. We didn't want releases to have burdensome version numbers, so we exclude the extended version number when on the master branch.

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