summaryrefslogtreecommitdiff
path: root/misc/fontbuildlib
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2020-04-04 23:05:03 +0300
committerRasmus Andersson <rasmus@notion.se>2020-04-04 23:05:03 +0300
commitcd4e4bca3af550cda62d27ce0b3c1f5ca4b39974 (patch)
tree6d40643fabc888788337b4ec01b46e65461897b0 /misc/fontbuildlib
parent4519bffb7cd52ce60f4b8e2e7c6ee547c9df78a2 (diff)
downloadinter-cd4e4bca3af550cda62d27ce0b3c1f5ca4b39974.tar.xz
Fixes an issue with missing git hash in version metadata of built fonts. Closes #234
Diffstat (limited to 'misc/fontbuildlib')
-rw-r--r--misc/fontbuildlib/info.py35
1 files changed, 5 insertions, 30 deletions
diff --git a/misc/fontbuildlib/info.py b/misc/fontbuildlib/info.py
index f135f1585..c4236f600 100644
--- a/misc/fontbuildlib/info.py
+++ b/misc/fontbuildlib/info.py
@@ -1,39 +1,11 @@
import subprocess
import re
+import sys
from datetime import datetime
from common import getGitHash, getVersion
from .util import readTextFile, BASEDIR, pjoin
-_gitHash = None
-def getGitHash():
- global _gitHash
- if _gitHash is None:
- _gitHash = ''
- try:
- _gitHash = subprocess.check_output(
- ['git', '-C', BASEDIR, 'rev-parse', '--short', 'HEAD'],
- stderr=subprocess.STDOUT,
- **_enc_kwargs
- ).strip()
- except:
- try:
- # git rev-parse --short HEAD > githash.txt
- _gitHash = readTextFile(pjoin(BASEDIR, 'githash.txt')).strip()
- except:
- pass
- return _gitHash
-
-
-_version = None
-def getVersion():
- global _version
- if _version is None:
- _version = readTextFile(pjoin(BASEDIR, 'version.txt')).strip()
- return _version
-
-
-
def updateFontVersion(font, dummy, isVF):
if dummy:
version = "1.0"
@@ -41,8 +13,11 @@ def updateFontVersion(font, dummy, isVF):
now = datetime(2016, 1, 1, 0, 0, 0, 0)
else:
version = getVersion()
- buildtag = getGitHash()
+ buildtag, buildtagErrs = getGitHash()
now = datetime.utcnow()
+ if buildtag == "" or len(buildtagErrs) > 0:
+ buildtag = "src"
+ print("warning: getGitHash() failed: %r" % buildtagErrs, file=sys.stderr)
versionMajor, versionMinor = [int(num) for num in version.split(".")]
font.info.version = version
font.info.versionMajor = versionMajor