gitprep / templates / compare.html.ep /
Newer Older
648 lines | 22.623kb
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
1
<%
2
  # API
added compare branch popup t...
Yuki Kimoto authored on 2013-05-10
3
  my $api = gitprep_api;
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
4

            
5
  # Parameters
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
6
  my $base_user_id = param('user');
7
  my $base_project_id = param('project');
8
  my $base_branch = param('rev1');
9
  my $user_id_and_target_branch = param('rev2');
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
10
  my $page = param('page') || 0;
add pull request form
Yuki Kimoto authored on 2016-04-12
11
  my $expand = param('expand');
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
12
  
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
13
  # Default base branch
14
  $base_branch //= app->manager->default_branch($base_user_id, $base_project_id);
15
  
16
  # Base project
17
  my $base_project = app->dbi->model('project')->select(
improve compare page popup
Yuki Kimoto authored on 2016-04-28
18
    [
19
      {__MY__ => '*'},
20
      {__user => ['id']}
21
    ],
cleanup join table
Yuki Kimoto authored on 2016-04-28
22
    where => {'project.id' => $base_project_id, '__user.id' => $base_user_id}
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
23
  )->one;
24
  
get target branch logic
Yuki Kimoto authored on 2016-04-27
25
  # Get target user, project, branch
26
  my $target_user_id;
27
  my $target_branch;
28
  my $target_project;
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
29
  if ($user_id_and_target_branch =~ /^([^:]+):(.+)/) {
get target branch logic
Yuki Kimoto authored on 2016-04-27
30
    $target_user_id = $1;
31
    $target_branch = $2;
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
32
    $target_project = $self->app->manager->child_project($base_user_id, $base_project_id, $target_user_id);
get target branch logic
Yuki Kimoto authored on 2016-04-27
33
  }
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
34
  else {
35
    $target_user_id = $base_user_id;
36
    $target_branch = $user_id_and_target_branch;
37
    $target_project = $base_project
cleanup branch
Yuki Kimoto authored on 2016-04-12
38
  }
39
  
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
40
  # Git
revert encoding support
Yuki Kimoto authored on 2013-11-22
41
  my $git = $self->app->git;
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
42
  
