Showing 8 changed files with 150 additions and 171 deletions
+25
lib/Gitprep/Git.pm
... ...
@@ -334,6 +334,31 @@ sub branch_commits {
334 334
   return $commits;
335 335
 }
336 336
 
337
+sub branch_diff {
338
+  my ($self, $user, $project, $branch1, $branch2) = @_;
339
+  
340
+  my @cmd = $self->cmd(
341
+    $user,
342
+    $project,
343
+    'rev-list',
344
+    '--left-right',
345
+    "$branch1...$branch2"
346
+  );
347
+  open my $fh, '-|', @cmd
348
+    or croak "Can't get branch status: @cmd";
349
+  
350
+  my $commits = [];
351
+  while (my $line = <$fh>) {
352
+    if ($line =~ /^>(.+)\s/) {
353
+      my $commit_id = $1;
354
+      my $commit = $self->get_commit($user, $project, $commit_id);
355
+      push @$commits, $commit;
356
+    }
357
+  }
358
+  
359
+  return $commits;
360
+}
361
+
337 362
 sub branch_status {
338 363
   my ($self, $user, $project, $branch1, $branch2) = @_;
339 364
   
+3 -3
templates/commit.html.ep
... ...
@@ -61,7 +61,7 @@
61 61
 %>
62 62
 
63 63
 % layout 'common';
64
-
64
+  
65 65
   %= javascript begin
66 66
     $(document).ready(function () {
67 67
     
... ...
@@ -141,11 +141,11 @@
141 141
     </div>
142 142
     <div class="border-gray" style="border-bottom-left-radius:5px;border-bottom-right-radius:5px;margin-bottom:10px;">
143 143
       <div class="row">
144
-        <div class="span4 padding5">
144
+        <div class="span4" style="padding:5px">
145 145
           <span><b><%= $commit->{author_name} %></b></span>
146 146
           <span class="muted">authored <span title="<%= $commit->{age_string_datetime} %>"><%= $commit->{age_string} %></span>
147 147
         </div>
148
-        <div class="span7 padding5 text-right" style="margin-left:75px">
148
+        <div class="span7 text-right" style="padding:5px;margin-left:75px">
149 149
           % my $parent = $commit->{parent};
150 150
           % my $parents = $commit->{parents};
151 151
           
+1 -1
templates/commits.html.ep
... ...
@@ -86,7 +86,7 @@
86 86
           <div class="border-blue <%= $num eq @$commits - 1 ? 'radius-bottom' : '' %>" style="font-size:12px;border-top:none; padding:1px 5px 5px 5px">
87 87
             <div class="row">
88 88
               <div class="span8">
89
-                <%= $commit->{author_name} %> <span class="muted" title="<%= $commit->{age_string_datetime} %>"><%= $commit->{age_string} %></span>
89
+                <span title="<%= $commit->{author_email} %>"><%= $commit->{author_name} %></span> <span class="muted" title="<%= $commit->{age_string_datetime} %>"><%= $commit->{age_string} %></span>
90 90
               </div>
91 91
               <div class="text-right">
92 92
                 <a class="muted" style="padding-right:18px;font-weight:bold" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">                  Browse code
+84 -66
templates/compare.html.ep
... ...
@@ -5,7 +5,6 @@
5 5
   # Parameters
6 6
   my $user = param('user');
7 7
   my $project = param('project');
8
-  my $rev = param('rev');
9 8
   my $rev1 = param('rev1');
10 9
   my $rev2 = param('rev2');
11 10
   my $page = param('page') || 0;
... ...
@@ -14,7 +13,8 @@
14 13
   my $git = $self->app->git;
15 14
   
16 15
   # Commits
17
-  my $commits = $git->branch_commits($user, $project, $rev1, $rev2);
16
+  my $commits = $git->branch_diff($user, $project, $rev1, $rev2);
17
+  
18 18
   my $commits_count = @$commits;
19 19
   my $commits_date = {};
20 20
   my $authors = {};
... ...
@@ -72,84 +72,102 @@
72 72
     %= include '/include/code_menu', display => 'files';
73 73
     
74 74
     <h2>Compare View</h2>
75
-    <div class="row">
76
-      <div class="span8 muted" style="padding-top:9px">
77
-        Last commit <span title="<%= $commits->[0]{age_string_datetime} %>"><%= $commits->[0]{age_string} %></span>
78
-      </div>
79
-      <div class="text-right">
80
-        <button class="btn"><%= $rev1 %></button>
81
-        ...
82
-        <button class="btn"><%= $rev2 %></button>
75
+    <div class="well" style="padding:9px 10px 9px 10px;margin-bottom:5px">
76
+      <div class="row">
77
+        <div class="span3">
78
+          <div class="radius" style="display:inline-block;background:#add8e6;padding:2px 12px;margin-right:5px"><%= $rev1 %></div>
79
+          ...
80
+          <div class="radius" style="display:inline-block;background:#add8e6;padding:2px 12px;margin-left:5px"><%= $rev2 %></div>
81
+        </div>
82
+        <!--
83
+        <div class="text-right">
84
+          <button class="btn" style="padding:2px 10px">Edit</button>
85
+        </div>
86
+        -->
83 87
       </div>
84 88
     </div>
89
+    <div style="margin-bottom:20px">From here you can compare two points in history. You can even compare tag names and commits.</div>
85 90
     
86 91
     <hr style="margin-top:5px">
87 92
 
88
-    <ul class="nav nav-tabs" id="compare-tab">
89
-      <li class="active"><a href="#commits" data-toggle="tab">Commits</a></li>
90
-      <li><a href="#file-changed" data-toggle="tab">Files Changed</a></li>
91
-    </ul>
93
+    % if (keys %$commits_date) {
92 94
 
93
-    <div class="tab-content">
94
-      <div class="tab-pane active" id="commits">
95
-        <div>
96
-          Showing <%= @$commits %> commits by <%= $authors_count %> author.
97
-        </div>
95
+      <ul class="nav nav-tabs" id="compare-tab">
96
+        <li class="active"><a href="#commits" data-toggle="tab">Commits</a></li>
97
+        <li><a href="#file-changed" data-toggle="tab">Files Changed</a></li>
98
+      </ul>
98 99
 
99
-        % for my $date (reverse sort keys %$commits_date) {
100
-          % my $commits = $commits_date->{$date};
101
-          
102
-          <div class="bk-gray-light border-gray" style="padding:5px;border-bottom:none">
103
-            <%= $date %>
100
+      <div class="tab-content">
101
+        <div class="tab-pane active" id="commits">
102
+          <div>
103
+            Showing <%= @$commits %> commits by <%= $authors_count %> author.
104 104
           </div>
105
-          
106
-          <div style="margin-bottom:20px">
107
-            % for my $commit (sort {$b->{author_epoch} <=> $a->{author_epoch}} @$commits) {
108
-              <div class="border-gray" style="padding:5px">
109
-                <div class="row">
110
-                  <div class="span2">
111
-                    <%= $commit->{author_name} %>
112
-                  </div>
113
-                  <div class="span2">
114
-                    <a class="muted" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
115
-                      <%= $commit->{title_short} %>
116
-                    </a>
117
-                  </div>
118
-                  <div class="span7 text-right">
119
-                    <a href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
120
-                      <%= substr($commit->{id}, 0, 7) %>
121
-                    </a>
105
+
106
+          % for my $date (reverse sort keys %$commits_date) {
107
+            % my $commits = $commits_date->{$date};
108
+            
109
+            <div class="bk-gray-light border-gray" style="padding:5px;border-bottom:none">
110
+              <%= $date %>
111
+            </div>
112
+            
113
+            <div style="margin-bottom:20px">
114
+              % for my $commit (sort {$b->{author_epoch} <=> $a->{author_epoch}} @$commits) {
115
+                <div class="border-gray" style="padding:5px;border-top:none">
116
+                  <div class="row">
117
+                    <div class="span2">
118
+                      <span title="<%= $commit->{author_email} %>"><%= $commit->{author_name} %></span>
119
+                    </div>
120
+                    <div class="span7">
121
+                      <a style="color:#333" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
122
+                        <%= $commit->{title_short} %>
123
+                      </a>
124
+                    </div>
125
+                    <div class="span2 text-right" style="margin-left:80px">
126
+                      <a href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
127
+                        <%= substr($commit->{id}, 0, 7) %>
128
+                      </a>
129
+                    </div>
122 130
                   </div>
123 131
                 </div>
124
-              </div>
125
-            % }
126
-          </div>
127
-        % }
128
-      </div>
129
-      <div class="tab-pane" id="file-changed">
130
-        <div style="margin-bottom:5px">
131
-          Showing <b><%= @$difftrees %> changed files</b>
132
-        </div>
133
-        <div>
134
-          <%= include '/include/difftree', id => $end_commit->{id}, from_id => $start_commit->{id},
135
-            difftrees => $difftrees, parents => [], project_ns => $project %>
132
+              % }
133
+            </div>
134
+          % }
136 135
         </div>
137
-        <div>
136
+        
137
+        <div class="tab-pane" id="file-changed">
138
+          <div style="margin-bottom:5px">
139
+            Showing <b><%= @$difftrees %> changed files</b>
140
+          </div>
141
+          <div>
142
+            <%= include '/include/difftree', id => $end_commit->{id}, from_id => $start_commit->{id},
143
+              difftrees => $difftrees, parents => [], project_ns => $project %>
144
+          </div>
138 145
           <div>
139
-            % for (my $i = 0; $i < @$blobdiffs; $i++) {
140
-              % my $blobdiff = $blobdiffs->[$i];
141
-              <div class="patch" id="<%= $i + 1 %>">
142
-                % my $lines = $blobdiff->{lines};
143
-                % my $file = $blobdiff->{file};
144
-                % my $from_file = $blobdiff->{from_file};
145
-                % $from_file = $file unless defined $from_file;
146
-                % my $status = $blobdiff->{status};
147
-                %= include '/include/blobdiff_body', file => $file, from_file => $from_file, status => $status, lines => $blobdiff->{lines}, project_ns => $project, from_id => $start_commit->{id}, id => $end_commit->{id};
148
-              </div>
149
-            % }
146
+            <div>
147
+              % for (my $i = 0; $i < @$blobdiffs; $i++) {
148
+                % my $blobdiff = $blobdiffs->[$i];
149
+                <div class="patch" id="<%= $i + 1 %>">
150
+                  % my $lines = $blobdiff->{lines};
151
+                  % my $file = $blobdiff->{file};
152
+                  % my $from_file = $blobdiff->{from_file};
153
+                  % $from_file = $file unless defined $from_file;
154
+                  % my $status = $blobdiff->{status};
155
+                  %= include '/include/blobdiff_body', file => $file, from_file => $from_file, status => $status, lines => $blobdiff->{lines}, project_ns => $project, from_id => $start_commit->{id}, id => $end_commit->{id};
156
+                </div>
157
+              % }
158
+            </div>
150 159
           </div>
151 160
         </div>
152 161
       </div>
153
-    </div>
162
+    % } else {
163
+      <div class="well" style="padding:35px">
164
+        <div class="text-center" style="margin-bottom:15px"><b>There isn't anything to compare.</b></div>
165
+
166
+        <div class="text-center muted">
167
+          <b><%= $rev1 %></b> is up to date with all commits from <b><%= $rev2 %></b>.
168
+          Try <a href="<%= url_for("/$user/$project/compare/$rev2...$rev1") %>">switching the base</a> for your comparison.
169
+        </div>
170
+      </div>
171
+    % }
154 172
   </div>
155 173
   %= include '/include/footer';
-95
templates/css/common.html.ep
... ...
@@ -1,8 +1,3 @@
1
-/* Offset */
2
-.offset1-mini {
3
-  margin-left: 88px;
4
-}
5
-
6 1
 /* Font color */
7 2
 .font-black {
8 3
   color: #333;
... ...
@@ -22,40 +17,6 @@
22 17
   background-color:#eee;
23 18
 }
24 19
 
25
-/* Padding */
26
-.vpadding5 {
27
-  padding-top:5px;
28
-  padding-bottom:5px;
29
-}
30
-.padding5 {
31
-  padding:5px;
32
-}      
33
-/* space */
34
-.space5 {
35
-  display:inline-block;
36
-  width:5px;
37
-}
38
-
39
-/* Vritical space */
40
-.vspace5 {
41
-  margin-top:5px;
42
-}
43
-.vspace10 {
44
-  margin-top:10px;
45
-}
46
-.vspace15 {
47
-  margin-top:15px;
48
-}
49
-.vspace20 {
50
-  margin-top:20px;
51
-}
52
-.vspace25 {
53
-  margin-top:25px;
54
-}
55
-.vspace30 {
56
-  margin-top:30px;
57
-}
58
-
59 20
 /* Border radius */
60 21
 .radius-top {
61 22
   border-top-left-radius:4px;
... ...
@@ -72,9 +33,6 @@
72 33
 }
73 34
 
74 35
 /* Border */
75
-.border-bottom-none {
76
-  border-bottom:none;
77
-}
78 36
 .border-gray {
79 37
   border:1px solid #ccc;
80 38
 }
... ...
@@ -84,60 +42,7 @@
84 42
 .border-bottom-gray {
85 43
   border-bottom:1px solid #ccc;
86 44
 }
87
-.border-3-gray {
88
-  border-left:1px solid #ccc;
89
-  border-bottom:1px solid #ccc;
90
-  border-right:1px solid #ccc;
91
-}
92
-
93
-.corner-left-none {
94
-  border-top-left-radius:0;
95
-  border-bottom-left-radius:0;
96
-  margin-left:0;
97
-}
98
-.corner-right-none {
99
-  border-top-right-radius:0;
100
-  border-bottom-right-radius:0;
101
-  margin-right:0;
102
-}
103 45
 
104 46
 .border-blue {
105 47
   border:1px solid #c5d5dd;
106 48
 }
107
-
108
-.border-blue-light {
109
-  
110
-}
111
-
112
-/* Commit page */
113
-
114
-  .file-add {
115
-    margin-left:3px;
116
-    padding:1px;
117
-    line-height:10px;
118
-    display:inline-block;
119
-    color:#32CD32;
120
-    border:2px #32CD32 solid;
121
-    font-weight:bold;
122
-  }
123
-
124
-  .file-del {
125
-    margin-left:3px;
126
-    padding:1px;
127
-    line-height:10px;
128
-    display:inline-block;
129
-    color:red;
130
-    border:2px red solid;
131
-    font-weight:bold;
132
-  }
133
-
134
-  .file-modified {
135
-    margin-left:3px;
136
-    padding:1px;
137
-    line-height:10px;
138
-    display:inline-block;
139
-    color:#A9A9A9;
140
-    border:2px #A9A9A9 solid;
141
-    font-weight:bold;
142
-    font-size:90%;
143
-  }
-1
templates/include/blobdiff_body.html.ep
... ...
@@ -59,4 +59,3 @@
59 59
     % }
60 60
   </table>
61 61
 </div>
62
-<div class="vspace20"></div>
+33
templates/include/difftree.html.ep
... ...
@@ -1,3 +1,36 @@
1
+%= stylesheet begin
2
+  .file-add {
3
+    margin-left:3px;
4
+    padding:1px;
5
+    line-height:10px;
6
+    display:inline-block;
7
+    color:#32CD32;
8
+    border:2px #32CD32 solid;
9
+    font-weight:bold;
10
+  }
11
+
12
+  .file-del {
13
+    margin-left:3px;
14
+    padding:1px;
15
+    line-height:10px;
16
+    display:inline-block;
17
+    color:red;
18
+    border:2px red solid;
19
+    font-weight:bold;
20
+  }
21
+
22
+  .file-modified {
23
+    margin-left:3px;
24
+    padding:1px;
25
+    line-height:10px;
26
+    display:inline-block;
27
+    color:#A9A9A9;
28
+    border:2px #A9A9A9 solid;
29
+    font-weight:bold;
30
+    font-size:90%;
31
+  }
32
+% end
33
+  
1 34
 <table style="margin-bottom:10px">
2 35
   
3 36
   % my $has_header = @$difftrees && @$parents > 1 && stash('action') eq 'commitdiff';
+4 -5
templates/project-settings.html.ep
... ...
@@ -188,7 +188,7 @@
188 188
           Settings
189 189
         </h4>
190 190
       </div>
191
-      <div class="padding5 border-gray" style="border-top:none">
191
+      <div class="border-gray" style="padding:5px;border-top:none">
192 192
         <div >Repository Name</div>
193 193
         <div>
194 194
           %= text_field 'renamed-project' => $project, style => 'margin-top:9px';
... ...
@@ -197,7 +197,7 @@
197 197
           </a>
198 198
         </div>
199 199
       </div>
200
-      <div class="padding5 border-gray" style="border-top:none">
200
+      <div class="border-gray" style="padding:5px;border-top:none">
201 201
         <div >Description</div>
202 202
         <div>
203 203
           % my $description = $git->description($user, $project);
... ...
@@ -209,7 +209,7 @@
209 209
           Savaed!
210 210
         </div>
211 211
       </div>
212
-      <div class="border-gray padding5" style="border-top:none">
212
+      <div class="border-gray" style="padding:5px;border-top:none">
213 213
         Default Branch
214 214
         % my $branches = $git->branches($user, $project);
215 215
         % my $branch_names = [map { $_->{name} } @$branches];
... ...
@@ -222,7 +222,7 @@
222 222
       <div class="border-gray bk-gray-light" style="background-color:red;padding-left:5px">
223 223
         <h4 style="color:white">Danger Zone</h4>
224 224
       </div>
225
-      <div class="padding5 border-gray" style="border-top:none">
225
+      <div class="border-gray" style="padding:5px;border-top:none">
226 226
         <div><b>Delete this repository</b></div>
227 227
         <span class="muted">
228 228
           Once you delete a repository, there is no going back.
... ...
@@ -292,5 +292,4 @@
292 292
     </div>
293 293
   </div>
294 294
 
295
-
296 295
   %= include '/include/footer';