Showing 4 changed files with 199 additions and 2 deletions
+4 -1
lib/Gitprep.pm
... ...
@@ -374,9 +374,12 @@ sub startup {
374 374
             # Home
375 375
             $r->get('/' => sub { shift->render_maybe('/tree') });
376 376
 
377
-            # Tags
377
+            # Pull requests
378 378
             $r->get('/pulls' => sub { shift->render_maybe('/pulls') })->to(tab => 'pulls');
379 379
             
380
+            # Pull request
381
+            $r->any('/pull/:row_id' => sub { shift->render_maybe('/pull') })->to(tab => 'pulls');
382
+            
380 383
             # Commit
381 384
             $r->get('/commit/*diff' => sub { shift->render_maybe('/commit') });
382 385
 
+22
public/css/common.css
... ...
@@ -35,6 +35,28 @@
35 35
   box-sizing: border-box;
36 36
 }
37 37
 
38
+.pull-request-form {
39
+  border:1px solid #95c97e;
40
+  border-radius:3px;
41
+}
42
+.pull-request-form-title {
43
+  padding:10px;
44
+}
45
+.pull-request-form-description {
46
+  padding:10px;
47
+  color:#767676;
48
+}
49
+.pull-request-form-button {
50
+  padding:10px;
51
+  border-top:1px solid #d8d8d8;
52
+}
53
+.pulls-title a {
54
+  color:black;
55
+}
56
+.pulls-title a:hover {
57
+  color:blue;
58
+}
59
+
38 60
 .pulls-button-container {
39 61
   text-align:right;
40 62
   margin-bottom:10px;
+170
templates/pull.html.ep
... ...
@@ -0,0 +1,170 @@
1
+<%
2
+  # API
3
+  my $api = gitprep_api;
4
+
5
+  # Parameters
6
+  my $user = param('user');
7
+  my $project = param('project');
8
+  my $row_id = param('row_id');
9
+  
10
+  # Git
11
+  my $git = $self->app->git;
12
+  
13
+  # Pull requests
14
+  my $pull_request = app->dbi->model('pull_request')->select(
15
+    [
16
+      {__MY__ => '*'},
17
+      {user => ['id']}
18
+    ],
19
+    where => {'pull_request.row_id' => $row_id}
20
+  )->one;
21
+  
22
+  my $from_rev = $pull_request->{branch1};
23
+  my $rev = $pull_request->{branch2};
24
+  
25
+  # Commits
26
+  my $commits = $git->forward_commits(app->rep_info($user, $project), $from_rev, $rev);
27
+  my $commits_count = @$commits;
28
+  my $commits_date = {};
29
+  my $authors = {};
30
+  for my $commit (@$commits) {
31
+    my $date = $commit->{age_string_date_local};
32
+    $commits_date->{$date} ||= [];
33
+    $authors->{$commit->{author}} = 1;
34
+    push @{$commits_date->{$date}}, $commit;
35
+  }
36
+  my $authors_count = keys %$authors;
37
+
38
+  # Start commit
39
+  my $start_commit = $git->separated_commit(app->rep_info($user, $project), $from_rev, $rev);
40
+
41
+  # End commit
42
+  my $end_commit = $git->get_commit(app->rep_info($user, $project), $rev);
43
+
44
+  # Variables
45
+  stash id => $end_commit->{id};
46
+  stash from_id => $start_commit->{id};
47
+  stash rev => $end_commit->{id};
48
+  stash from_rev => $start_commit->{id};
49
+%>
50
+
51
+% layout 'common', title => "Pull Requests Tags \x{30fb} $user/$project";
52
+  
53
+  %= include '/include/header';
54
+  
55
+  <div class="container">
56
+    <div style="font-size:23px;margin-top:20px;margin-bottom:9px;">
57
+      <%
58
+        my $pull_title = $pull_request->{branch2};
59
+        $pull_title =~ s/_/ /g;
60
+        $pull_title = ucfirst $pull_title;
61
+      %>
62
+      
63
+      <%= $pull_title %> <span style="color:#767676;">#<%= $pull_request->{row_id} %></span>
64
+    </div>
65
+    <div>
66
+      <div style="display:inline-block;color:white;margin-right:4px;">
67
+        % if ($pull_request->{open}) {
68
+          <div style="background:#6cc644;padding:4px 8px;border-radius:3px;">
69
+            Open
70
+          </div>
71
+        % } else {
72
+          <div style="background:red;padding:4px 8px;border-radius:3px;">
73
+            Closed
74
+          </div>
75
+        % }
76
+      </div>
77
+      % my $open_user_id = $pull_request->{'user.id'};
78
+      <a style="color:#333333;font-weight:bold" href="<%= url_for("/$open_user_id") %>"><%= $open_user_id %></a> 
79
+      <span style="color:#767676">
80
+        wants to merge <%= $commits_count %> commits
81
+        into <%= $pull_request->{branch1} %> from <%= $pull_request->{branch2} %>
82
+      </span>
83
+    </div>
84
+    <div>
85
+      <ul class="compare-header">
86
+        <li>
87
+          <b><%= @$commits %></b> <span>commit</span>
88
+        </li>
89
+        <li>
90
+          <b><%= $authors_count %></b> <span>contributor</span>
91
+        </li>
92
+        <li>
93
+          
94
+        </li>
95
+        <li>
96
+          
97
+        </li>
98
+      </ul>
99
+      
100
+      <div class="commits">
101
+        % for my $date (reverse sort keys %$commits_date) {
102
+          % my $commits = $commits_date->{$date};
103
+          
104
+          <div class="commit-date">
105
+            <i class="icon-off"></i><span>Commits on <%= $date %></span>
106
+          </div>
107
+          
108
+          <ul class="compare-commits-date-container">
109
+            % for my $commit (sort {$b->{author_epoch} <=> $a->{author_epoch}} @$commits) {
110
+              <%
111
+                my $commit_author_mail = $commit->{author_email};
112
+                my $commit_author_id = app->dbi->model('user')->select(
113
+                  'id',
114
+                  where => {mail => $commit_author_mail}
115
+                )->value;
116
+              %>
117
+              <li>
118
+                <div class="compare-commits-author">
119
+                  <span title="<%= $commit->{author_email} %>">
120
+                    % if (defined $commit_author_id) {
121
+                      <a href="<%= url_for("/$commit_author_id") %>"><%= $commit_author_id %></a>
122
+                    % } else {
123
+                      <%= $commit->{author_name} %>
124
+                    % }
125
+                  </span>
126
+                </div>
127
+                <div class="compare-commits-commit-title">
128
+                  <a style="color:#333" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
129
+                    <%= $commit->{title_short} %>
130
+                  </a>
131
+                </div>
132
+                <div class="compare-commits-commit-id">
133
+                  <a href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
134
+                    <%= substr($commit->{id}, 0, 7) %>
135
+                  </a>
136
+                </div>
137
+              </li>
138
+            % }
139
+          </ul>
140
+        % }
141
+      </div>
142
+      
143
+      %= include '/include/commit_body';
144
+      <form action="<%= url_for %>" method="post">
145
+        <div class="pull-request-form">
146
+          <div style="overflow:hidden">
147
+            <div style="float:left;padding:10px;padding-right:0">
148
+              <div style="width:30px;height:30px;text-align:center;border-radius:15px;background:#95c97e;color:white;padding-top:5px;"><%= "\x{2714}" %></div>
149
+            </div>
150
+            <div style="float:left">
151
+              <div class="pull-request-form-title">
152
+                <div>
153
+                  <b>This branch has no conflicts with the base branch</b>
154
+                </div>
155
+                <div>
156
+                  <span style="color:#767676">Merging can be performed automatically.</span>
157
+                </div>
158
+              </div>
159
+            </div>
160
+          </div>
161
+          <div class="pull-request-form-button">
162
+            <%= submit_button 'Merge pull request', class => "btn btn-success" %>
163
+          </div>
164
+        </div>
165
+      </div>
166
+    </div>
167
+  </div>
168
+
169
+ 
170
+  %= include '/include/footer';
+3 -1
templates/pulls.html.ep
... ...
@@ -50,7 +50,9 @@
50 50
               %>
51 51
               <li>
52 52
                 <div class="pulls-title">
53
-                  <b><%= $pull_request->{title} %></b>
53
+                  <a href="<%= "/$user/$project/pull/$pull_request->{row_id}" %>">
54
+                    <b><%= $pull_request->{title} %></b>
55
+                  </a>
54 56
                 </div>
55 57
                 <div class="pulls-description">
56 58
                   #<%= $pull_request->{row_id} %> <%= $pull_request->{open} ? 'opened' : 'closed' %>