add compare validation
Yuki Kimoto authored on 2016-05-04
43
  my $errors;
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
44
  if (lc $self->req->method eq 'post') {
45
    my $op = param('op');
46
    
47
    if ($op eq 'create-pull-request') {
add compare validation
Yuki Kimoto authored on 2016-05-04
48
      
49
      # Parameters
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
50
      my $title = param('title');
51
      my $message = param('message');
52
      
add compare validation
Yuki Kimoto authored on 2016-05-04
53
      # Validation
54
      my $vc = app->vc;
55
      my $validation = $vc->validation;
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
56
      
add compare validation
Yuki Kimoto authored on 2016-05-04
57
      # Check title
58
      if (!(defined $title && length $title)) {
59
        $validation->add_failed(title => 'title is empty');
60
      }
61
      elsif (length $title > 300) {
62
        $validation->add_failed(title => 'title is too long');
63
      }
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
64
      
add compare validation
Yuki Kimoto authored on 2016-05-04
65
      # Message
66
      if (!(defined $message && length $message)) {
67
        $message = '';
68
        if (length $message > 1000) {
69
          $validation->add_failed(message => 'message is too long');
70
        }
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
71
      }
add compare validation
Yuki Kimoto authored on 2016-05-04
72
      
73
      if ($validation->is_valid) {
74
      
75
        my $project_row_id = app->dbi->model('project')->select(
76
          'project.row_id',
77
          where => {'__user.id' => $base_user_id, 'project.id' => $base_project_id}
add pulls description
Yuki Kimoto authored on 2016-04-20
78
        )->value;
79
        
add compare validation
Yuki Kimoto authored on 2016-05-04
80
        my $pull_request = app->dbi->model('pull_request')->select(
81
          where => {
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
82
            base_project => $project_row_id,
83
            base_branch => $base_branch,
add compare validation
Yuki Kimoto authored on 2016-05-04
84
            target_project => $target_project->{id},
85
            target_branch => $target_branch
86
          }
87
        )->one;
88
        
89
        if ($pull_request) {
90
          $self->redirect_to("/$base_user_id/$base_project_id/pull/$pull_request->{row_id}");
91
          return;
92
        }
93
        else {
94
          my $now_tm = Time::Moment->now_utc;
95
          my $now_epoch = $now_tm->epoch;
96
          my $user_row_id = app->dbi->model('user')->select(
add pull request message log...
Yuki Kimoto authored on 2016-04-23
97
            'row_id',
add compare validation
Yuki Kimoto authored on 2016-05-04
98
            where => {id => $base_user_id}
99
          )->value;
100
          
101
          my $new_pull_request_row_id;
102
          my $session_user_row_id = $api->session_user_row_id;
103
          app->dbi->connector->txn(sub {
104
            # New pull request
105
            my $new_pull_request_params = {
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
106
              base_project => $project_row_id,
107
              base_branch => $base_branch,
108
              target_project => $target_project->{row_id},
add compare validation
Yuki Kimoto authored on 2016-05-04
109
              target_branch => $target_branch,
110
              title => $title,
111
              open => 1,
112
              open_time => $now_epoch,
113
              open_user => $session_user_row_id
114
            };
115
            
116
            app->dbi->model('pull_request')->insert($new_pull_request_params);
117
            
118
            $new_pull_request_row_id = app->dbi->model('pull_request')->select(
119
              'row_id',
120
              where => {
121
                base_project => $project_row_id,
122
                base_branch => $base_branch,
123
                target_project => $target_project->{row_id},
124
                target_branch => $target_branch
125
              }
126
            )->value;
127
            
128
            # Get pull request message number
129
            my $number = app->dbi->model('pull_request_message')->select(
130
              'max(number)',
131
              where => {pull_request => $new_pull_request_row_id},
132
              append => 'group by number'
133
            )->value;
134
            
135
            $number //= 0;
136
            
137
            my $new_number = $number + 1;
138
            
139
            # New pull request message
140
            my $new_pull_request_message_params = {
141
              pull_request => $new_pull_request_row_id,
142
              number => $new_number,
143
              message => $message,
144
              create_time => $now_epoch,
145
              update_time => $now_epoch,
146
              user => $session_user_row_id
147
            };
148
            
149
            app->dbi->model('pull_request_message')->insert($new_pull_request_message_params);
150
          });
fix create pull request logi...
Yuki Kimoto authored on 2016-04-23
151
          
add compare validation
Yuki Kimoto authored on 2016-05-04
152
          $self->redirect_to("/$base_user_id/$base_project_id/pull/$new_pull_request_row_id");
153
          return;
154
        }
155
      }
156
      else {
157
        $errors = $validation->messages;
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
158
      }
159
    }
160
  }
cleanup comapre
Yuki Kimoto authored on 2016-04-27
161

            
162
  # Can merge
fix compare branch link
Yuki Kimoto authored on 2016-04-28
163
  my $base_rep_info = app->rep_info($base_user_id, $base_project_id);
cleanup comapre
Yuki Kimoto authored on 2016-04-27
164
  my $merge_success;
fix compare branch link
Yuki Kimoto authored on 2016-04-28
165
  my $target_rep_info;
cleanup comapre
Yuki Kimoto authored on 2016-04-27
166
  if ($target_project) {
fix compare branch link
Yuki Kimoto authored on 2016-04-28
167
    $target_rep_info = app->rep_info($target_user_id, $target_project->{id});
cleanup comapre
Yuki Kimoto authored on 2016-04-27
168
  }
169
  else {
fix compare branch link
Yuki Kimoto authored on 2016-04-28
170
    $target_rep_info = $base_rep_info;
cleanup comapre
Yuki Kimoto authored on 2016-04-27
171
  }
172
    
173
  # Create working repository if it don't exist
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
174
  $self->app->manager->create_work_rep($base_user_id, $base_project_id);
cleanup comapre
Yuki Kimoto authored on 2016-04-27
175
  
176
  # Lock working repository
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
177
  my $work_rep_info = app->work_rep_info($base_user_id, $base_project_id);
cleanup comapre
Yuki Kimoto authored on 2016-04-27
178
  {
179
    my $lock_fh = $self->app->manager->lock_rep($work_rep_info);
180
    
181
    # Prepare merge
182
    $self->app->manager->prepare_merge(
183
      $work_rep_info,
fix compare branch link
Yuki Kimoto authored on 2016-04-28
184
      $base_rep_info,
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
185
      $base_branch,
fix compare branch link
Yuki Kimoto authored on 2016-04-28
186
      $target_rep_info,
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
187
      $target_branch
cleanup comapre
Yuki Kimoto authored on 2016-04-27
188
    );
189
    
190
    # Check merge automatically
191
    $merge_success = $self->app->manager->merge(
192
      $work_rep_info,
fix compare branch link
Yuki Kimoto authored on 2016-04-28
193
      $target_rep_info,
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
194
      $target_branch
cleanup comapre
Yuki Kimoto authored on 2016-04-27
195
    );
196
  }
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
197
  
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
198
  # Commits
