... | ... |
@@ -67,11 +67,11 @@ sub startup { |
67 | 67 |
$r->get('/')->to('#project'); |
68 | 68 |
|
69 | 69 |
# Commit |
70 |
- $r->get('/commit/:diff')->to('#commit'); |
|
70 |
+ $r->get('/commit/#diff')->to('#commit'); |
|
71 | 71 |
|
72 | 72 |
# Commits |
73 |
- $r->get('/commits/:rev', {id => 'HEAD'})->to('#commits'); |
|
74 |
- $r->get('/commits/:rev/(*blob)')->to('#commits'); |
|
73 |
+ $r->get('/commits/#rev', {id => 'HEAD'})->to('#commits'); |
|
74 |
+ $r->get('/commits/#rev/(*blob)')->to('#commits'); |
|
75 | 75 |
|
76 | 76 |
# Branches |
77 | 77 |
$r->get('/branches')->to('#branches'); |
... | ... |
@@ -92,11 +92,11 @@ sub startup { |
92 | 92 |
$r->get('/raw/(*id_file)')->to('#raw'); |
93 | 93 |
|
94 | 94 |
# Archive |
95 |
- $r->get('/archive/(:rev).tar.gz')->to('#archive', archive_type => 'tar'); |
|
96 |
- $r->get('/archive/(:rev).zip')->to('#archive', archive_type => 'zip'); |
|
95 |
+ $r->get('/archive/(#rev).tar.gz')->to('#archive', archive_type => 'tar'); |
|
96 |
+ $r->get('/archive/(#rev).zip')->to('#archive', archive_type => 'zip'); |
|
97 | 97 |
|
98 | 98 |
# Compare |
99 |
- $r->get('/compare/(#diff)')->to('#compare'); |
|
99 |
+ $r->get('/compare/(#rev1)...(#rev2)')->to('#compare'); |
|
100 | 100 |
} |
101 | 101 |
|
102 | 102 |
# File cache |
... | ... |
@@ -129,6 +129,40 @@ sub cmd { |
129 | 129 |
return ($self->bin, "--git-dir=$project"); |
130 | 130 |
} |
131 | 131 |
|
132 |
+sub branch_commits { |
|
133 |
+ my ($self, $rep, $rev1, $rev2) = @_; |
|
134 |
+ |
|
135 |
+ # Command "git diff-tree" |
|
136 |
+ my @cmd = ($self->cmd($rep), 'show-branch', '--all', $rev1, $rev2); |
|
137 |
+ open my $fh, "-|", @cmd |
|
138 |
+ or croak 500, "Open git-show-branch failed"; |
|
139 |
+ |
|
140 |
+ my $commits = []; |
|
141 |
+ my $start; |
|
142 |
+ while (my $line = <$fh>) { |
|
143 |
+ chomp $line; |
|
144 |
+ |
|
145 |
+ if ($start) { |
|
146 |
+ my ($id) = $line =~ /^.*?\[(.+)?\]/; |
|
147 |
+ |
|
148 |
+ next unless $id =~ /^\Q$rev2\E^?$/ || $id =~ /^\Q$rev2\E^[0-9]+$/; |
|
149 |
+ |
|
150 |
+ my $commit = $self->parse_commit($rep, $id); |
|
151 |
+ |
|
152 |
+ push @$commits, $commit; |
|
153 |
+ } |
|
154 |
+ else { |
|
155 |
+ if ($line =~ /^-/) { |
|
156 |
+ $start = 1; |
|
157 |
+ } |
|
158 |
+ } |
|
159 |
+ } |
|
160 |
+ |
|
161 |
+ close $fh or croak 'Reading git-show-branch failed'; |
|
162 |
+ |
|
163 |
+ return $commits; |
|
164 |
+} |
|
165 |
+ |
|
132 | 166 |
sub commits_number { |
133 | 167 |
my ($self, $rep, $ref) = @_; |
134 | 168 |
|
... | ... |
@@ -1,3 +1,36 @@ |
1 |
+<% |
|
2 |
+ # API |
|
3 |
+ my $api = Gitprep::API->new($self); |
|
4 |
+ |
|
5 |
+ # Parameters |
|
6 |
+ my $user = param('user'); |
|
7 |
+ my $project = param('project'); |
|
8 |
+ my $rev = param('rev'); |
|
9 |
+ my $rev1 = param('rev1'); |
|
10 |
+ my $rev2 = param('rev2'); |
|
11 |
+ my $page = param('page') || 0; |
|
12 |
+ my $root_ns = $api->root_ns(config->{root}); |
|
13 |
+ my $rep_ns = "$root_ns/$user/$project.git"; |
|
14 |
+ my $rep = "/$rep_ns"; |
|
15 |
+ |
|
16 |
+ # Git |
|
17 |
+ my $git = $self->app->git; |
|
18 |
+ |
|
19 |
+ # Commits |
|
20 |
+ my $page_count = 30; |
|
21 |
+ my $commits = $git->branch_commits($rep, $rev1, $rev2); |
|
22 |
+ my $commits_count = @$commits; |
|
23 |
+ my $commits_date = {}; |
|
24 |
+ for my $commit (@$commits) { |
|
25 |
+ my $date = $commit->{age_string_date}; |
|
26 |
+ $commits_date->{$date} ||= []; |
|
27 |
+ push @{$commits_date->{$date}}, $commit; |
|
28 |
+ } |
|
29 |
+ |
|
30 |
+ # Global variable |
|
31 |
+ stash(user => $user, project => $project); |
|
32 |
+%> |
|
33 |
+ |
|
1 | 34 |
% layout 'common'; |
2 | 35 |
%= include '/css/common'; |
3 | 36 |
|
... | ... |
@@ -56,6 +89,38 @@ |
56 | 89 |
<div class="commits_number"> |
57 | 90 |
Showing 47 commits by 1 author. |
58 | 91 |
</div> |
92 |
+ |
|
93 |
+ % for my $date (sort keys %$commits_date) { |
|
94 |
+ <div class="commit"> |
|
95 |
+ % my $commits = $commits_date->{$date}; |
|
96 |
+ |
|
97 |
+ <div class="cdate"><%= $date %></div> |
|
98 |
+ % for my $commit (sort {$a->{author_epoch} <=> $b->{author_epoch}} @$commits) { |
|
99 |
+ <div class="ccontent"> |
|
100 |
+ <div class="cfirst"> |
|
101 |
+ <div class="cfirst_left"> |
|
102 |
+ <a class="ubar" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>"> |
|
103 |
+ <%= $commit->{title_short} %> |
|
104 |
+ </a> |
|
105 |
+ </div> |
|
106 |
+ <div class="cfirst_right a_dec_on a_blue"> |
|
107 |
+ <a class="ubar" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>"> |
|
108 |
+ <%= substr($commit->{id}, 0, 10) %> |
|
109 |
+ </a> |
|
110 |
+ </div> |
|
111 |
+ </div> |
|
112 |
+ <div class="csecond"> |
|
113 |
+ <div class="csecond_left">yuki-kimoto authored 7 days ago</div> |
|
114 |
+ <div class="csecond_right"> |
|
115 |
+ <a class="ubar" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>"> |
|
116 |
+ Browse code |
|
117 |
+ </a> |
|
118 |
+ </div> |
|
119 |
+ </div> |
|
120 |
+ </div> |
|
121 |
+ % } |
|
122 |
+ </div> |
|
123 |
+ % } |
|
59 | 124 |
</div> |
60 | 125 |
|
61 | 126 |
%= include '/include/footer'; |
... | ... |
@@ -14,7 +14,6 @@ |
14 | 14 |
|
15 | 15 |
# Parameters |
16 | 16 |
my $root_ns = $api->root_ns(config->{root}); |
17 |
- |
|
18 | 17 |
my $rep_ns = "$root_ns/$user/$project.git"; |
19 | 18 |
my $rep = "/$rep_ns"; |
20 | 19 |
my $home_ns = $api->dirname($rep_ns); |