mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Possible fix for git messages (#4882)
* yank git stuff out * fix tests * Add check for git to reduce warning logs Fixes #4428 * reverse git removal * and more resetting
This commit is contained in:
parent
433ea4d0de
commit
717bb07dcf
@ -93,6 +93,30 @@ def inventreeDjangoVersion():
|
|||||||
return django.get_version()
|
return django.get_version()
|
||||||
|
|
||||||
|
|
||||||
|
git_available: bool = None # is git available and used by the install?
|
||||||
|
|
||||||
|
|
||||||
|
def check_for_git():
|
||||||
|
"""Check if git is available on the install."""
|
||||||
|
global git_available
|
||||||
|
|
||||||
|
if git_available is not None:
|
||||||
|
return git_available
|
||||||
|
|
||||||
|
try:
|
||||||
|
subprocess.check_output('git --version'.split(), stderr=subprocess.DEVNULL)
|
||||||
|
except Exception:
|
||||||
|
git_available = False
|
||||||
|
|
||||||
|
if git_available is None:
|
||||||
|
try:
|
||||||
|
subprocess.check_output('git status'.split(), stderr=subprocess.DEVNULL)
|
||||||
|
git_available = True
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
git_available = False
|
||||||
|
|
||||||
|
|
||||||
def inventreeCommitHash():
|
def inventreeCommitHash():
|
||||||
"""Returns the git commit hash for the running codebase."""
|
"""Returns the git commit hash for the running codebase."""
|
||||||
# First look in the environment variables, i.e. if running in docker
|
# First look in the environment variables, i.e. if running in docker
|
||||||
@ -101,6 +125,9 @@ def inventreeCommitHash():
|
|||||||
if commit_hash:
|
if commit_hash:
|
||||||
return commit_hash
|
return commit_hash
|
||||||
|
|
||||||
|
if not check_for_git():
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return str(subprocess.check_output('git rev-parse --short HEAD'.split()), 'utf-8').strip()
|
return str(subprocess.check_output('git rev-parse --short HEAD'.split()), 'utf-8').strip()
|
||||||
except Exception: # pragma: no cover
|
except Exception: # pragma: no cover
|
||||||
@ -115,6 +142,9 @@ def inventreeCommitDate():
|
|||||||
if commit_date:
|
if commit_date:
|
||||||
return commit_date.split(' ')[0]
|
return commit_date.split(' ')[0]
|
||||||
|
|
||||||
|
if not check_for_git():
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
d = str(subprocess.check_output('git show -s --format=%ci'.split()), 'utf-8').strip()
|
d = str(subprocess.check_output('git show -s --format=%ci'.split()), 'utf-8').strip()
|
||||||
return d.split(' ')[0]
|
return d.split(' ')[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user