fix compare branch link
Yuki Kimoto authored on 2016-04-28
199
  my $commits = $git->forward_commits($base_rep_info, $base_branch, $target_branch);
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
200
  my $commits_count = @$commits;
201
  my $commits_date = {};
improved compare page commit...
Yuki Kimoto authored on 2013-02-06
202
  my $authors = {};
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
203
  for my $commit (@$commits) {
support time zone
Yuki Kimoto authored on 2014-03-08
204
    my $date = $commit->{age_string_date_local};
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
205
    $commits_date->{$date} ||= [];
improved compare page commit...
Yuki Kimoto authored on 2013-02-06
206
    $authors->{$commit->{author}} = 1;
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
207
    push @{$commits_date->{$date}}, $commit;
208
  }
improved compare page commit...
Yuki Kimoto authored on 2013-02-06
209
  my $authors_count = keys %$authors;
added compare page file chan...
Yuki Kimoto authored on 2013-02-07
210

            
211
  # Start commit
fix compare branch link
Yuki Kimoto authored on 2016-04-28
212
  my $start_commit = $git->separated_commit($base_rep_info, $base_branch, $target_branch);
added compare page file chan...
Yuki Kimoto authored on 2013-02-07
213

            
214
  # End commit
fix compare branch link
Yuki Kimoto authored on 2016-04-28
215
  my $end_commit = $git->get_commit($target_rep_info, $target_branch);
cleanup
Yuki Kimoto authored on 2013-05-13
216
  
217
  if (!$start_commit || !$end_commit) {
do success xt tests
Yuki Kimoto authored on 2016-03-25
218
    $self->reply->not_found;
cleanup
Yuki Kimoto authored on 2013-05-13
219
    return;
220
  }
added compare page file chan...
Yuki Kimoto authored on 2013-02-07
221
  
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
222
  # Member projects
223
  my $member_projects = app->manager->member_projects($base_user_id, $base_project_id);
224
  unshift @$member_projects, $base_project;
225
  
fix compare branch link
Yuki Kimoto authored on 2016-04-28
226
  # Base branches
227
  my $base_branches = $git->branches($base_rep_info);
228
  @$base_branches = sort { $a->{commit}{age} <=> $b->{commit}{age} } @$base_branches;
229

            
230
  # Target branches
231
  my $target_branches = $git->branches($target_rep_info);
232
  @$target_branches = sort { $a->{commit}{age} <=> $b->{commit}{age} } @$target_branches;
added base branch selection ...
Yuki Kimoto authored on 2013-05-10
233
  
add pull request form
Yuki Kimoto authored on 2016-04-12
234
  # Can open pull request
235
  my $can_open_pull_request;
236
  if (keys %$commits_date && $expand) {
237
    $can_open_pull_request = 1;
238
  }
239
  
cleanup merge and push logic
Yuki Kimoto authored on 2016-04-27
240
  # commit_body args
241
  my %commit_body_args = (
242
    id => $end_commit->{id},
243
    from_id => $start_commit->{id},
244
    rev => $end_commit->{id},
245
    from_rev => $start_commit->{id}
246
  );
