f4pga/setup: optionally use .gitcommit

Signed-off-by: Unai Martinez-Corral <umartinezcorral@antmicro.com>
This commit is contained in:
Unai Martinez-Corral 2022-08-02 02:20:55 +02:00
parent 2eddad761b
commit b730305701
1 changed files with 5 additions and 0 deletions

View File

@ -55,6 +55,11 @@ def get_requirements(file: Path) -> List[str]:
semver = "0.0.0"
version = None
with (packagePath.parent / '.gitcommit').open("r") as rptr:
sha = rptr.read().strip()
if sha != '$Format:%h$':
version = f'{semver}-{sha}'
git = which('git')
if git is not None:
proc = run(['git', 'rev-parse', 'HEAD'], capture_output=True)