Skip to content

Commit

Permalink
Build version/Python 3: use with open function when obtaining Git hea…
Browse files Browse the repository at this point in the history
…d/commit for version information construction. Re nvaccess#9038.

Without modifying head/commit values for version info, NVDA will report 'year.major.minor' when running from source. Therefore edit this routine.
  • Loading branch information
josephsl committed Jun 2, 2019
1 parent 609333c commit 1983f8e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/buildVersion.py
Expand Up @@ -18,14 +18,16 @@ def _updateVersionFromVCS():
# The root of the Git working tree will be the parent of this module's directory.
gitDir = os.path.join(os.path.dirname(os.path.dirname(__file__)), ".git")
try:
head = file(os.path.join(gitDir, "HEAD"), "r").read().rstrip()
with open(os.path.join(gitDir, "HEAD"), "r") as f:
head = f.read().rstrip()
if not head.startswith("ref: "):
# Detached head.
version = "source-DETACHED-%s" % head[:7]
return
# Strip the "ref: " prefix to get the ref.
ref = head[5:]
commit = file(os.path.join(gitDir, ref), "r").read().rstrip()
with open(os.path.join(gitDir, ref), "r") as f:
commit = f.read().rstrip()
version = "source-%s-%s" % (
os.path.basename(ref),
commit[:7])
Expand Down

0 comments on commit 1983f8e

Please sign in to comment.