247

            
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
248
  layout 'common', title => "Comparing $base_branch...$target_branch \x{30fb} $base_user_id/$base_project_id";
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
249
%>
250

            
cleanup compare page
Yuki Kimoto authored on 2013-04-12
251

            
improve compare page design
Yuki Kimoto authored on 2016-02-04
252
%= javascript begin
253
  $(document).ready(function () {
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
254

            
255
    // Change base fork
256
    $('#base-fork-btn').on('click', function () {
257
      $('#base-fork-popup')
258
        .css('display', 'block')
259
        .css('top', '40px')
260
        .css('left', '10px')
261
      ;
262
    });
263
    $('#base-fork-popup').on('click', function () {
264
      $('#base-fork-popup').css('display', 'none');
265
    });
266
    // close popup
267
    $(document).click(function() { $('#base-fork-popup').hide(); });
268
    $('#base-fork-btn').click(function() { event.stopPropagation(); });
269
    $('#base-fork-popup').click(function() { event.stopPropagation(); });
270

            
271

            
272
    // Change head fork
273
    $('#head-fork-btn').on('click', function () {
274
      $('#head-fork-popup')
275
        .css('display', 'block')
276
        .css('top', '40px')
277
        .css('left', '10px')
278
      ;
279
    });
280
    $('#head-fork-popup').on('click', function () {
281
      $('#head-fork-popup').css('display', 'none');
282
    });
283
    // close popup
284
    $(document).click(function() { $('#head-fork-popup').hide(); });
285
    $('#head-fork-btn').click(function() { event.stopPropagation(); });
286
    $('#head-fork-popup').click(function() { event.stopPropagation(); });
287

            
improve compare page design
Yuki Kimoto authored on 2016-02-04
288
    // Change base branch
289
    $('#base-branch-btn').on('click', function () {
290
      $('#base-branch-popup')
291
        .css('display', 'block')
292
        .css('top', '40px')
293
        .css('left', '10px')
294
      ;
295
    });
296
    $('#base-branch-close').on('click', function () {
297
      $('#base-branch-popup').css('display', 'none');
298
    });
299
    $('[name=base-branch]').on('keypress', function (e) {
300
      // Enter
301
      if (e.which == 13) {
fix compare branch link
Yuki Kimoto authored on 2016-04-28
302
        var href;
improve compare page popup
Yuki Kimoto authored on 2016-04-28
303
        % if ($base_user_id eq $target_user_id) {
fix compare branch link
Yuki Kimoto authored on 2016-04-28
304
          href = '<%= url_for("/$base_user_id/$base_project_id/compare/") %>' + $(this).val() + '...<%= $target_branch %>';
improve compare page popup
Yuki Kimoto authored on 2016-04-28
305
        % } else {
fix compare branch link
Yuki Kimoto authored on 2016-04-28
306
          href = '<%= url_for("/$base_user_id/$base_project_id/compare/") %>' + $(this).val() + '...<%= $target_user_id %>:<%= $target_branch %>';
improve compare page popup
Yuki Kimoto authored on 2016-04-28
307
        % }
308
        
show not able to merge
Yuki Kimoto authored on 2016-04-18
309
        if (<%= $expand ? 1 : 0 %>) {
310
          href = href + '?expand=1';
311
        }
fix compare branch link
Yuki Kimoto authored on 2016-04-28
312
        
show not able to merge
Yuki Kimoto authored on 2016-04-18
313
        location.href = href;
improve compare page design
Yuki Kimoto authored on 2016-02-04
314
      }
315
    });
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
316
    // close popup
improve compare page popup
Yuki Kimoto authored on 2016-04-28
317
    $(document).click(function() { $('#base-branch-popup').hide(); });
318
    $('#base-branch-btn').click(function() { event.stopPropagation(); });
319
    $('#base-branch-popup').click(function() { event.stopPropagation(); });
show not able to merge
Yuki Kimoto authored on 2016-04-18
320
    
improve compare page design
Yuki Kimoto authored on 2016-02-04
321
    // Change compare branch
fix compare branch link
Yuki Kimoto authored on 2016-04-28
322
    $('#target-branch-btn').on('click', function () {
323
      $('#target-branch-popup')
improve compare page design
Yuki Kimoto authored on 2016-02-04
324
        .css('display', 'block')
325
        .css('top', '40px')
326
        .css('left', '96px')
327
      ;
328
    });
fix compare branch link
Yuki Kimoto authored on 2016-04-28
329
    $('#target-branch-close').on('click', function () {
330
      $('#target-branch-popup').css('display', 'none');
improve compare page design
Yuki Kimoto authored on 2016-02-04
331
    });
fix compare branch link
Yuki Kimoto authored on 2016-04-28
332
    $('[name=target-branch]').on('keypress', function (e) {
improve compare page design
Yuki Kimoto authored on 2016-02-04
333
      // Enter
334
      if (e.which == 13) {
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
335
        var href = '<%= url_for("/$base_user_id/$base_project_id/compare/") %>' + '<%= $base_branch %>...' + $(this).val();
show not able to merge
Yuki Kimoto authored on 2016-04-18
336
        if (<%= $expand ? 1 : 0 %>) {
337
          href = href + '?expand=1';
338
        }
339
        location.href = href;
improve compare page design
Yuki Kimoto authored on 2016-02-04
340
      }
improved compare page design
Yuki Kimoto authored on 2013-02-07
341
    });
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
342
    // close popup
fix compare branch link
Yuki Kimoto authored on 2016-04-28
343
    $(document).click(function() { $('#target-branch-popup').hide(); });
344
    $('#target-branch-btn').click(function() { event.stopPropagation(); });
345
    $('#target-branch-popup').click(function() { event.stopPropagation(); });
improve compare page popup
Yuki Kimoto authored on 2016-04-28
346

            
improve compare page design
Yuki Kimoto authored on 2016-02-04
347
  });
