gitprep / templates / compare.html.ep /
Newer Older
707 lines | 24.784kb
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__ => '*'},
remove table __ prefix
Yuki Kimoto authored on 2016-06-11
20
      {user => ['id']}
improve compare page popup
Yuki Kimoto authored on 2016-04-28
21
    ],
remove table __ prefix
Yuki Kimoto authored on 2016-06-11
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;
hide new pull reqeust button...
Yuki Kimoto authored on 2016-08-22
29
  if (defined $user_id_and_target_branch && $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;
fix bug that new pull reqeus...
Yuki Kimoto authored on 2016-06-18
36
    $target_branch = $user_id_and_target_branch // $base_branch;
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
37
    $target_project = $base_project
cleanup branch
Yuki Kimoto authored on 2016-04-12
38
  }
fix pulls page bug
Yuki Kimoto authored on 2016-08-20
39

            
40
  # Already pull request exists
41
  my $pull_request_already = app->dbi->model('pull_request')->select(
42
    where => {
43
      base_project => $base_project->{row_id},
44
      base_branch => $base_branch,
45
      target_project => $target_project->{row_id},
46
      target_branch => $target_branch
47
    }
48
  )->one;
cleanup branch
Yuki Kimoto authored on 2016-04-12
49
  
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
50
  # Git
revert encoding support
Yuki Kimoto authored on 2013-11-22
51
  my $git = $self->app->git;
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
52
  
