aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@manus.(none)>2007-02-20 19:22:14 -0800
committerbnewbold <bnewbold@manus.(none)>2007-02-20 19:22:14 -0800
commit7adab6520975d9a8650a214ca519f2357707bd65 (patch)
treed04da2f2c0829198b1b02e87ca1de71ddb3f8b03
parent3395a94951e7f9dce5c774b7fb38159052751869 (diff)
downloadbnewnet-7adab6520975d9a8650a214ca519f2357707bd65.tar.gz
bnewnet-7adab6520975d9a8650a214ca519f2357707bd65.zip
git_browse: actually moved heads_table and tags_table to seperate files
created shortlog_table
-rw-r--r--bn_django/git_browse/models.py41
-rw-r--r--bn_django/git_browse/templates/git_browse/base.html9
-rw-r--r--bn_django/git_browse/templates/git_browse/repository_info.html4
-rw-r--r--bn_django/git_browse/views.py4
-rw-r--r--static/style/default.css2
-rw-r--r--static/style/git_browse.css39
6 files changed, 78 insertions, 21 deletions
diff --git a/bn_django/git_browse/models.py b/bn_django/git_browse/models.py
index be097f8..db69bfc 100644
--- a/bn_django/git_browse/models.py
+++ b/bn_django/git_browse/models.py
@@ -49,16 +49,47 @@ class Repository(models.Model):
heads = dict()
for h in os.listdir(GITBROWSE_BASE + self.slug + '/.git/refs/heads/'):
f = open(GITBROWSE_BASE + self.slug + '/.git/refs/heads/' + h,'r')
- heads[h] = f.readline()
- f.close
+ heads[h.strip()] = f.readline().strip()
+ f.close()
tags = dict()
for t in os.listdir(GITBROWSE_BASE + self.slug + '/.git/refs/tags/'):
f = open(GITBROWSE_BASE + self.slug + '/.git/refs/tags/' + t,'r')
- tags[t] = f.readline()
- f.close
-
+ tags[t.strip()] = f.readline().strip()
+ f.close()
return (GITPREFIX, heads, tags)
+
+ def shortlog(self):
+ import commands
+
+ GITPREFIX = 'cd ' + GITBROWSE_BASE + self.slug + '; ' + GITCOMMAND \
+ + ' --git-dir=' + GITBROWSE_BASE + self.slug + '/.git '
+ logtxt = commands.getoutput(GITPREFIX + ' log --relative-date --max-count=6 | cat')
+ log_items = logtxt.split('\ncommit ')
+ if (log_items[0] == ''):
+ log_items.pop(0)
+ if (log_items[0].startswith('commit ')):
+ log_items[0] = log_items[0][7:]
+ shortlog = list()
+ for li in log_items:
+ logobj = dict()
+ lines = li.splitlines()
+ if len(lines) < 3: continue
+ logobj['hash'] = lines[0].strip()
+ logobj['shorthash'] = lines[0].strip()[:5]
+ logobj['author'] = lines[1][8:]
+ logobj['date'] = lines[2][8:]
+ if len(lines) > 4:
+ logobj['description'] = lines[4][4:]
+ else:
+ logobj['description'] = '(none)'
+ # here we truncate commit comments for shortlogs
+ logobj['shortdescription'] = logobj['description'][:128]
+ shortlog.append(logobj)
+ return shortlog
+
+
+
class Tree(models.Model):
repo = models.ForeignKey(Repository)
mode = models.CharField("file mode/permissions", blank=False,maxlength=4)
diff --git a/bn_django/git_browse/templates/git_browse/base.html b/bn_django/git_browse/templates/git_browse/base.html
index 93814c1..d23ab55 100644
--- a/bn_django/git_browse/templates/git_browse/base.html
+++ b/bn_django/git_browse/templates/git_browse/base.html
@@ -9,9 +9,11 @@
{% endblock %}
{% block path %}
- <a href="/code/">code</a> &raquo;
+{{ block.super }}
{% if object %}
- <a href="/code/{{ object.slug }}/">{{ object.name }}</a>
+ <a href="/code/{{ object.slug }}/">{{ object.name }}</a>
+ [<a href="/code/{{ object.slug }}/tree/">browse</a>,
+ <a href="/code/{{ object.slug }}/log/">log</a>]
{% endif %}
{% endblock %}
@@ -30,9 +32,6 @@
<a href="/code/{{ object.slug }}/tree/">browse tree</a> - <a href="/code/{{ object.slug }}/log">full log</a>
</span>
<br />
- {% if raw %}
- <pre>{{raw}}</pre>
- {% endif %}
{% else %}
<p>No such repository!</p>
{% endif %}
diff --git a/bn_django/git_browse/templates/git_browse/repository_info.html b/bn_django/git_browse/templates/git_browse/repository_info.html
index 51794d3..f45eeb8 100644
--- a/bn_django/git_browse/templates/git_browse/repository_info.html
+++ b/bn_django/git_browse/templates/git_browse/repository_info.html
@@ -2,9 +2,8 @@
{% block gitbrowse %}
{{ object.description }}
-{% if shortlog %}
<h3>Shortlog (<a href="/code/{{object.slug}}/log/">full log</a>)</h3>
-<pre>{{ shortlog }}</pre>
+{% include "git_browse/shortlog_table" %}
<h3>Heads (<a href="/code/{{object.slug}}/tree/">browse</a>)</h3>
{% include "git_browse/heads_table" %}
<h3>Tags (<a href="/code/{{object.slug}}/tree/">browse</a>)</h3>
@@ -12,5 +11,4 @@
<h3>Filelist (<a href="/code/{{object.slug}}/tree/">browse tree</a>)</h3>
{% if filelist %} <pre class="large">{{ filelist }}</pre>
{% else %}No files!{% endif %}
-{% endif %}
{% endblock %}
diff --git a/bn_django/git_browse/views.py b/bn_django/git_browse/views.py
index d8e01d7..3439c35 100644
--- a/bn_django/git_browse/views.py
+++ b/bn_django/git_browse/views.py
@@ -25,10 +25,10 @@ def repo_info(request, repo,branch=None):
therepo = get_object_or_404(Repository, slug=repo)
(GITPREFIX, heads, tags) = therepo.scan()
- shortlog = commands.getoutput(GITPREFIX + ' log | ' + GITCOMMAND \
- + '-shortlog')
branches = commands.getoutput(GITPREFIX + ' branch')
filelist = commands.getoutput(GITPREFIX + ' ls-files')
+ shortlog = therepo.shortlog()
+
return render_to_response('git_browse/repository_info.html', \
dict(object=therepo, \
filelist=filelist, \
diff --git a/static/style/default.css b/static/style/default.css
index 8c0cd7e..58c3011 100644
--- a/static/style/default.css
+++ b/static/style/default.css
@@ -8,6 +8,8 @@ body {
background-color: #E3E3E3; }
a {
text-decoration: none; }
+a:hover {
+ border-bottom: 1px solid blue; }
a.subtle {
color: black;
text-decoration: none; }
diff --git a/static/style/git_browse.css b/static/style/git_browse.css
index 44b884b..bf9974d 100644
--- a/static/style/git_browse.css
+++ b/static/style/git_browse.css
@@ -8,25 +8,52 @@ pre.large {
table.gitbrowser {
width: 100%;
- border-spacing: 4px;
+ border-spacing: 0px;
+ font-size: 11px;
}
table.gitbrowser tr {
width: 100%;
background-color: #EEEEEE;
}
-table.gitbrowser td {
- margin: 0px;
- margin-bottom: 2px;
-}
td.head {
font-weight: bold;
+ padding-left: 13px;
width: 130px;
overflow: hidden;
}
-
+td.tag {
+ font-weight: bold;
+ padding-left: 13px;
+ width: 130px;
+ overflow: hidden;
+}
+td.date {
+ font-style: italic;
+ width: 90px;
+ overflow: hidden;
+}
+td.author {
+ font-style: italic;
+ width: 100px;
+ overflow: hidden;
+}
+td.description {
+ overflow: hidden;
+}
+td.shorthash {
+ width: 60px;
+ overflow: hidden;
+ text-align: right;
+ font-family: courier;
+}
td.hash {
width: 100px;
overflow: hidden;
text-align: right;
font-family: courier;
}
+
+a.head {
+ color: green; }
+a.tag {
+ color: yellow; }