Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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