add compare validation
Yuki Kimoto authored on 2016-05-04
53
  my $errors;
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
54
  if (lc $self->req->method eq 'post') {
add pull reqeust link button...
Yuki Kimoto authored on 2016-08-20
55
  
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
56
    my $op = param('op');
57
    
58
    if ($op eq 'create-pull-request') {
add compare validation
Yuki Kimoto authored on 2016-05-04
59
      
add pull reqeust link button...
Yuki Kimoto authored on 2016-08-20
60
      if ($pull_request_already) {
61
        $self->render_exception("Error");
62
      }
63
      
add compare validation
Yuki Kimoto authored on 2016-05-04
64
      # Parameters
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
65
      my $title = param('title');
66
      my $message = param('message');
67
      
add compare validation
Yuki Kimoto authored on 2016-05-04
68
      # Validation
69
      my $vc = app->vc;
70
      my $validation = $vc->validation;
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
71
      
add compare validation
Yuki Kimoto authored on 2016-05-04
72
      # Check title
73
      if (!(defined $title && length $title)) {
74
        $validation->add_failed(title => 'title is empty');
75
      }
76
      elsif (length $title > 300) {
77
        $validation->add_failed(title => 'title is too long');
78
      }
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
79
      
add compare validation
Yuki Kimoto authored on 2016-05-04
80
      # Message
81
      if (!(defined $message && length $message)) {
82
        $message = '';
83
        if (length $message > 1000) {
84
          $validation->add_failed(message => 'message is too long');
85
        }
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
86
      }
add compare validation
Yuki Kimoto authored on 2016-05-04
87
      
88
      if ($validation->is_valid) {
89
      
90
        my $project_row_id = app->dbi->model('project')->select(
91
          'project.row_id',
remove table __ prefix
Yuki Kimoto authored on 2016-06-11
92
          where => {'user.id' => $base_user_id, 'project.id' => $base_project_id}
add pulls description
Yuki Kimoto authored on 2016-04-20
93
        )->value;
94
        
add compare validation
Yuki Kimoto authored on 2016-05-04
95
        my $pull_request = app->dbi->model('pull_request')->select(
96
          where => {
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
97
            base_project => $project_row_id,
98
            base_branch => $base_branch,
fix pull reqeust error bug
Yuki Kimoto authored on 2016-08-19
99
            target_project => $target_project->{row_id},
add compare validation
Yuki Kimoto authored on 2016-05-04
100
            target_branch => $target_branch
101
          }
102
        )->one;
103
        
fix branches page
Yuki Kimoto authored on 2016-06-11
104
        my $issue;
add compare validation
Yuki Kimoto authored on 2016-05-04
105
        if ($pull_request) {
fix branches page
Yuki Kimoto authored on 2016-06-11
106
          $issue = app->dbi->model('issue')->select(
107
            where => {pull_request => $pull_request->{row_id}}
108
          )->one;
fix issue number bug
Yuki Kimoto authored on 2016-06-11
109
          $self->redirect_to("/$base_user_id/$base_project_id/pull/$issue->{number}");
add compare validation
Yuki Kimoto authored on 2016-05-04
110
          return;
111
        }
112
        else {
113
          my $now_tm = Time::Moment->now_utc;
114
          my $now_epoch = $now_tm->epoch;
115
          my $session_user_row_id = $api->session_user_row_id;
fix issue number bug
Yuki Kimoto authored on 2016-06-11
116
          my $issue_number;
add compare validation
Yuki Kimoto authored on 2016-05-04
117
          app->dbi->connector->txn(sub {
fix compare page
Yuki Kimoto authored on 2016-06-11
118
            
add compare validation
Yuki Kimoto authored on 2016-05-04
119
            # New pull request
fix compare page
Yuki Kimoto authored on 2016-06-11
120
            my $new_pull_request = {
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
121
              base_project => $project_row_id,
122
              base_branch => $base_branch,
123
              target_project => $target_project->{row_id},
add compare validation
Yuki Kimoto authored on 2016-05-04
124
              target_branch => $target_branch,
fix compare page
Yuki Kimoto authored on 2016-06-11
125
            };
126
            
fix issue number bug
Yuki Kimoto authored on 2016-06-11
127
            # last pull request row id
fix compare page
Yuki Kimoto authored on 2016-06-11
128
            app->dbi->model('pull_request')->insert($new_pull_request);
129
            my $new_pull_request_row_id = app->dbi->execute("select LAST_INSERT_ROWID()")->value;
130
            
fix issue number bug
Yuki Kimoto authored on 2016-06-11
131
            # issue number
132
            $issue_number = app->dbi->model('issue')->select(
133
              'max(number)',
134
              where => {project => $project_row_id},
135
              append => 'group by project'
136
            )->value;
137
            $issue_number++;
138
            
fix compare page
Yuki Kimoto authored on 2016-06-11
139
            # New issue
140
            my $new_issue = {
add compare validation
Yuki Kimoto authored on 2016-05-04
141
              title => $title,
142
              open => 1,
143
              open_time => $now_epoch,
fix compare page
Yuki Kimoto authored on 2016-06-11
144
              open_user => $session_user_row_id,
fix issue number bug
Yuki Kimoto authored on 2016-06-11
145
              pull_request => $new_pull_request_row_id,
146
              project => $project_row_id,
147
              number => $issue_number
add compare validation
Yuki Kimoto authored on 2016-05-04
148
            };
fix compare page
Yuki Kimoto authored on 2016-06-11
149
            app->dbi->model('issue')->insert($new_issue);
fix issue number bug
Yuki Kimoto authored on 2016-06-11
150
            my $new_issue_row_id = app->dbi->execute("select LAST_INSERT_ROWID()")->value;
add compare validation
Yuki Kimoto authored on 2016-05-04
151
            
fix compare page
Yuki Kimoto authored on 2016-06-11
152
            # New issue message
153
            my $new_issue_message = {
fix pulls page
Yuki Kimoto authored on 2016-06-09
154
              issue => $new_issue_row_id,
fix compare page
Yuki Kimoto authored on 2016-06-11
155
              number => 1,
add compare validation
Yuki Kimoto authored on 2016-05-04
156
              message => $message,
157
              create_time => $now_epoch,
158
              update_time => $now_epoch,
159
              user => $session_user_row_id
160
            };
161
            
fix compare page
Yuki Kimoto authored on 2016-06-11
162
            app->dbi->model('issue_message')->insert($new_issue_message);
add compare validation
Yuki Kimoto authored on 2016-05-04
163
          });
fix create pull request logi...
Yuki Kimoto authored on 2016-04-23
164
          
fix issue number bug
Yuki Kimoto authored on 2016-06-11
165
          $self->redirect_to("/$base_user_id/$base_project_id/pull/$issue_number");
add compare validation
Yuki Kimoto authored on 2016-05-04
166
          return;
167
        }
168
      }
169
      else {
170
        $errors = $validation->messages;
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
171
      }
172
    }
173
  }
cleanup comapre
Yuki Kimoto authored on 2016-04-27
174

            
175
  # Can merge
fix compare branch link
Yuki Kimoto authored on 2016-04-28
176
  my $base_rep_info = app->rep_info($base_user_id, $base_project_id);
cleanup comapre
Yuki Kimoto authored on 2016-04-27
177
  my $merge_success;
fix compare branch link
Yuki Kimoto authored on 2016-04-28
178
  my $target_rep_info;
cleanup comapre
Yuki Kimoto authored on 2016-04-27
179
  if ($target_project) {
fix compare branch link
Yuki Kimoto authored on 2016-04-28
180
    $target_rep_info = app->rep_info($target_user_id, $target_project->{id});
cleanup comapre
Yuki Kimoto authored on 2016-04-27
181
  }
