fix: handle detached head

Workaround for https://github.com/gitpython-developers/GitPython/issues/633
This commit is contained in:
barredterra 2021-07-13 13:11:15 +02:00
parent 93e5398d5d
commit 04094110f5

View file

@ -774,6 +774,7 @@ def get_version(output):
"""Show the versions of all the installed apps."""
from git import Repo
from frappe.utils.commands import render_table
from frappe.utils.change_log import get_app_branch
frappe.init("")
data = []
@ -785,8 +786,8 @@ def get_version(output):
app_info = frappe._dict()
app_info.app = app
app_info.branch = repo.head.ref.name
app_info.commit = repo.head.ref.commit.hexsha[:7]
app_info.branch = get_app_branch(app)
app_info.commit = repo.head.object.hexsha[:7]
app_info.version = getattr(app_hooks, f"{app_info.branch}_version", None) or module.__version__
data.append(app_info)