summaryrefslogtreecommitdiff
path: root/misc
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
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')
-rwxr-xr-xmisc/fontbuild2
-rw-r--r--misc/fontbuildlib/info.py35
-rw-r--r--misc/tools/common.py15
3 files changed, 13 insertions, 39 deletions
diff --git a/misc/fontbuild b/misc/fontbuild
index ea9f48f5d..0bc87a599 100755
--- a/misc/fontbuild
+++ b/misc/fontbuild
@@ -21,7 +21,7 @@ from glyphsLib.interpolation import apply_instance_data
from fontbuildlib import FontBuilder
from fontbuildlib.util import mkdirs, loadTTFont
-from fontbuildlib.info import setFontInfo, updateFontVersion
+from fontbuildlib.info import setFontInfo
from fontbuildlib.name import setFamilyName, renameStylesGoogleFonts
log = logging.getLogger(__name__)
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
diff --git a/misc/tools/common.py b/misc/tools/common.py
index 8f25f1989..33114673d 100644
--- a/misc/tools/common.py
+++ b/misc/tools/common.py
@@ -36,23 +36,22 @@ def readTextFile(filename):
_gitHash = None
-def getGitHash():
+_gitHashErrs = []
+def getGitHash(): # returns tuple (hash :string, errors :string[])
global _gitHash
if _gitHash is None:
_gitHash = ''
+ args = ['git', '-C', BASEDIR, 'rev-parse', '--short', 'HEAD']
try:
- _gitHash = subprocess.check_output(
- ['git', '-C', BASEDIR, 'rev-parse', '--short', 'HEAD'],
- stderr=subprocess.STDOUT,
- **_enc_kwargs
- ).strip()
+ _gitHash = subprocess.check_output(args, stderr=subprocess.STDOUT, **_enc_kwargs).strip()
except:
+ _gitHashErrs.append(sys.exc_info()[0])
try:
# git rev-parse --short HEAD > githash.txt
_gitHash = readTextFile(pjoin(BASEDIR, 'githash.txt')).strip()
except:
- pass
- return _gitHash
+ _gitHashErrs.append(sys.exc_info()[0])
+ return (_gitHash, _gitHashErrs)
_version = None