348
% end
cleanup
Yuki Kimoto authored on 2013-02-04
349

            
improve compare page design
Yuki Kimoto authored on 2016-02-04
350
%= include '/include/header';
cleanup
Yuki Kimoto authored on 2013-02-04
351

            
improve compare page design
Yuki Kimoto authored on 2016-02-04
352
<div class="container">
add compare validation
Yuki Kimoto authored on 2016-05-04
353
  %= include '/include/errors', errors => $errors;
354
  
add pull request form
Yuki Kimoto authored on 2016-04-12
355
  <div class="topic1">
356
    % if ($can_open_pull_request) {
357
      Open a pull request
358
    % } else {
359
      Comparing changes
360
    % }
361
  </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
362
  <div class="compare-select">
363
    <div>
364
      <div>
improve compare page popup
Yuki Kimoto authored on 2016-04-28
365
        <div style="display:inline-block">
366
          % if ($base_user_id ne $target_user_id) {
367
            <button id="base-fork-btn" class="btn btn-small">
368
              <span>base fork:</span><b> <%= $base_project->{'__user.id'} %>/<%= $base_project->{id} %></b><i class="icon-arrow-down"></i>
369
            </button>
370
          % }
371
          <button id="base-branch-btn" class="btn btn-small">
372
            <span>base:</span><b> <%= $base_branch %></b><i class="icon-arrow-down"></i>
373
          </button>
374
          ...
375
        </div>
complete pull request logic
Yuki Kimoto authored on 2016-04-28
376
        <div style="display:inline-block;margin-top:10px;">
improve compare page popup
Yuki Kimoto authored on 2016-04-28
377
          % if ($base_user_id ne $target_user_id) {
378
            <button id="head-fork-btn" class="btn btn-small">
379
              <span>head fork:</span><b> <%= $target_project->{'__user.id'} %>/<%= $target_project->{id} %></b><i class="icon-arrow-down"></i>
380
            </button>
381
          % }
fix compare branch link
Yuki Kimoto authored on 2016-04-28
382
          <button id="target-branch-btn" class="btn btn-small">
improve compare page popup
Yuki Kimoto authored on 2016-04-28
383
            <span>compare:</span> <b><%= $target_branch %></b><i class="icon-arrow-down"></i>
384
          </button>
add automatical merge checki...
Yuki Kimoto authored on 2016-04-18
385
        
improve compare page popup
Yuki Kimoto authored on 2016-04-28
386
          % if ($can_open_pull_request) {
387
            % if ($merge_success) {
388
              <span style="margin-left:10px">
389
                <span style="color:green;font-weight:bold"><%= "\x{2714}" %>Able to merge.</span> These branches can be automatically merged.
390
              </span>
391
            % } else {
392
              <span style="margin-left:10px">
393
                <span style="color:red;font-weight:bold"><%= "×" %>Not able to merge.</span> These branches can't be automatically merged.
394
              </span>
395
            % }
show not able to merge
Yuki Kimoto authored on 2016-04-18
396
          % }
improve compare page popup
Yuki Kimoto authored on 2016-04-28
397
        </div>
cleanup
Yuki Kimoto authored on 2013-03-15
398
      </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
399
    </div>
show not able to merge
Yuki Kimoto authored on 2016-04-18
400

            
401
    <div id="base-branch-popup" style="display:none;width:330px;position:absolute">
402
      <div class="radius-top border-gray" style="background:#E6E6FA;padding:10px">
403
        <div style="overflow:hidden">
404
          <div style="float:left;width:90%;">
405
            <b>Choose a base branch</b>
406
          </div>
407
          <div style="float:left:width:10%;text-align:right;">
408
            <i id="base-branch-close" class="icon-remove-circle"></i>
added base branch selection ...
Yuki Kimoto authored on 2013-05-10
409
          </div>
show pull request only when ...
Yuki Kimoto authored on 2016-04-18
410
        </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
411
      </div>
show not able to merge
Yuki Kimoto authored on 2016-04-18
412
      <div class="border-gray" style="background:#F5F5F5;border-top:none;border-bottom:none;text-align:center;padding:10px 0">
413
        %= text_field 'base-branch', style => 'margin-bottom:0;width:270px', placeholder => 'Branch, tag, commit, or history marker';
414
      </div>
415
      <div style="background:white;max-height:500px;overflow:auto;">
416
        <ul class="nav nav-tabs nav-stacked">
fix compare branch link
Yuki Kimoto authored on 2016-04-28
417
          % for (my $i = 0; $i < @$base_branches; $i++) {
418
            % my $branch = $base_branches->[$i];
show not able to merge
Yuki Kimoto authored on 2016-04-18
419
              <li>
fix compare branch link
Yuki Kimoto authored on 2016-04-28
420
                <%
421
                  my $url;
422
                  if ($base_user_id eq $target_user_id) {
423
                    $url = url_with("/$base_user_id/$base_project_id/compare/$branch->{name}...$target_branch");
424
                  }
425
                  else {
426
                    $url = url_with("/$base_user_id/$base_project_id/compare/$branch->{name}...$target_user_id:$target_branch");
427
                  }
428
                %>
show not able to merge
Yuki Kimoto authored on 2016-04-18
429
                <a style="border-top-left-radius:0px;border-top-right-radius:0px;"
fix compare branch link
Yuki Kimoto authored on 2016-04-28
430
                  href="<%= $url  %>">
show not able to merge
Yuki Kimoto authored on 2016-04-18
431
                  <%= $branch->{name} %>
432
                </a>
433
              </li>
434
          % }
435
        </ul>
436
      </div>
437
    </div>
438

            
fix compare branch link
Yuki Kimoto authored on 2016-04-28
439
    <div id="target-branch-popup" style="display:none;width:330px;position:absolute">
improve compare page design
Yuki Kimoto authored on 2016-02-04
440
      <div class="radius-top border-gray" style="background:#E6E6FA;padding:10px">
441
        <div style="overflow:hidden">
442
          <div style="float:left;width:90%;">
443
            <b>Choose a compare branch</b>
444
          </div>
445
          <div style="float:left:width:10%;text-align:right;">
fix compare branch link
Yuki Kimoto authored on 2016-04-28
446
            <i id="target-branch-close" class="icon-remove-circle"></i>
added compare branch popup t...
Yuki Kimoto authored on 2013-05-10
447
          </div>
448
        </div>
449
      </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
450
      <div class="border-gray" style="background:#F5F5F5;border-top:none;border-bottom:none;text-align:center;padding:10px 0">
fix compare branch link
Yuki Kimoto authored on 2016-04-28
451
        %= text_field 'target-branch', style => 'margin-bottom:0;width:270px', placeholder => 'Branch, tag, commit, or history marker';
improve compare page design
Yuki Kimoto authored on 2016-02-04
452
      </div>
453
      <div style="background:white;max-height:500px;overflow:auto;">
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
454
        <ul class="nav nav-tabs nav-stacked">
455
          % for (my $i = 0; $i < @$target_branches; $i++) {
456
            % my $target_branch = $target_branches->[$i];
457
              <li>
458
                <%
459
                  my $url;
460
                  if ($base_user_id eq $target_user_id) {
461
                    $url = url_with("/$base_user_id/$base_project_id/compare/$base_branch...$target_branch->{name}");
462
                  }
463
                  else {
464
                    $url = url_with("/$base_user_id/$base_project_id/compare/$base_branch...$target_user_id:$target_branch->{name}");
465
                  }
466
                %>
467
                <a style="border-top-left-radius:0px;border-top-right-radius:0px;" href="<%= $url %>">
468
                  <%= $target_branch->{name} %>
469
                </a>
470
              </li>
471
          % }
472
        </ul>
473
      </div>
474
    </div>
475

            
476

            
477
    <div id="base-fork-popup" style="display:none;width:330px;position:absolute">
478
      <div class="radius-top border-gray" style="background:#E6E6FA;padding:10px">
479
        <div style="overflow:hidden">
480
          <div style="float:left;width:90%;">
481
            <b>Choose a base fork</b>
482
          </div>
483
          <div style="float:left:width:10%;text-align:right;">
