Fixed src and dst in diff data for files that had been added/deleted/etc.
Dan Brook [Fri, 9 Apr 2010 22:27:57 +0000 (23:27 +0100)]
* Added a link to the diff of a commit in the commit action.
* Tidied up the "path" stuff in the tree action which is no longer used.

lib/Gitalist/Controller/Fragment/Ref.pm
lib/Gitalist/Git/Object/Commit.pm
root/_diff.tt2
root/fragment/ref/commit.tt2
root/ref/tree.tt2

index b4a2181..e537896 100644 (file)
@@ -52,7 +52,6 @@ after tree => sub {
     $c->stash(
         tree      => $tree,
         tree_list => [$repository->list_tree($tree->sha1)],
-        path      => $c->stash->{filename}, # FIXME?
     );
 };
 
index 7ac568b..0445999 100644 (file)
@@ -128,7 +128,7 @@ class Gitalist::Git::Object::Commit
                     next;
                 }
 
-                if (/^index (\w+)\.\.(\w+) (\d+)$/) {
+                if (/^index (\w+)\.\.(\w+)(?: (\d+))?$/) {
                     @{$ret[-1]}{qw(index src dst mode)} = ($_, $1, $2, $3);
                     next
                 }
index 4b217d2..11b4199 100755 (executable)
@@ -7,13 +7,19 @@
 [% FOREACH item IN diff %]
 
 <h4 id="diff[% loop.count %]" class='diff-head'>diff --git [%# FIXME %]
- <a href='[% c.uri_for_action("/ref/blob", [Repository.name, Commit.sha1], item.file) %]' title="Blob">[% item.a %]</a>
- <a href='[% c.uri_for_action("/ref/blob", [Repository.name, Commit.sha1], item.file) %]' title="Blob">[% item.b %]</a>
+ [% IF !item.src.match('^0+$') %]
+   <a href='[% c.uri_for_action("/ref/blob", [Repository.name, item.src]) %]' title="Blob">[% item.a %]</a>
+ [% ELSE %]
+   [% item.a %]
+ [% END %]
+ [% IF !item.dst.match('^0+$') %]
+ <a href='[% c.uri_for_action("/ref/blob", [Repository.name, item.dst]) %]' title="Blob">[% item.b %]</a>
+ [% ELSE %]
+   [% item.b %]
+ [% END %]
 </h4>
 
 
-
-
 <div class='diff-patch'>
        <pre>[% blobs.${loop.index} %]</pre>
 </div>
index 551d103..8560e1f 100755 (executable)
@@ -38,7 +38,7 @@
        <tr>
                <td class='sha1'>[% INCLUDE 'inc/chroma_hash.tt2' sha1 = Commit.sha1.substr(0, 7), hide_sha1_output = 1 %] <div class="sha1_label">Commit</div></td>
                <td>[% Commit.sha1 %]</td>
-               <td class='action-list'></td>
+               <td class='action-list'><a href="[% c.uri_for_action('/ref/diff_fancy', [Repository.name, Commit.sha1]) %]" title="Difference" class="button diff">diff</a></td>
        </tr>
        <tr>
                <td class='sha1'>[% INCLUDE 'inc/chroma_hash.tt2' sha1 = Commit.tree_sha1.substr(0, 7), hide_sha1_output = 1 %] <div class="sha1_label">Tree</div></td>
index b477e0c..6d76c32 100755 (executable)
@@ -1,8 +1 @@
-  [%
-    IF path;
-      INCLUDE 'nav/path.tt2' filename = path;
-    END;
-
-    subinclude('/fragment/ref/tree', c.req.captures, c.req.args.to_path);
-  %]
-
+[% subinclude('/fragment/ref/tree', c.req.captures, c.req.args.to_path) %]