182
  else {
fix compare branch link
Yuki Kimoto authored on 2016-04-28
183
    $target_rep_info = $base_rep_info;
cleanup comapre
Yuki Kimoto authored on 2016-04-27
184
  }
185
    
186
  # Create working repository if it don't exist
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
187
  $self->app->manager->create_work_rep($base_user_id, $base_project_id);
cleanup comapre
Yuki Kimoto authored on 2016-04-27
188
  
189
  # Lock working repository
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
190
  my $work_rep_info = app->work_rep_info($base_user_id, $base_project_id);
cleanup comapre
Yuki Kimoto authored on 2016-04-27
191
  {
192
    my $lock_fh = $self->app->manager->lock_rep($work_rep_info);
193
    
194
    # Prepare merge
195
    $self->app->manager->prepare_merge(
196
      $work_rep_info,
fix compare branch link
Yuki Kimoto authored on 2016-04-28
197
      $base_rep_info,
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
198
      $base_branch,
fix compare branch link
Yuki Kimoto authored on 2016-04-28
199
      $target_rep_info,
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
200
      $target_branch
cleanup comapre
Yuki Kimoto authored on 2016-04-27
201
    );
202
    
203
    # Check merge automatically
204
    $merge_success = $self->app->manager->merge(
205
      $work_rep_info,
fix compare branch link
Yuki Kimoto authored on 2016-04-28
206
      $target_rep_info,
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
207
      $target_branch
cleanup comapre
Yuki Kimoto authored on 2016-04-27
208
    );
209
  }
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
210
  
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
211
  # Commits
fix compare page from forke...
Yuki Kimoto authored on 2016-08-20
212
  my $commits = $git->forward_commits(
213
    $work_rep_info,
214
    $base_rep_info,
215
    $base_branch,
216
    $target_rep_info,
217
    $target_branch
218
  );
219

            
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
220
  my $commits_count = @$commits;
221
  my $commits_date = {};
improved compare page commit...
Yuki Kimoto authored on 2013-02-06
222
  my $authors = {};
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
223
  for my $commit (@$commits) {
support time zone
Yuki Kimoto authored on 2014-03-08
224
    my $date = $commit->{age_string_date_local};
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
225
    $commits_date->{$date} ||= [];
improved compare page commit...
Yuki Kimoto authored on 2013-02-06
226
    $authors->{$commit->{author}} = 1;
added feature that get branc...
Yuki Kimoto authored on 2013-02-04
227
    push @{$commits_date->{$date}}, $commit;
228
  }
improved compare page commit...
Yuki Kimoto authored on 2013-02-06
229
  my $authors_count = keys %$authors;
added compare page file chan...
Yuki Kimoto authored on 2013-02-07
230

            
231
  # Start commit
fix compare page from forke...
Yuki Kimoto authored on 2016-08-20
232
  my $start_commit_id = app->git->ref_to_object_id($base_rep_info, $base_branch);
added compare page file chan...
Yuki Kimoto authored on 2013-02-07
233

            
234
  # End commit
fix compare page from forke...
Yuki Kimoto authored on 2016-08-20
235
  my $end_commit_id = app->git->ref_to_object_id($target_rep_info, $target_branch);
cleanup
Yuki Kimoto authored on 2013-05-13
236
  
fix compare page from forke...
Yuki Kimoto authored on 2016-08-20
237
  if (!$start_commit_id || !$end_commit_id) {
do success xt tests
Yuki Kimoto authored on 2016-03-25
238
    $self->reply->not_found;
cleanup
Yuki Kimoto authored on 2013-05-13
239
    return;
240
  }
added compare page file chan...
Yuki Kimoto authored on 2013-02-07
241
  
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
242
  # Member projects
243
  my $member_projects = app->manager->member_projects($base_user_id, $base_project_id);
244
  unshift @$member_projects, $base_project;
245
  
fix compare branch link
Yuki Kimoto authored on 2016-04-28
246
  # Base branches
247
  my $base_branches = $git->branches($base_rep_info);
248
  @$base_branches = sort { $a->{commit}{age} <=> $b->{commit}{age} } @$base_branches;
249

            
250
  # Target branches
251
  my $target_branches = $git->branches($target_rep_info);
252
  @$target_branches = sort { $a->{commit}{age} <=> $b->{commit}{age} } @$target_branches;
added base branch selection ...
Yuki Kimoto authored on 2013-05-10
253
  