484
            <i id="member-project-close" class="icon-remove-circle"></i>
485
          </div>
486
        </div>
487
      </div>
488
      <div style="background:white;max-height:500px;overflow:auto;">
489
        <ul class="nav nav-tabs nav-stacked">
490
          % for (my $i = 0; $i < @$member_projects; $i++) {
491
            % my $member_project = $member_projects->[$i];
fix compare branch link
Yuki Kimoto authored on 2016-04-28
492
              <%
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
493
                my $member_user_id = $member_project->{'__user.id'};
494
                my $member_project_id = $member_project->{id};
fix compare branch link
Yuki Kimoto authored on 2016-04-28
495
              %>
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
496
              <li>
497
                <%
498
                  my $url;
499
                  if ($member_user_id eq $target_user_id) {
500
                    $url = url_with("/$member_user_id/$member_project_id/compare/$base_branch...$target_branch");
501
                  }
502
                  else {
503
                    $url = url_with("/$member_user_id/$member_project_id/compare/$base_branch...$target_user_id:$target_branch");
504
                  }
505
                %>
506
                <a style="border-top-left-radius:0px;border-top-right-radius:0px;" href="<%= $url %>">
507
                  <%= $member_user_id %>/<%= $member_project_id %>
508
                </a>
509
              </li>
510
          % }
511
        </ul>
512
      </div>
513
    </div>
514

            
515

            
516

            
517

            
518
    <div id="head-fork-popup" style="display:none;width:330px;position:absolute">
519
      <div class="radius-top border-gray" style="background:#E6E6FA;padding:10px">
520
        <div style="overflow:hidden">
521
          <div style="float:left;width:90%;">
522
            <b>Choose a head fork</b>
523
          </div>
524
          <div style="float:left:width:10%;text-align:right;">
525
            <i id="member-project-close" class="icon-remove-circle"></i>
526
          </div>
527
        </div>
528
      </div>
529
      <div style="background:white;max-height:500px;overflow:auto;">
530
        <ul class="nav nav-tabs nav-stacked">
531
          % for (my $i = 0; $i < @$member_projects; $i++) {
532
            % my $member_project = $member_projects->[$i];
533
              <%
534
                my $member_user_id = $member_project->{'__user.id'};
535
                my $member_project_id = $member_project->{id};
536
              %>
537
              <li>
538
                <%
539
                  my $url;
540
                  if ($member_user_id eq $base_user_id) {
541
                    $url = url_with("/$base_user_id/$base_project_id/compare/$base_branch...$target_branch");
542
                  }
543
                  else {
544
                    $url = url_with("/$base_user_id/$base_project_id/compare/$base_branch...$member_user_id:$target_branch");
545
                  }
546
                %>
547
                <a style="border-top-left-radius:0px;border-top-right-radius:0px;" href="<%= $url %>">
548
                  <%= $member_user_id %>/<%= $member_project_id %>
549
                </a>
550
              </li>
551
          % }
552
        </ul>
improve compare page design
Yuki Kimoto authored on 2016-02-04
553
      </div>
added base branch selection ...
Yuki Kimoto authored on 2013-05-10
554
    </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
555
  </div>
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
556
 
complete pull request logic
Yuki Kimoto authored on 2016-04-28
557
  % if (keys %$commits_date && $merge_success) {
add pull request form
Yuki Kimoto authored on 2016-04-12
558
    <div class="compare-open-pull-request">
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
559
      <form action="<%= url_for %>" method="post">
560
        <%= hidden_field op => 'create-pull-request' %>
add pull request form
Yuki Kimoto authored on 2016-04-12
561
        <div class="compare-open-pull-request-title">
cleanup methods
Yuki Kimoto authored on 2016-04-13
562
          <%= text_field 'title' => $commits->[0]{title_short}  %>
add pull request form
Yuki Kimoto authored on 2016-04-12
563
        </div>
564
        <div class="compare-open-pull-request-message">
565
          <%= text_area 'message' %>
566
        </div>
567
        <div class="compare-open-pull-request-button">
568
          <%= submit_button 'Create pull request', class => 'btn btn-success' %>
569
        </div>
570
      </form>
571
    </div>
572
  % }
