Showing 1 changed files with 87 additions and 43 deletions
+87 -43
templates/pull.html.ep
... ...
@@ -184,7 +184,27 @@
184 184
       $target_branch
185 185
     );
186 186
   }
187
+  
188
+  # HTTP repository URL
189
+  my $http_rep_url = url_for("$target_user_id/$target_project_id.git")->to_abs;
190
+  
191
+  # SSH repository URL
192
+  my $url = url_for->to_abs;
193
+  $url->base(undef);
194
+  my $ssh_port = config->{basic}{ssh_port};
195
+  my $rep_home = app->rep_home;
196
+  my $execute_user = getpwuid($>);
197
+  my $ssh_rep_url_base = defined app->config->{basic}{'ssh_rep_url_base'}
198
+    ? app->config->{basic}{'ssh_rep_url_base'} : $rep_home;
199
+  my $ssh_rep_url = "ssh://$execute_user\@" . $url->host
200
+    . ($ssh_port ? ":$ssh_port" : '') . "$ssh_rep_url_base/$user/$project.git";
187 201
 
202
+  my $patch_url = url_for("/$base_user_id/$base_project_id/pull/$pull_request->{row_id}.patch")->to_abs;
203
+
204
+  my $pre_content_base = "git checkout -b $target_user_id-$target_branch $base_branch";
205
+  my $pre_content_http = "git pull $http_rep_url $target_branch";
206
+  my $pre_content_ssh = "git pull $ssh_rep_url $target_branch";
207
+  
188 208
   # Commit body arguments