add pull request form
Yuki Kimoto authored on 2016-04-12
254
  # Can open pull request
255
  my $can_open_pull_request;
256
  if (keys %$commits_date && $expand) {
257
    $can_open_pull_request = 1;
258
  }
259
  
cleanup merge and push logic
Yuki Kimoto authored on 2016-04-27
260
  # commit_body args
261
  my %commit_body_args = (
fix compare and pull page vi...
Yuki Kimoto authored on 2016-08-22
262
    user => $target_user_id,
263
    project => $target_project->{id},
fix compare page from forke...
Yuki Kimoto authored on 2016-08-20
264
    rep_info => $work_rep_info,
265
    rev => $end_commit_id,
266
    from_rev => $start_commit_id
cleanup merge and push logic
Yuki Kimoto authored on 2016-04-27
267
  );
268

            
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
269
  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
270
%>
271

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

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

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

            
292

            
293
    // Change head fork
294
    $('#head-fork-btn').on('click', function () {
295
      $('#head-fork-popup')
296
        .css('display', 'block')
297
        .css('top', '40px')
298
        .css('left', '10px')
299
      ;
300
    });
301
    $('#head-fork-popup').on('click', function () {
302
      $('#head-fork-popup').css('display', 'none');
303
    });
304
    // close popup
305
    $(document).click(function() { $('#head-fork-popup').hide(); });
306
    $('#head-fork-btn').click(function() { event.stopPropagation(); });
307
    $('#head-fork-popup').click(function() { event.stopPropagation(); });
308

            
improve compare page design
Yuki Kimoto authored on 2016-02-04
309
    // Change base branch
310
    $('#base-branch-btn').on('click', function () {
311
      $('#base-branch-popup')
312
        .css('display', 'block')
313
        .css('top', '40px')
314
        .css('left', '10px')
315
      ;
316
    });
317
    $('#base-branch-close').on('click', function () {
318
      $('#base-branch-popup').css('display', 'none');
319
    });
320
    $('[name=base-branch]').on('keypress', function (e) {
321
      // Enter
322
      if (e.which == 13) {
fix compare branch link
Yuki Kimoto authored on 2016-04-28
323
        var href;
improve compare page popup
Yuki Kimoto authored on 2016-04-28
324
        % if ($base_user_id eq $target_user_id) {
fix compare branch link
Yuki Kimoto authored on 2016-04-28
325
          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
326
        % } else {
fix compare branch link
Yuki Kimoto authored on 2016-04-28
327
          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
328
        % }
329
        
show not able to merge
Yuki Kimoto authored on 2016-04-18
330
        if (<%= $expand ? 1 : 0 %>) {
331
          href = href + '?expand=1';
332
        }
fix compare branch link
Yuki Kimoto authored on 2016-04-28
333
        
show not able to merge
Yuki Kimoto authored on 2016-04-18
334
        location.href = href;
improve compare page design
Yuki Kimoto authored on 2016-02-04
335
      }
336
    });
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
337
    // close popup
improve compare page popup
Yuki Kimoto authored on 2016-04-28
338
    $(document).click(function() { $('#base-branch-popup').hide(); });
339
    $('#base-branch-btn').click(function() { event.stopPropagation(); });
340
    $('#base-branch-popup').click(function() { event.stopPropagation(); });
show not able to merge
Yuki Kimoto authored on 2016-04-18
341
    
improve compare page design
Yuki Kimoto authored on 2016-02-04
342
    // Change compare branch
fix compare branch link
Yuki Kimoto authored on 2016-04-28
343
    $('#target-branch-btn').on('click', function () {
344
      $('#target-branch-popup')
improve compare page design
Yuki Kimoto authored on 2016-02-04
345
        .css('display', 'block')
346
        .css('top', '40px')
347
        .css('left', '96px')
348
      ;
349
    });
fix compare branch link
Yuki Kimoto authored on 2016-04-28
350
    $('#target-branch-close').on('click', function () {
351
      $('#target-branch-popup').css('display', 'none');
improve compare page design
Yuki Kimoto authored on 2016-02-04
352
    });
fix compare branch link
Yuki Kimoto authored on 2016-04-28
353
    $('[name=target-branch]').on('keypress', function (e) {
improve compare page design
Yuki Kimoto authored on 2016-02-04
354
      // Enter
355
      if (e.which == 13) {
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
356
        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
357
        if (<%= $expand ? 1 : 0 %>) {
358
          href = href + '?expand=1';
359
        }
360
        location.href = href;
improve compare page design
Yuki Kimoto authored on 2016-02-04
361
      }
improved compare page design
Yuki Kimoto authored on 2013-02-07
362
    });
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
363
    // close popup
fix compare branch link
Yuki Kimoto authored on 2016-04-28
364
    $(document).click(function() { $('#target-branch-popup').hide(); });
365
    $('#target-branch-btn').click(function() { event.stopPropagation(); });
366
    $('#target-branch-popup').click(function() { event.stopPropagation(); });
improve compare page popup
Yuki Kimoto authored on 2016-04-28
367

            
imrpvoe pull request form
Yuki Kimoto authored on 2016-07-09
368
    %= include '/include/add_issue_form_js';
improve compare page design
Yuki Kimoto authored on 2016-02-04
369
  });
370
% end
cleanup
Yuki Kimoto authored on 2013-02-04
371

            
add compare across forks btn...
Yuki Kimoto authored on 2016-08-18
372
%= javascript begin
373
  $(document).ready(function () {
374
    $('#comapre-across-btn').on('click', function () {
375
      $('#base-fork-btn').toggle();
376
      $('#head-fork-btn').toggle();
377
    });
378
  });
379
% end
380

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

            
improve compare page design
Yuki Kimoto authored on 2016-02-04
383
<div class="container">
add compare validation
Yuki Kimoto authored on 2016-05-04
384
  %= include '/include/errors', errors => $errors;
385
  
add pull request form
Yuki Kimoto authored on 2016-04-12
386
  <div class="topic1">
387
    % if ($can_open_pull_request) {
388
      Open a pull request
389
    % } else {
add compare across forks btn...
Yuki Kimoto authored on 2016-08-18
390
      Compare changes
add pull request form
Yuki Kimoto authored on 2016-04-12
391
    % }
392
  </div>
add compare across forks btn...
Yuki Kimoto authored on 2016-08-18
393
  <div class="compare-desc">
394
    Compare changes across branches, commits, tags, and more below. If you need to, you can also <a href="javascript:void(0)" id="comapre-across-btn">compare across forks</a>.
395
  </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
396
  <div class="compare-select">
397
    <div>
398
      <div>
improve compare page popup
Yuki Kimoto authored on 2016-04-28
399
        <div style="display:inline-block">
add compare across forks btn...
Yuki Kimoto authored on 2016-08-18
400
          <button id="base-fork-btn" class="btn btn-small" style="<%= $base_user_id eq $target_user_id ? 'display:none' : '' %>">
401
            <span>base fork:</span><b> <%= $base_project->{'user.id'} %>/<%= $base_project->{id} %></b><i class="icon-arrow-down"></i>
402
          </button>
improve compare page popup
Yuki Kimoto authored on 2016-04-28
403
          <button id="base-branch-btn" class="btn btn-small">
404
            <span>base:</span><b> <%= $base_branch %></b><i class="icon-arrow-down"></i>
405
          </button>
406
          ...
407
        </div>
complete pull request logic
Yuki Kimoto authored on 2016-04-28
408
        <div style="display:inline-block;margin-top:10px;">
add compare across forks btn...
Yuki Kimoto authored on 2016-08-18
409
          <button id="head-fork-btn" class="btn btn-small" style="<%= $base_user_id eq $target_user_id ? 'display:none' : '' %>">
410
            <span>head fork:</span><b> <%= $target_project->{'user.id'} %>/<%= $target_project->{id} %></b><i class="icon-arrow-down"></i>
411
          </button>
fix compare branch link
Yuki Kimoto authored on 2016-04-28
412
          <button id="target-branch-btn" class="btn btn-small">
improve compare page popup
Yuki Kimoto authored on 2016-04-28
413
            <span>compare:</span> <b><%= $target_branch %></b><i class="icon-arrow-down"></i>
414
          </button>
add compare across forks btn...
Yuki Kimoto authored on 2016-08-18
415
          
improve compare page popup
Yuki Kimoto authored on 2016-04-28
416
          % if ($can_open_pull_request) {
417
            % if ($merge_success) {
418
              <span style="margin-left:10px">
419
                <span style="color:green;font-weight:bold"><%= "\x{2714}" %>Able to merge.</span> These branches can be automatically merged.
420
              </span>
421
            % } else {
422
              <span style="margin-left:10px">
issue belong to project
Yuki Kimoto authored on 2016-06-11
423
                <span style="color:red;font-weight:bold">Not able to merge.</span> These branches can't be automatically merged.
improve compare page popup
Yuki Kimoto authored on 2016-04-28
424
              </span>
425
            % }
show not able to merge
Yuki Kimoto authored on 2016-04-18
426
          % }
improve compare page popup
Yuki Kimoto authored on 2016-04-28
427
        </div>
cleanup
Yuki Kimoto authored on 2013-03-15
428
      </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
429
    </div>
show not able to merge
Yuki Kimoto authored on 2016-04-18
430

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

            
fix compare branch link
Yuki Kimoto authored on 2016-04-28
469
    <div id="target-branch-popup" style="display:none;width:330px;position:absolute">
improve compare page design
Yuki Kimoto authored on 2016-02-04
470
      <div class="radius-top border-gray" style="background:#E6E6FA;padding:10px">
471
        <div style="overflow:hidden">
472
          <div style="float:left;width:90%;">
473
            <b>Choose a compare branch</b>
474
          </div>
475
          <div style="float:left:width:10%;text-align:right;">
fix compare branch link
Yuki Kimoto authored on 2016-04-28
476
            <i id="target-branch-close" class="icon-remove-circle"></i>
added compare branch popup t...
Yuki Kimoto authored on 2013-05-10
477
          </div>
478
        </div>
479
      </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
480
      <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
481
        %= 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
482
      </div>
483
      <div style="background:white;max-height:500px;overflow:auto;">
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
484
        <ul class="nav nav-tabs nav-stacked">
485
          % for (my $i = 0; $i < @$target_branches; $i++) {
486
            % my $target_branch = $target_branches->[$i];
487
              <li>
488
                <%
489
                  my $url;
490
                  if ($base_user_id eq $target_user_id) {
491
                    $url = url_with("/$base_user_id/$base_project_id/compare/$base_branch...$target_branch->{name}");
492
                  }
493
                  else {
494
                    $url = url_with("/$base_user_id/$base_project_id/compare/$base_branch...$target_user_id:$target_branch->{name}");
495
                  }
496
                %>
497
                <a style="border-top-left-radius:0px;border-top-right-radius:0px;" href="<%= $url %>">
498
                  <%= $target_branch->{name} %>
499
                </a>
500
              </li>
501
          % }
502
        </ul>
503
      </div>
504
    </div>
505

            
506

            
507
    <div id="base-fork-popup" style="display:none;width:330px;position:absolute">
508
      <div class="radius-top border-gray" style="background:#E6E6FA;padding:10px">
509
        <div style="overflow:hidden">
510
          <div style="float:left;width:90%;">
511
            <b>Choose a base fork</b>
512
          </div>
513
          <div style="float:left:width:10%;text-align:right;">
514
            <i id="member-project-close" class="icon-remove-circle"></i>
515
          </div>
516
        </div>
517
      </div>
518
      <div style="background:white;max-height:500px;overflow:auto;">
519
        <ul class="nav nav-tabs nav-stacked">
520
          % for (my $i = 0; $i < @$member_projects; $i++) {
521
            % my $member_project = $member_projects->[$i];
fix compare branch link
Yuki Kimoto authored on 2016-04-28
522
              <%
remove table __ prefix
Yuki Kimoto authored on 2016-06-11
523
                my $member_user_id = $member_project->{'user.id'};
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
524
                my $member_project_id = $member_project->{id};
fix compare branch link
Yuki Kimoto authored on 2016-04-28
525
              %>
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
526
              <li>
527
                <%
528
                  my $url;
529
                  if ($member_user_id eq $target_user_id) {
530
                    $url = url_with("/$member_user_id/$member_project_id/compare/$base_branch...$target_branch");
531
                  }
532
                  else {
533
                    $url = url_with("/$member_user_id/$member_project_id/compare/$base_branch...$target_user_id:$target_branch");
534
                  }
535
                %>
536
                <a style="border-top-left-radius:0px;border-top-right-radius:0px;" href="<%= $url %>">
537
                  <%= $member_user_id %>/<%= $member_project_id %>
538
                </a>
539
              </li>
540
          % }
541
        </ul>
542
      </div>
543
    </div>
544

            
545

            
546

            
547

            
548
    <div id="head-fork-popup" style="display:none;width:330px;position:absolute">
549
      <div class="radius-top border-gray" style="background:#E6E6FA;padding:10px">
550
        <div style="overflow:hidden">
551
          <div style="float:left;width:90%;">
552
            <b>Choose a head fork</b>
553
          </div>
554
          <div style="float:left:width:10%;text-align:right;">
555
            <i id="member-project-close" class="icon-remove-circle"></i>
556
          </div>
557
        </div>
558
      </div>
559
      <div style="background:white;max-height:500px;overflow:auto;">