added base branch popup to c...
Yuki Kimoto authored on 2013-05-10
573

            
improve compare page design
Yuki Kimoto authored on 2016-02-04
574
  % if (keys %$commits_date) {
575
    <ul class="compare-header">
576
      <li>
577
        <b><%= @$commits %></b> <span>commit</span>
578
      </li>
579
      <li>
580
        <b><%= $authors_count %></b> <span>contributor</span>
581
      </li>
582
      <li>
583
        
584
      </li>
585
      <li>
586
        
587
      </li>
588
    </ul>
improved compare page design
Yuki Kimoto authored on 2013-02-07
589
    
improve compare page design
Yuki Kimoto authored on 2016-02-04
590
    <div class="commits">
expand compare page tabs
Yuki Kimoto authored on 2013-08-10
591
      % for my $date (reverse sort keys %$commits_date) {
592
        % my $commits = $commits_date->{$date};
593
        
improve compare page design
Yuki Kimoto authored on 2016-02-04
594
        <div class="commit-date">
595
          <i class="icon-off"></i><span>Commits on <%= $date %></span>
expand compare page tabs
Yuki Kimoto authored on 2013-08-10
596
        </div>
597
        
improve compare page design
Yuki Kimoto authored on 2016-02-04
598
        <ul class="compare-commits-date-container">
expand compare page tabs
Yuki Kimoto authored on 2013-08-10
599
          % for my $commit (sort {$b->{author_epoch} <=> $a->{author_epoch}} @$commits) {
add user page link from user...
Yuki Kimoto authored on 2016-04-11
600
            <%
fix mail bug
Yuki Kimoto authored on 2016-04-21
601
              my $commit_author_email = $commit->{author_email};
add user page link from user...
Yuki Kimoto authored on 2016-04-11
602
              my $commit_author_id = app->dbi->model('user')->select(
603
                'id',
fix mail bug
Yuki Kimoto authored on 2016-04-21
604
                where => {email => $commit_author_email}
add user page link from user...
Yuki Kimoto authored on 2016-04-11
605
              )->value;
606
            %>
improve compare page design
Yuki Kimoto authored on 2016-02-04
607
            <li>
608
              <div class="compare-commits-author">
add user page link from user...
Yuki Kimoto authored on 2016-04-11
609
                <span title="<%= $commit->{author_email} %>">
610
                  % if (defined $commit_author_id) {
611
                    <a href="<%= url_for("/$commit_author_id") %>"><%= $commit_author_id %></a>
612
                  % } else {
613
                    <%= $commit->{author_name} %>
614
                  % }
615
                </span>
expand compare page tabs
Yuki Kimoto authored on 2013-08-10
616
              </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
617
              <div class="compare-commits-commit-title">
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
618
                <a style="color:#333" href="<%= url_for("/$base_user_id/$base_project_id/commit/$commit->{id}") %>">
improve compare page design
Yuki Kimoto authored on 2016-02-04
619
                  <%= $commit->{title_short} %>
620
                </a>
621
              </div>
622
              <div class="compare-commits-commit-id">
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
623
                <a href="<%= url_for("/$base_user_id/$base_project_id/commit/$commit->{id}") %>">
improve compare page design
Yuki Kimoto authored on 2016-02-04
624
                  <%= substr($commit->{id}, 0, 7) %>
625
                </a>
626
              </div>
627
            </li>
improved branches page and c...
Yuki Kimoto authored on 2013-05-07
628
          % }
improve compare page design
Yuki Kimoto authored on 2016-02-04
629
        </ul>
expand compare page tabs
Yuki Kimoto authored on 2013-08-10
630
      % }
improve compare page design
Yuki Kimoto authored on 2016-02-04
631
    </div>
632
  
cleanup merge and push logic
Yuki Kimoto authored on 2016-04-27
633
    %= include '/include/commit_body', %commit_body_args;
improve compare page design
Yuki Kimoto authored on 2016-02-04
634
  % } else {
improve compare page
Yuki Kimoto authored on 2016-04-12
635
    <div class="compare-nothing">
636
      <div>
637
        <b><big>There isn't anything to compare.</big></b>
638
      </div>
639
      <div>
show not able to merge
Yuki Kimoto authored on 2016-04-18
640
        <b>
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
641
          <%= $base_branch %></b> is up to date with all commits from
642
          <b><%= $target_branch %></b>.
643
          Try <a href="<%= url_for("/$base_user_id/$base_project_id/compare/$target_branch...$base_branch") %>">switching the base</a> for your comparison.
improve compare page
Yuki Kimoto authored on 2016-04-12
644
      </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
645
    </div>
646
  % }
647
</div>
648
%= include '/include/footer';