<% # API my $api = gitprep_api; # Parameters my $user = param('user'); my $project = param('project'); my $from_rev = param('rev1'); my $rev = param('rev2'); my $page = param('page') || 0; # Git my $git = $self->app->git; # Commits my $commits = $git->forward_commits($user, $project, $from_rev, $rev); my $commits_count = @$commits; my $commits_date = {}; my $authors = {}; for my $commit (@$commits) { my $date = $commit->{age_string_date_local}; $commits_date->{$date} ||= []; $authors->{$commit->{author}} = 1; push @{$commits_date->{$date}}, $commit; } my $authors_count = keys %$authors; # Start commit my $start_commit = $git->separated_commit($user, $project, $from_rev, $rev); # End commit my $end_commit = $git->get_commit($user, $project, $rev); if (!$start_commit || !$end_commit) { $self->reply->not_found; return; } # Branches my $branches = $git->branches($user, $project); @$branches = sort { $a->{commit}{age} <=> $b->{commit}{age} } @$branches; # Variables stash id => $end_commit->{id}; stash from_id => $start_commit->{id}; stash rev => $end_commit->{id}; stash from_rev => $start_commit->{id}; layout 'common', title => "Comparing $rev1...$rev2 \x{30fb} $user/$project"; %> %= javascript begin $(document).ready(function () { // Change base branch $('#base-branch-btn').on('click', function () { $('#base-branch-popup') .css('display', 'block') .css('top', '40px') .css('left', '10px') ; }); $('#base-branch-close').on('click', function () { $('#base-branch-popup').css('display', 'none'); }); $('[name=base-branch]').on('keypress', function (e) { // Enter if (e.which == 13) { location.href = '<%= url_for("/$user/$project/compare/") %>' + $(this).val() + '...<%= $rev %>'; } }); // Change compare branch $('#compare-branch-btn').on('click', function () { $('#compare-branch-popup') .css('display', 'block') .css('top', '40px') .css('left', '96px') ; }); $('#compare-branch-close').on('click', function () { $('#compare-branch-popup').css('display', 'none'); }); $('[name=compare-branch]').on('keypress', function (e) { // Enter if (e.which == 13) { location.href = '<%= url_for("/$user/$project/compare/") %>' + '<%= $from_rev %>...' + $(this).val(); } }); }); % end %= include '/include/header';
Compare View
...
% if (keys %$commits_date) {
% for my $date (reverse sort keys %$commits_date) { % my $commits = $commits_date->{$date};
Commits on <%= $date %>
% }
%= include '/include/commit_body'; % } else {
There isn't anything to compare.
% }
%= include '/include/footer';