189 209
   my %commit_body_args = (
190 210
     id => $end_commit->{id},
... ...
@@ -265,7 +285,7 @@
265 285
             <b><%= $pull_request_message_first->{'__open_user.id'} %></b>
266 286
             <span style="color:#767676">
267 287
               commented
268
-              <%= $api->age_string($pull_request_message_first->{update_time}) %></b>
288
+              <%= $api->age_string($pull_request_message_first->{update_time}) %>
269 289
             </span>
270 290
           </div>
271 291
           <div class="pull-comment-body">
... ...
@@ -323,63 +343,88 @@
323 343
       % if ($api->can_write_access($session_user_id, $base_user_id, $base_project_id)) {
324 344
         % if ($commits_count && $merge_success && $pull_request->{open}) {
325 345
           <div class="pull-request-form">
326
-            <div>
327
-              <div style="overflow:hidden">
328
-                <div style="float:left;padding:10px;padding-right:0">
329
-                  <div style="width:30px;height:30px;text-align:center;border-radius:15px;background:#95c97e;color:white;padding-top:5px;"><%= "\x{2714}" %></div>
330
-                </div>
331
-                <div style="float:left">
332
-                  <div class="pull-request-form-title">
333
-                    <div>
334
-                      <b>This branch has no conflicts with the base branch</b>
335
-                    </div>
336
-                    <div>
337
-                      <span style="color:#767676">Merging can be performed automatically.</span>
338
-                    </div>
339
-                  </div>
340
-                </div>
346
+            <div style="overflow:hidden">
347
+              <div style="float:left;padding:10px;padding-right:0">
348
+                <div style="width:30px;height:30px;text-align:center;border-radius:15px;background:#95c97e;color:white;padding-top:5px;"><%= "\x{2714}" %></div>
341 349
               </div>
342
-              <div class="pull-request-form-button">
343
-                <form action="<%= url_for %>" method="post">
344
-                  <%= hidden_field op => 'merge' %>
345
-                  <%= submit_button 'Merge pull request', class => "btn btn-success" %>
346
-                  <span style="margin-left:5px">
347
-                    You can also view <a href="javascript:void(0)" onclick="$('#command-line-instructions').toggle()" >command line instructions</a>.
348
-                  </span>
349
-                </form>
350
-                
351
-                <div id="command-line-instructions">
352
-                  <div style="margin-top:15px;border-top:1px solid #d8d8d8;">
353
-                  <div style="font-size:18px;padding:10px 0">
354
-                    Merging via command line
355
-                  </div>
356
-
350
+              <div style="float:left">
351
+                <div class="pull-request-form-title">
357 352
                   <div>
358
-                    If you do not want to use the merge button or an automatic merge cannot be performed, you can perform a manual merge on the command line.
353
+                    <b>This branch has no conflicts with the base branch</b>
359 354
                   </div>
360
-                  <div style="margin-top:10px">
361
-                    <button class="btn btn-small" style="border-radius:3px 0 0 3px">HTTPS</button><button class="btn btn-small" style="border-radius:0">Git</button><button class="btn btn-small" style="border-radius:0">Patch</button><%= text_field clone_url => "https://github.com/kaloyan13/gitprep.git", style => "width:600px;padding:4px 7px 5px 7px;border-radius:0 3px 3px 0" %>
355
+                  <div>
356
+                    <span style="color:#767676">Merging can be performed automatically.</span>
362 357
                   </div>
358
+                </div>
359
+              </div>
360
+            </div>
361
+            <div class="pull-request-form-button">
362
+              <form action="<%= url_for %>" method="post">
363
+                <%= hidden_field op => 'merge' %>
364
+                <%= submit_button 'Merge pull request', class => "btn btn-success" %>
365
+                <span style="margin-left:5px">
366
+                  You can also view <a href="javascript:void(0)" onclick="$('#command-line-instructions').toggle()" >command line instructions</a>.
367
+                </span>
368
+              </form>
369
+              
370
+              <div id="command-line-instructions" style="display:none">
371
+                <div style="font-size:18px;padding:10px 0">
372
+                  Merging via command line
373
+                </div>
363 374
 
364
-                  <div style="margin-top:15px;margin-bottom:5px;">
365
-                    <b>Step 1:</b> From your project repository, check out a new branch and test the changes.
366
-                  </div>
375
+                <div>
376
+                  If you do not want to use the merge button or an automatic merge cannot be performed, you can perform a manual merge on the command line.
377
+                </div>
378
+                %= javascript begin
379
+                  $(document).ready(function () {
380
+                    var http_rep_url = "<%= $http_rep_url %>";
381
+                    
382
+                    var ssh_rep_url = "<%= $ssh_rep_url %>";
383
+                    var patch_url = "<%= $patch_url %>";
384
+                    
385
+                    var pre_content_base = "<%= $pre_content_base %>";
386
+                    var pre_content_http = "<%= $pre_content_http %>";
387
+                    var pre_content_ssh = "<%= $pre_content_ssh %>";
388
+                    
389
+                    var pre_content_http_all = pre_content_base + "\n" + pre_content_http;
390
+                    var pre_content_ssh_all = pre_content_base + "\n" + pre_content_ssh;
391
+                    
392
+                    $('#http-btn').on('click', function () {
393
+                      $('[name=clone_url]').val(http_rep_url);
394
+                      $('#step1').text(pre_content_http_all);
395
+                    });
396
+                    $('#ssh-btn').on('click', function () {
397
+                      $('[name=clone_url]').val(ssh_rep_url);
398
+                      $('#step1').text(pre_content_ssh_all);
399
+                    });
400
+                    $('#patch-btn').on('click', function () {
401
+                      $('[name=clone_url]').val(patch_url);
402
+                    });
403
+                  });
404
+                % end
405
+                
406
+                <div style="margin-top:10px">
407
+                  <button id="http-btn" class="btn btn-small" style="border-radius:3px 0 0 3px">HTTPS</button><button id="ssh-btn" class="btn btn-small" style="border-radius:0">SSH</button><button id="patch-btn" class="btn btn-small" style="border-radius:0">Patch</button><%= text_field clone_url => $http_rep_url, style => "width:600px;padding:4px 7px 5px 7px;border-radius:0 3px 3px 0" %>
408
+                </div>
367 409
 
368
-<pre style="background:#f2f2f2; padding:10px; border-radius:3px">
410
+                <div style="margin-top:15px;margin-bottom:5px;">
411
+                  <b>Step 1:</b> From your project repository, check out a new branch and test the changes.
412
+                </div>
413
+
414
+<pre id="step1" style="background:#f2f2f2; padding:10px; border-radius:3px">
369 415
 git checkout -b <%= $target_user_id %>-<%= $target_branch %> <%= $base_branch %>
370 416
 git pull <%= url_for("$target_user_id/$target_project_id.git")->to_abs %> <%= $target_branch %>
371 417
 </pre>
372 418
 
373
-                  <div style="margin-top:15px;margin-bottom:5px;">
374
-                    <b>Step 2:</b> Merge the changes and update on GitPrep.
375
-                  </div>
419
+                <div style="margin-top:15px;margin-bottom:5px;">
420
+                  <b>Step 2:</b> Merge the changes and update on GitPrep.
421
+                </div>
376 422
 
377 423
 <pre style="background:#f2f2f2; padding:10px; border-radius:3px">
378 424
 git checkout <%= $base_branch %>
379 425
 git merge --no-ff <%= $target_user_id %>-<%= $target_branch %>
380 426
 git push origin <%= $base_branch %>
381 427
 </pre>
382
-                </div>
383 428
               </div>
384 429
             </div>
385 430
           </div>
... ...
@@ -404,5 +449,4 @@ git push origin <%= $base_branch %>
404 449
     </div>
405 450
   </div>
406 451
 
407
- 
408 452
   %= include '/include/footer';