mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
check git version and safe for runtime
This commit is contained in:
parent
c882d1f89b
commit
bae290d605
@ -10,6 +10,7 @@ from maintenance_mode.core import set_maintenance_mode
|
|||||||
|
|
||||||
from InvenTree.ready import isImportingData
|
from InvenTree.ready import isImportingData
|
||||||
from plugin import registry
|
from plugin import registry
|
||||||
|
from plugin.helpers import check_git_version
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger('inventree')
|
logger = logging.getLogger('inventree')
|
||||||
@ -34,3 +35,6 @@ class PluginAppConfig(AppConfig):
|
|||||||
# drop out of maintenance
|
# drop out of maintenance
|
||||||
# makes sure we did not have an error in reloading and maintenance is still active
|
# makes sure we did not have an error in reloading and maintenance is still active
|
||||||
set_maintenance_mode(False)
|
set_maintenance_mode(False)
|
||||||
|
|
||||||
|
# check git version
|
||||||
|
registry.git_is_modern = check_git_version()
|
||||||
|
@ -108,6 +108,26 @@ def get_git_log(path):
|
|||||||
output = 7 * [''] # pragma: no cover
|
output = 7 * [''] # pragma: no cover
|
||||||
return {'hash': output[0], 'author': output[1], 'mail': output[2], 'date': output[3], 'message': output[4], 'verified': output[5], 'key': output[6]}
|
return {'hash': output[0], 'author': output[1], 'mail': output[2], 'date': output[3], 'message': output[4], 'verified': output[5], 'key': output[6]}
|
||||||
|
|
||||||
|
def check_git_version():
|
||||||
|
"""returns if the current git version supports modern features"""
|
||||||
|
|
||||||
|
# get version string
|
||||||
|
try:
|
||||||
|
output = str(subprocess.check_output(['git', '--version'], cwd=os.path.dirname(settings.BASE_DIR)), 'utf-8')
|
||||||
|
except subprocess.CalledProcessError: # pragma: no cover
|
||||||
|
return False
|
||||||
|
|
||||||
|
# process version string
|
||||||
|
try:
|
||||||
|
version = output[12:-1].split(".")
|
||||||
|
if len(version) > 1 and version[0] == '2':
|
||||||
|
if len(version) > 2 and int(version[1]) >= 22:
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class GitStatus:
|
class GitStatus:
|
||||||
"""
|
"""
|
||||||
|
@ -52,6 +52,7 @@ class PluginsRegistry:
|
|||||||
# flags
|
# flags
|
||||||
self.is_loading = False
|
self.is_loading = False
|
||||||
self.apps_loading = True # Marks if apps were reloaded yet
|
self.apps_loading = True # Marks if apps were reloaded yet
|
||||||
|
self.git_is_modern = True # Is a modern version of git available
|
||||||
|
|
||||||
# integration specific
|
# integration specific
|
||||||
self.installed_apps = [] # Holds all added plugin_paths
|
self.installed_apps = [] # Holds all added plugin_paths
|
||||||
|
Loading…
x
Reference in New Issue
Block a user