Programmatically printing git revision and checking for uncommitted changes
- by Andrew Grimm
To ensure that my scientific analysis is reproducible, I'd like to programmatically check if there are any modifications to the code base that aren't checked in, and if not, print out what commit is being used.
For example, if there are uncommitted changes, it should output
Warning: uncommitted changes made. This output may not be reproducible.
Else, produce
Current commit: d27ec73cf2f1df89cbccd41494f579e066bad6fe
Ideally, it should use "plumbing", not "porcelain".