Skip to content

Commit

Permalink
Provide a better description of development versions
Browse files Browse the repository at this point in the history
Use `git describe` to provide the version text for development
versions.
  • Loading branch information
Nick-Hall committed Feb 7, 2025
1 parent f5e551c commit 2a046b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
10 changes: 4 additions & 6 deletions gramps/gen/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Copyright (C) 2000-2006 Donald N. Allingham
# Copyright (C) 2012 Doug Blank
# Copyright (C) 2013 John Ralls <[email protected]>
# Copyright (C) 2025 Nick Hall
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -173,14 +174,11 @@
#
# -------------------------------------------------------------------------
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))

sys.path.insert(0, ROOT_DIR)
git_revision = get_git_revision(ROOT_DIR).replace("\n", "")
if sys.platform == "win32" and git_revision == "":
git_revision = get_git_revision(os.path.split(ROOT_DIR)[1])

git_revision = get_git_revision()
if DEV_VERSION:
VERSION += git_revision
# VERSION += "-1"
VERSION = git_revision

#
# Glade files
Expand Down
13 changes: 7 additions & 6 deletions gramps/gen/git_revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2012 Doug Blank <[email protected]>
# Copyright (C) 2025 Nick Hall
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -20,18 +21,18 @@
#

"""
Find the latest git revision.
Use `git describe` to obtain a description of the revision.
"""

import subprocess


def get_git_revision(path=""):
def get_git_revision():
"""
Return the short commit hash of the latest commit.
Return a description of the latest commit.
"""
stdout = ""
command = ["git", "log", "-1", "--format=%h", path]
command = ["git", "describe"]
try:
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = proc.communicate()
Expand All @@ -43,6 +44,6 @@ def get_git_revision(path=""):
stdout = stdout.decode("utf-8", errors="replace")
except UnicodeDecodeError:
pass
return "-" + stdout if stdout else ""
else: # no output from git log
return stdout
else: # no output from git describe
return ""

0 comments on commit 2a046b7

Please sign in to comment.