Try to replace copyright year from last commit date

This commit is contained in:
Dmitri Bogomolov 2017-11-07 13:46:23 +02:00
parent b9cd571d9b
commit 20288d4ab4
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
3 changed files with 27 additions and 9 deletions

View File

@ -113,10 +113,11 @@ class AboutDialog(QtGui.QDialog, RetranslateMixin):
def __init__(self, parent=None):
super(AboutDialog, self).__init__(parent)
widgets.load('about.ui', self)
commit = paths.lastCommit()[:7]
last_commit = paths.lastCommit()
version = softwareVersion
commit = last_commit.get('commit')
if commit:
version += '-' + commit
version += '-' + commit[:7]
self.labelVersion.setText(
self.labelVersion.text().replace(
':version:', version
@ -124,6 +125,16 @@ class AboutDialog(QtGui.QDialog, RetranslateMixin):
)
self.labelVersion.setOpenExternalLinks(True)
try:
self.label_2.setText(
self.label_2.text().replace(
'2017', str(last_commit.get('time').year)
))
except AttributeError:
pass
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
class IconGlossaryDialog(QtGui.QDialog, RetranslateMixin):
def __init__(self, parent=None, config=None):

View File

@ -87,7 +87,7 @@ def createSupportMessage(myapp):
myapp.ui.lineEditTo.setText(SUPPORT_ADDRESS)
version = softwareVersion
commit = paths.lastCommit()
commit = paths.lastCommit().get('commit')
if commit:
version += " GIT " + commit

View File

@ -1,5 +1,7 @@
from os import environ, path
import sys
import re
from datetime import datetime
# When using py2exe or py2app, the variable frozen is added to the sys
# namespace. This can be used to setup a different code path for
@ -95,13 +97,18 @@ def tail(f, lines=20):
all_read_text = ''.join(reversed(blocks))
return '\n'.join(all_read_text.splitlines()[-total_lines_wanted:])
def lastCommit():
githeadfile = path.join(codePath(), '..', '.git', 'logs', 'HEAD')
version = ""
if (path.isfile(githeadfile)):
result = {}
if path.isfile(githeadfile):
try:
with open(githeadfile, 'rt') as githead:
version = tail(githead, 1).split()[1]
except IOError:
line = tail(githead, 1)
result['commit'] = line.split()[1]
result['time'] = datetime.fromtimestamp(
float(re.search(r'>\s*(.*?)\s', line).group(1))
)
except (IOError, AttributeError, TypeError):
pass
return version
return result