Commit d641091d authored by Michal Čihař's avatar Michal Čihař

Include Git commit details on Git details page

parent 52a66b5f
{% load i18n %}
<span class="git-details">
{% blocktrans with commit.hexsha as hash %}Commit {{ hash }}{% endblocktrans %}<br />
{% blocktrans with commit.author.name as author %}Authored by {{ author }}{% endblocktrans %}
</span>
...@@ -30,6 +30,20 @@ ...@@ -30,6 +30,20 @@
<p>{% trans "There are some new commits in local Git repository!" %}</p> <p>{% trans "There are some new commits in local Git repository!" %}</p>
{% endif %} {% endif %}
{% if object.subproject_set %}
{% else %}
{% with object.get_last_remote_commit as commit %}
<p>
{% trans "Last remote commit:" %}
<span class="git-commit">
{{ commit.hexsha|slice:":7" }}
{% include "git-commit-info.html" %}
</span>
</p>
{% endwith %}
{% endif %}
<div class="details-accordion"> <div class="details-accordion">
<h3><a href="#">{% trans "Details" %}</a></h3> <h3><a href="#">{% trans "Details" %}</a></h3>
<div> <div>
......
...@@ -294,3 +294,9 @@ img.avatar { ...@@ -294,3 +294,9 @@ img.avatar {
width: 1em; width: 1em;
height: 1em; height: 1em;
} }
span.git-details {
display: none;
}
.ui-tooltip {
max-width: 30em;
}
...@@ -392,6 +392,13 @@ $(function() { ...@@ -392,6 +392,13 @@ $(function() {
}, },
items: "span.tooltip" items: "span.tooltip"
}); });
$(document).tooltip({
content: function() {
var element = $(this).find('.git-details');
return element.html();
},
items: "span.git-commit"
});
if (update_lock) { if (update_lock) {
window.setInterval(function() { window.setInterval(function() {
$.get($('#js-lock').attr('href')); $.get($('#js-lock').attr('href'));
......
...@@ -767,6 +767,12 @@ class SubProject(models.Model): ...@@ -767,6 +767,12 @@ class SubProject(models.Model):
# Fallback to initializing the repository # Fallback to initializing the repository
return git.Repo.init(path) return git.Repo.init(path)
def get_last_remote_commit(self):
'''
Returns latest remote commit we know.
'''
return self.get_repo().commit('origin/master')
def get_repoweb_link(self, filename, line): def get_repoweb_link(self, filename, line):
''' '''
Generates link to source code browser for given file and line. Generates link to source code browser for given file and line.
...@@ -1842,6 +1848,9 @@ class Translation(models.Model): ...@@ -1842,6 +1848,9 @@ class Translation(models.Model):
def get_repo(self): def get_repo(self):
return self.subproject.get_repo() return self.subproject.get_repo()
def get_last_remote_commit(self):
return self.subproject.get_last_remote_commit()
def do_update(self, request=None): def do_update(self, request=None):
return self.subproject.do_update(request) return self.subproject.do_update(request)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment