Skip to content

Commit

Permalink
Show commit tags in commit details
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-koch committed Nov 20, 2018
1 parent 9ca692c commit 2a6c988
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion gitover/repos_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,7 @@ def clearOutput(self):
("date", str),
("user", str),
("msg", str),
("tags", list),
("changes", list)))

CommitChange = NamedTuple("CommitChange", (("change", str),
Expand Down Expand Up @@ -1715,13 +1716,14 @@ def commit(self, rev):
LOGGER.debug("Commit details for {} in {}".format(rev, self._path))
repo = git.Repo(self._path)
c = repo.commit(rev)
tags = [t.name for t in repo.tags if c.hexsha == t.commit.hexsha]
msg = c.message.split("\n")[0].strip()
shortrev = repo.git.rev_parse(c.hexsha, short=8)
changes = repo.git.diff_tree(rev, no_commit_id=True, name_status=True,
r=True).split("\n")
changes = [CommitChange(*c.split("\t")) for c in changes if c.strip()]
cd = CommitDetail(rev, shortrev, str(c.committed_datetime), c.author.name, msg,
changes)
tags, changes)
self._commit_cache[rev] = cd
while len(self._commit_cache) > self._commit_cache_max_size:
self._commit_cache.popitem(last=False)
Expand Down Expand Up @@ -1974,6 +1976,7 @@ class CommitDetails(QObject):
dateChanged = pyqtSignal('QString')
userChanged = pyqtSignal('QString')
msgChanged = pyqtSignal('QString')
tagsChanged = pyqtSignal('QStringList')
changesChanged = pyqtSignal(QVariant)

@classmethod
Expand All @@ -1988,6 +1991,7 @@ def __init__(self, parent=None):
self._date = ""
self._user = ""
self._msg = ""
self._tags = []
self._changes = []
self._runnable = None
self.destroyed.connect(lambda: self._cancelRunnable())
Expand All @@ -2014,6 +2018,7 @@ def _updateImpl(self):
self.date = cd.date
self.user = cd.user
self.msg = cd.msg
self.tags = cd.tags
self.changes = [{"change": ch.change, "path": ch.path} for ch in cd.changes]
self._runnable = None

Expand Down Expand Up @@ -2079,6 +2084,16 @@ def msg(self, msg):
self._msg = msg
self.msgChanged.emit(self._msg)

@pyqtProperty('QStringList', notify=tagsChanged)
def tags(self):
return self._tags

@tags.setter
def tags(self, tags):
if tags != self._tags:
self._tags = tags
self.tagsChanged.emit(self._tags)

@pyqtProperty('QVariant', notify=changesChanged)
def changes(self):
return self._changes
Expand Down
1 change: 1 addition & 0 deletions res/qml/BranchDetails.qml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Item {
SelectableTextline {
Layout.fillWidth: true
text: details.msg ? details.msg : ""
label: details.tags.map( function(t) { return "<b>"+t+"</b>";} ).join(" ")
font.family: "courier"
font.pointSize: Theme.fonts.smallPointSize
}
Expand Down

0 comments on commit 2a6c988

Please sign in to comment.