Enhace commit info presentation.

portnov [2008-06-11 05:30:50]
Enhace commit info presentation.
Filename
pygit/pygit.py
pygit/views.py
templates/git_diff.html
diff --git a/pygit/pygit.py b/pygit/pygit.py
index 876e898..f0988d1 100644
--- a/pygit/pygit.py
+++ b/pygit/pygit.py
@@ -115,3 +115,13 @@ def commits_stats(rid,branch='master'):
   r = open_repo(rid)
   d = [c.authored_date[:3] for c in r.commits(branch,max_count=100)]
   return [(date(t[0]),t[1]) for t in uniq(d)][:20]
+
+def commit_stats(rid,cid):
+  r = open_repo(rid)
+  c = r.commit(cid)
+  return c.stats.total, c.stats.files
+
+def commit_message(rid,cid):
+  r = open_repo(rid)
+  c = r.commit(cid)
+  return c.message
diff --git a/pygit/views.py b/pygit/views.py
index 4ea9ae0..1801f58 100644
--- a/pygit/views.py
+++ b/pygit/views.py
@@ -89,18 +89,26 @@ def diff(request,rid,branch,cid,path=None):
       else:
         return line
     lines = map(escape,data.split('\n'))
-    return diff[0], '\n'.join(map(format_line,lines))
+    return diff[0], '\n'.join(map(format_line,lines)), diff[2]

+  message = pygit.commit_message(rid,cid)
+  total,files = pygit.commit_stats(rid,cid)
   if not path:
     ds = pygit.diff_all(rid,cid)
+    if ds:
+      ds = [(d[0],d[1], files[d[0]]) for d in ds]
   else:
     ds = pygit.diff_path(rid,path,cid)
+    if ds:
+      ds[0] = (ds[0][0], ds[0][1], files[path])
   repo = repo_rid(rid)
   ds = map(format_diff,ds)
   return render_it('git_diff.html',
     {'repo': repo,
+     'message': message,
      'branch': branch,
      'path': path,
      'cid': cid,
+     'total_stats': total,
      'diffs': ds},
     request)
diff --git a/templates/git_diff.html b/templates/git_diff.html
index 71ff04e..de1f8d0 100644
--- a/templates/git_diff.html
+++ b/templates/git_diff.html
@@ -5,9 +5,13 @@
 {% block git %}

 <h2>Diff: #{{cid}}{% if path %} {{path}}{% endif %}</h2>
+<p><a href='/git/diff/{{repo.rid}}/{{branch}}/{{cid}}/'>Коммит: {{message}}</a></p>
+<p>Всего файлов: {{total_stats.files}}, всего строк: {{total_stats.lines}},
+всего новых строк: {{total_stats.insertions}}, всего удалено строк: {{total_stats.deletions}}</p>
 {% autoescape off %}
-{% for file,diff in diffs %}
+{% for file,diff,stats in diffs %}
   <h3><a href='/git/blame/{{repo.rid}}/{{branch}}/{{file}}/'>{{file}}</a></h3>
+  <p>Новых строк: {{stats.insertions}}, удалено строк: {{stats.deletions}}</p>
   <code><pre>
   {{diff}}
   </pre></code>
ViewGit