mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
add git commit readout
This commit is contained in:
parent
2960e4486b
commit
fddbaa4629
@ -1,6 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import inspect
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -144,6 +147,17 @@ class NavigationMixin:
|
|||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
|
def get_git_log(path):
|
||||||
|
path = path.replace(os.path.dirname(settings.BASE_DIR), '')[1:]
|
||||||
|
command = ['git', 'log', '-n', '1', "--pretty=format:'%H%n%aN%n%aE%n%ad%n%f'", '--follow', '--', path]
|
||||||
|
try:
|
||||||
|
output = str(subprocess.check_output(command, cwd=os.path.dirname(settings.BASE_DIR), stderr=subprocess.STDOUT), 'utf-8').split('\n')
|
||||||
|
except subprocess.CalledProcessError as _e:
|
||||||
|
print(_e)
|
||||||
|
output = 5 * ['']
|
||||||
|
return {'commit': output[0], 'author': output[1], 'mail': output[2], 'date': output[3], 'message': output[4]}
|
||||||
|
|
||||||
|
|
||||||
class IntegrationPlugin(MixinBase, plugin.InvenTreePlugin):
|
class IntegrationPlugin(MixinBase, plugin.InvenTreePlugin):
|
||||||
"""
|
"""
|
||||||
The IntegrationPlugin class is used to integrate with 3rd party software
|
The IntegrationPlugin class is used to integrate with 3rd party software
|
||||||
@ -151,6 +165,7 @@ class IntegrationPlugin(MixinBase, plugin.InvenTreePlugin):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.add_mixin('base')
|
self.add_mixin('base')
|
||||||
|
self.commit = self.get_plugin_commit()
|
||||||
|
|
||||||
def mixin(self, key):
|
def mixin(self, key):
|
||||||
return key in self._mixins
|
return key in self._mixins
|
||||||
@ -160,3 +175,7 @@ class IntegrationPlugin(MixinBase, plugin.InvenTreePlugin):
|
|||||||
fnc_name = self._mixins.get(key)
|
fnc_name = self._mixins.get(key)
|
||||||
return getattr(self, fnc_name, True)
|
return getattr(self, fnc_name, True)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_plugin_commit(self):
|
||||||
|
path = inspect.getfile(self.__class__)
|
||||||
|
return get_git_log(path)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Name" %}</th>
|
<th>{% trans "Name" %}</th>
|
||||||
<th>{% trans "Author" %}</th>
|
<th>{% trans "Author" %}</th>
|
||||||
|
<th>{% trans "Date" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@ -46,6 +47,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td># TODO</td>
|
<td># TODO</td>
|
||||||
|
<td>{{plugin.commit.date}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Loading…
Reference in New Issue
Block a user