py-cpuinfo icon indicating copy to clipboard operation
py-cpuinfo copied to clipboard

Include git commit hash in version for pre-release

Open workhorsy opened this issue 7 years ago • 1 comments

It would be nice to know the exact git checkout that the code originates from. We can do this by including the git commit hash in the py-cpuinfo version.

The cpuinfo version of a release:

CPUINFO_VERSION = (4, 0, 0)

The cpuinfo version before that release:

CPUINFO_VERSION = (4, 0, 0, 'pre-release', git-hash:a630dd823bbc3a640e666bc7a477fd99da8b72cb')

We can use a git pre-commit hook and sed to replace the old hash in the source code:

git rev-parse HEAD

The git hook can be installed like:

#!/bin/sh

cd .git/hooks/
rm -f pre-commit
ln -s ../../bin/pre-commit pre-commit

workhorsy avatar Jan 25 '18 19:01 workhorsy

I need to do more research into this. I think there may be a better, more standard way of doing this.

workhorsy avatar Jan 25 '18 19:01 workhorsy