Git head information in version
- About dialog now shows the git head - git head check has been improved to point to the head rather than the previous commit
This commit is contained in:
parent
2c72b337c1
commit
a381f75b4b
|
@ -4004,7 +4004,8 @@ class aboutDialog(QtGui.QDialog):
|
||||||
self.ui = Ui_aboutDialog()
|
self.ui = Ui_aboutDialog()
|
||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.ui.labelVersion.setText('version ' + softwareVersion)
|
self.ui.label.setText("PyBitmessage " + softwareVersion)
|
||||||
|
self.ui.labelVersion.setText(paths.lastCommit())
|
||||||
|
|
||||||
|
|
||||||
class regenerateAddressesDialog(QtGui.QDialog):
|
class regenerateAddressesDialog(QtGui.QDialog):
|
||||||
|
|
|
@ -34,16 +34,17 @@ class Ui_aboutDialog(object):
|
||||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
|
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
|
||||||
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
|
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
|
||||||
self.label = QtGui.QLabel(aboutDialog)
|
self.label = QtGui.QLabel(aboutDialog)
|
||||||
self.label.setGeometry(QtCore.QRect(70, 126, 111, 20))
|
self.label.setGeometry(QtCore.QRect(10, 106, 341, 20))
|
||||||
font = QtGui.QFont()
|
font = QtGui.QFont()
|
||||||
font.setBold(True)
|
font.setBold(True)
|
||||||
font.setWeight(75)
|
font.setWeight(75)
|
||||||
self.label.setFont(font)
|
self.label.setFont(font)
|
||||||
self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
self.label.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter)
|
||||||
self.label.setObjectName(_fromUtf8("label"))
|
self.label.setObjectName(_fromUtf8("label"))
|
||||||
self.labelVersion = QtGui.QLabel(aboutDialog)
|
self.labelVersion = QtGui.QLabel(aboutDialog)
|
||||||
self.labelVersion.setGeometry(QtCore.QRect(190, 126, 161, 20))
|
self.labelVersion.setGeometry(QtCore.QRect(10, 116, 341, 41))
|
||||||
self.labelVersion.setObjectName(_fromUtf8("labelVersion"))
|
self.labelVersion.setObjectName(_fromUtf8("labelVersion"))
|
||||||
|
self.labelVersion.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter)
|
||||||
self.label_2 = QtGui.QLabel(aboutDialog)
|
self.label_2 = QtGui.QLabel(aboutDialog)
|
||||||
self.label_2.setGeometry(QtCore.QRect(10, 150, 341, 41))
|
self.label_2.setGeometry(QtCore.QRect(10, 150, 341, 41))
|
||||||
self.label_2.setAlignment(QtCore.Qt.AlignCenter)
|
self.label_2.setAlignment(QtCore.Qt.AlignCenter)
|
||||||
|
|
|
@ -87,13 +87,9 @@ def createSupportMessage(myapp):
|
||||||
myapp.ui.lineEditTo.setText(SUPPORT_ADDRESS)
|
myapp.ui.lineEditTo.setText(SUPPORT_ADDRESS)
|
||||||
|
|
||||||
version = softwareVersion
|
version = softwareVersion
|
||||||
githeadfile = path.join(paths.codePath(), '..', '.git', 'ORIG_HEAD')
|
commit = paths.lastCommit()
|
||||||
if (path.isfile(githeadfile)):
|
if commit:
|
||||||
try:
|
version += " GIT " + commit
|
||||||
with open(githeadfile, 'rt') as githead:
|
|
||||||
version += " GIT " + githead.readline().rstrip()
|
|
||||||
except IOError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
os = sys.platform
|
os = sys.platform
|
||||||
if os == "win32":
|
if os == "win32":
|
||||||
|
|
37
src/paths.py
37
src/paths.py
|
@ -68,3 +68,40 @@ def codePath():
|
||||||
codePath = path.dirname(__file__)
|
codePath = path.dirname(__file__)
|
||||||
return codePath
|
return codePath
|
||||||
|
|
||||||
|
def tail(f, lines=20):
|
||||||
|
total_lines_wanted = lines
|
||||||
|
|
||||||
|
BLOCK_SIZE = 1024
|
||||||
|
f.seek(0, 2)
|
||||||
|
block_end_byte = f.tell()
|
||||||
|
lines_to_go = total_lines_wanted
|
||||||
|
block_number = -1
|
||||||
|
blocks = [] # blocks of size BLOCK_SIZE, in reverse order starting
|
||||||
|
# from the end of the file
|
||||||
|
while lines_to_go > 0 and block_end_byte > 0:
|
||||||
|
if (block_end_byte - BLOCK_SIZE > 0):
|
||||||
|
# read the last block we haven't yet read
|
||||||
|
f.seek(block_number*BLOCK_SIZE, 2)
|
||||||
|
blocks.append(f.read(BLOCK_SIZE))
|
||||||
|
else:
|
||||||
|
# file too small, start from begining
|
||||||
|
f.seek(0,0)
|
||||||
|
# only read what was not read
|
||||||
|
blocks.append(f.read(block_end_byte))
|
||||||
|
lines_found = blocks[-1].count('\n')
|
||||||
|
lines_to_go -= lines_found
|
||||||
|
block_end_byte -= BLOCK_SIZE
|
||||||
|
block_number -= 1
|
||||||
|
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)):
|
||||||
|
try:
|
||||||
|
with open(githeadfile, 'rt') as githead:
|
||||||
|
version = tail(githead, 1).split()[1]
|
||||||
|
except IOError:
|
||||||
|
pass
|
||||||
|
return version
|
||||||
|
|
Loading…
Reference in New Issue
Block a user