560
        <ul class="nav nav-tabs nav-stacked">
561
          % for (my $i = 0; $i < @$member_projects; $i++) {
562
            % my $member_project = $member_projects->[$i];
563
              <%
remove table __ prefix
Yuki Kimoto authored on 2016-06-11
564
                my $member_user_id = $member_project->{'user.id'};
fix compare base and head fo...
Yuki Kimoto authored on 2016-04-28
565
                my $member_project_id = $member_project->{id};
566
              %>
567
              <li>
568
                <%
569
                  my $url;
570
                  if ($member_user_id eq $base_user_id) {
571
                    $url = url_with("/$base_user_id/$base_project_id/compare/$base_branch...$target_branch");
572
                  }
573
                  else {
574
                    $url = url_with("/$base_user_id/$base_project_id/compare/$base_branch...$member_user_id:$target_branch");
575
                  }
576
                %>
577
                <a style="border-top-left-radius:0px;border-top-right-radius:0px;" href="<%= $url %>">
578
                  <%= $member_user_id %>/<%= $member_project_id %>
579
                </a>
580
              </li>
581
          % }
582
        </ul>
improve compare page design
Yuki Kimoto authored on 2016-02-04
583
      </div>
added base branch selection ...
Yuki Kimoto authored on 2013-05-10
584
    </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
585
  </div>
add pull reqeust link button...
Yuki Kimoto authored on 2016-08-20
586
  
587
  % if ($pull_request_already) {
588
    <%
589
      my $issue = app->dbi->model('issue')->select(
590
        where => {
591
          project => $base_project->{row_id},
592
          pull_request => $pull_request_already->{row_id}
593
        }
594
      )->one;
595
    %>
596
    
597
    <div class="compare-pull-request-link">
598
      <a href="<%= url_for("/$base_user_id/$base_project_id/pull/$issue->{number}") %>">
599
        Pull request #<%= $issue->{number} %>
600
      </a>
601
    </div>
602
  % } elsif (keys %$commits_date && $merge_success) {
imrpvoe pull request form
Yuki Kimoto authored on 2016-07-09
603
    <div class="issue-add-comment" style="width:80%">
add create pull request logi...
Yuki Kimoto authored on 2016-04-19
604
      <form action="<%= url_for %>" method="post">
605
        <%= hidden_field op => 'create-pull-request' %>
imrpvoe pull request form
Yuki Kimoto authored on 2016-07-09
606
        <div class="issue-add-comment-header">
607
          <div class="issue-add-comment-title">
608
            <%= text_field 'title' => $commits->[0]{title_short} %>
609
          </div>
cleanup issue preview
Yuki Kimoto authored on 2016-07-25
610
          <div class="issue-message-write-tab issue-add-comment-header-tab"><a href="javascript:void(0)">Write</a></div>
611
          <div class="issue-message-preview-tab issue-add-comment-header-tab"><a class="disable" href="javascript:void(0)">Preview</a></div>
612
          %= include '/include/issue_comment_icon';
add pull request form
Yuki Kimoto authored on 2016-04-12
613
        </div>
imrpvoe pull request form
Yuki Kimoto authored on 2016-07-09
614
        <div class="issue-add-comment-body">
cleanup issue preview
Yuki Kimoto authored on 2016-07-25
615
          <div class="issue-message-write-area issue-add-comment-message">
imrpvoe pull request form
Yuki Kimoto authored on 2016-07-09
616
            <%= text_area 'message' %>
617
          </div>
cleanup issue preview
Yuki Kimoto authored on 2016-07-25
618
          <div class="issue-message-preview-area issue-add-comment-preview markdown-body" style="padding:10px">
imrpvoe pull request form
Yuki Kimoto authored on 2016-07-09
619
          </div>
620
          <div class="issue-add-comment-bottom">
621
            <div class="issue-add-comment-button-left">
622
              Styling with Markdown is supported
623
            </div>
624
            <div class="issue-add-comment-button">
rename btn-success to btn-gr...
Yuki Kimoto authored on 2016-11-30
625
              <input type="submit" value="Create pull request" class="btn btn-green">
imrpvoe pull request form
Yuki Kimoto authored on 2016-07-09
626
            </div>
627
          </div>
add pull request form
Yuki Kimoto authored on 2016-04-12
628
        </div>
629
      </form>
630
    </div>
631
  % }
added base branch popup to c...
Yuki Kimoto authored on 2013-05-10
632

            
improve compare page design
Yuki Kimoto authored on 2016-02-04
633
  % if (keys %$commits_date) {
634
    <ul class="compare-header">
635
      <li>
636
        <b><%= @$commits %></b> <span>commit</span>
637
      </li>
638
      <li>
639
        <b><%= $authors_count %></b> <span>contributor</span>
640
      </li>
641
      <li>
642
        
643
      </li>
644
      <li>
645
        
646
      </li>
647
    </ul>
improved compare page design
Yuki Kimoto authored on 2013-02-07
648
    
improve compare page design
Yuki Kimoto authored on 2016-02-04
649
    <div class="commits">
expand compare page tabs
Yuki Kimoto authored on 2013-08-10
650
      % for my $date (reverse sort keys %$commits_date) {
651
        % my $commits = $commits_date->{$date};
652
        
improve compare page design
Yuki Kimoto authored on 2016-02-04
653
        <div class="commit-date">
654
          <i class="icon-off"></i><span>Commits on <%= $date %></span>
expand compare page tabs
Yuki Kimoto authored on 2013-08-10
655
        </div>
656
        
improve compare page design
Yuki Kimoto authored on 2016-02-04
657
        <ul class="compare-commits-date-container">
expand compare page tabs
Yuki Kimoto authored on 2013-08-10
658
          % for my $commit (sort {$b->{author_epoch} <=> $a->{author_epoch}} @$commits) {
add user page link from user...
Yuki Kimoto authored on 2016-04-11
659
            <%
fix mail bug
Yuki Kimoto authored on 2016-04-21
660
              my $commit_author_email = $commit->{author_email};
add user page link from user...
Yuki Kimoto authored on 2016-04-11
661
              my $commit_author_id = app->dbi->model('user')->select(
662
                'id',
fix mail bug
Yuki Kimoto authored on 2016-04-21
663
                where => {email => $commit_author_email}
add user page link from user...
Yuki Kimoto authored on 2016-04-11
664
              )->value;
665
            %>
improve compare page design
Yuki Kimoto authored on 2016-02-04
666
            <li>
667
              <div class="compare-commits-author">
add user page link from user...
Yuki Kimoto authored on 2016-04-11
668
                <span title="<%= $commit->{author_email} %>">
669
                  % if (defined $commit_author_id) {
670
                    <a href="<%= url_for("/$commit_author_id") %>"><%= $commit_author_id %></a>
671
                  % } else {
672
                    <%= $commit->{author_name} %>
673
                  % }
674
                </span>
expand compare page tabs
Yuki Kimoto authored on 2013-08-10
675
              </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
676
              <div class="compare-commits-commit-title">
fix compare and pull page vi...
Yuki Kimoto authored on 2016-08-22
677
                <a style="color:#333" href="<%= url_for("/$target_user_id/$target_project->{id}/commit/$commit->{id}") %>">
improve compare page design
Yuki Kimoto authored on 2016-02-04
678
                  <%= $commit->{title_short} %>
679
                </a>
680
              </div>
681
              <div class="compare-commits-commit-id">
fix compare and pull page vi...
Yuki Kimoto authored on 2016-08-22
682
                <a href="<%= url_for("/$target_user_id/$target_project->{id}/commit/$commit->{id}") %>">
improve compare page design
Yuki Kimoto authored on 2016-02-04
683
                  <%= substr($commit->{id}, 0, 7) %>
684
                </a>
685
              </div>
686
            </li>
improved branches page and c...
Yuki Kimoto authored on 2013-05-07
687
          % }
improve compare page design
Yuki Kimoto authored on 2016-02-04
688
        </ul>
expand compare page tabs
Yuki Kimoto authored on 2013-08-10
689
      % }
improve compare page design
Yuki Kimoto authored on 2016-02-04
690
    </div>
691
  
cleanup merge and push logic
Yuki Kimoto authored on 2016-04-27
692
    %= include '/include/commit_body', %commit_body_args;
improve compare page design
Yuki Kimoto authored on 2016-02-04
693
  % } else {
improve compare page
Yuki Kimoto authored on 2016-04-12
694
    <div class="compare-nothing">
695
      <div>
696
        <b><big>There isn't anything to compare.</big></b>
697
      </div>
698
      <div>
show not able to merge
Yuki Kimoto authored on 2016-04-18
699
        <b>
fix pull_request table bug
Yuki Kimoto authored on 2016-04-27
700
          <%= $base_branch %></b> is up to date with all commits from
701
          <b><%= $target_branch %></b>.
702
          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
703
      </div>
improve compare page design
Yuki Kimoto authored on 2016-02-04
704
    </div>
705
  % }
706
</div>
707
%= include '/include/footer';