...
|
...
|
@@ -120,8 +120,6 @@
|
120
|
120
|
user => $user_row_id
|
121
|
121
|
};
|
122
|
122
|
|
123
|
|
- use D;d $new_pull_request_message_params;
|
124
|
|
-
|
125
|
123
|
app->dbi->model('pull_request_message')->insert($new_pull_request_message_params);
|
126
|
124
|
});
|
127
|
125
|
|
...
|
...
|
@@ -132,14 +130,14 @@
|
132
|
130
|
}
|
133
|
131
|
|
134
|
132
|
# Can merge
|
135
|
|
- my $rep_info = app->rep_info($base_user_id, $base_project_id);
|
|
133
|
+ my $base_rep_info = app->rep_info($base_user_id, $base_project_id);
|
136
|
134
|
my $merge_success;
|
137
|
|
- my $rep_info2;
|
|
135
|
+ my $target_rep_info;
|
138
|
136
|
if ($target_project) {
|
139
|
|
- $rep_info2 = app->rep_info($target_user_id, $target_project->{id});
|
|
137
|
+ $target_rep_info = app->rep_info($target_user_id, $target_project->{id});
|
140
|
138
|
}
|
141
|
139
|
else {
|
142
|
|
- $rep_info2 = $rep_info;
|
|
140
|
+ $target_rep_info = $base_rep_info;
|
143
|
141
|
}
|
144
|
142
|
|
145
|
143
|
# Create working repository if it don't exist
|
...
|
...
|
@@ -153,24 +151,24 @@
|
153
|
151
|
# Prepare merge
|
154
|
152
|
$self->app->manager->prepare_merge(
|
155
|
153
|
$work_rep_info,
|
156
|
|
- $rep_info,
|
|
154
|
+ $base_rep_info,
|
157
|
155
|
$base_branch,
|
158
|
|
- $rep_info2,
|
|
156
|
+ $target_rep_info,
|
159
|
157
|
$target_branch
|
160
|
158
|
);
|
161
|
159
|
|
162
|
160
|
# Check merge automatically
|
163
|
161
|
$merge_success = $self->app->manager->merge(
|
164
|
162
|
$work_rep_info,
|
165
|
|
- $rep_info,
|
|
163
|
+ $base_rep_info,
|
166
|
164
|
$base_branch,
|
167
|
|
- $rep_info2,
|
|
165
|
+ $target_rep_info,
|
168
|
166
|
$target_branch
|
169
|
167
|
);
|
170
|
168
|
}
|
171
|
169
|
|
172
|
170
|
# Commits
|
173
|
|
- my $commits = $git->forward_commits($rep_info, $base_branch, $target_branch);
|
|
171
|
+ my $commits = $git->forward_commits($base_rep_info, $base_branch, $target_branch);
|
174
|
172
|
my $commits_count = @$commits;
|
175
|
173
|
my $commits_date = {};
|
176
|
174
|
my $authors = {};
|
...
|
...
|
@@ -183,19 +181,23 @@
|
183
|
181
|
my $authors_count = keys %$authors;
|
184
|
182
|
|
185
|
183
|
# Start commit
|
186
|
|
- my $start_commit = $git->separated_commit($rep_info, $base_branch, $target_branch);
|
|
184
|
+ my $start_commit = $git->separated_commit($base_rep_info, $base_branch, $target_branch);
|
187
|
185
|
|
188
|
186
|
# End commit
|
189
|
|
- my $end_commit = $git->get_commit($rep_info2, $target_branch);
|
|
187
|
+ my $end_commit = $git->get_commit($target_rep_info, $target_branch);
|
190
|
188
|
|
191
|
189
|
if (!$start_commit || !$end_commit) {
|
192
|
190
|
$self->reply->not_found;
|
193
|
191
|
return;
|
194
|
192
|
}
|
195
|
193
|
|
196
|
|
- # Branches
|
197
|
|
- my $branches = $git->branches($rep_info);
|
198
|
|
- @$branches = sort { $a->{commit}{age} <=> $b->{commit}{age} } @$branches;
|
|
194
|
+ # Base branches
|
|
195
|
+ my $base_branches = $git->branches($base_rep_info);
|
|
196
|
+ @$base_branches = sort { $a->{commit}{age} <=> $b->{commit}{age} } @$base_branches;
|
|
197
|
+
|
|
198
|
+ # Target branches
|
|
199
|
+ my $target_branches = $git->branches($target_rep_info);
|
|
200
|
+ @$target_branches = sort { $a->{commit}{age} <=> $b->{commit}{age} } @$target_branches;
|
199
|
201
|
|
200
|
202
|
# Can open pull request
|
201
|
203
|
my $can_open_pull_request;
|
...
|
...
|
@@ -232,17 +234,17 @@
|
232
|
234
|
$('[name=base-branch]').on('keypress', function (e) {
|
233
|
235
|
// Enter
|
234
|
236
|
if (e.which == 13) {
|
235
|
|
- % use D;d [$base_user_id, $target_user_id];
|
236
|
|
-
|
|
237
|
+ var href;
|
237
|
238
|
% if ($base_user_id eq $target_user_id) {
|
238
|
|
- var href = '<%= url_for("/$base_user_id/$base_project_id/compare/") %>' + $(this).val() + '...<%= $target_branch %>';
|
|
239
|
+ href = '<%= url_for("/$base_user_id/$base_project_id/compare/") %>' + $(this).val() + '...<%= $target_branch %>';
|
239
|
240
|
% } else {
|
240
|
|
- var href = '<%= url_for("/$base_user_id/$base_project_id/compare/") %>' + $(this).val() + '...<%= $target_user_id %>:<%= $target_branch %>';
|
|
241
|
+ href = '<%= url_for("/$base_user_id/$base_project_id/compare/") %>' + $(this).val() + '...<%= $target_user_id %>:<%= $target_branch %>';
|
241
|
242
|
% }
|
242
|
243
|
|
243
|
244
|
if (<%= $expand ? 1 : 0 %>) {
|
244
|
245
|
href = href + '?expand=1';
|
245
|
246
|
}
|
|
247
|
+
|
246
|
248
|
location.href = href;
|
247
|
249
|
}
|
248
|
250
|
});
|
...
|
...
|
@@ -252,17 +254,17 @@
|
252
|
254
|
$('#base-branch-popup').click(function() { event.stopPropagation(); });
|
253
|
255
|
|
254
|
256
|
// Change compare branch
|
255
|
|
- $('#compare-branch-btn').on('click', function () {
|
256
|
|
- $('#compare-branch-popup')
|
|
257
|
+ $('#target-branch-btn').on('click', function () {
|
|
258
|
+ $('#target-branch-popup')
|
257
|
259
|
.css('display', 'block')
|
258
|
260
|
.css('top', '40px')
|
259
|
261
|
.css('left', '96px')
|
260
|
262
|
;
|
261
|
263
|
});
|
262
|
|
- $('#compare-branch-close').on('click', function () {
|
263
|
|
- $('#compare-branch-popup').css('display', 'none');
|
|
264
|
+ $('#target-branch-close').on('click', function () {
|
|
265
|
+ $('#target-branch-popup').css('display', 'none');
|
264
|
266
|
});
|
265
|
|
- $('[name=compare-branch]').on('keypress', function (e) {
|
|
267
|
+ $('[name=target-branch]').on('keypress', function (e) {
|
266
|
268
|
// Enter
|
267
|
269
|
if (e.which == 13) {
|
268
|
270
|
var href = '<%= url_for("/$base_user_id/$base_project_id/compare/") %>' + '<%= $base_branch %>...' + $(this).val();
|
...
|
...
|
@@ -273,9 +275,9 @@
|
273
|
275
|
}
|
274
|
276
|
});
|
275
|
277
|
// ポップアップを閉じる
|
276
|
|
- $(document).click(function() { $('#compare-branch-popup').hide(); });
|
277
|
|
- $('#compare-branch-btn').click(function() { event.stopPropagation(); });
|
278
|
|
- $('#compare-branch-popup').click(function() { event.stopPropagation(); });
|
|
278
|
+ $(document).click(function() { $('#target-branch-popup').hide(); });
|
|
279
|
+ $('#target-branch-btn').click(function() { event.stopPropagation(); });
|
|
280
|
+ $('#target-branch-popup').click(function() { event.stopPropagation(); });
|
279
|
281
|
|
280
|
282
|
});
|
281
|
283
|
% end
|
...
|
...
|
@@ -310,7 +312,7 @@
|
310
|
312
|
<span>head fork:</span><b> <%= $target_project->{'__user.id'} %>/<%= $target_project->{id} %></b><i class="icon-arrow-down"></i>
|
311
|
313
|
</button>
|
312
|
314
|
% }
|
313
|
|
- <button id="compare-branch-btn" class="btn btn-small">
|
|
315
|
+ <button id="target-branch-btn" class="btn btn-small">
|
314
|
316
|
<span>compare:</span> <b><%= $target_branch %></b><i class="icon-arrow-down"></i>
|
315
|
317
|
</button>
|
316
|
318
|
|
...
|
...
|
@@ -345,11 +347,20 @@
|
345
|
347
|
</div>
|
346
|
348
|
<div style="background:white;max-height:500px;overflow:auto;">
|
347
|
349
|
<ul class="nav nav-tabs nav-stacked">
|
348
|
|
- % for (my $i = 0; $i < @$branches; $i++) {
|
349
|
|
- % my $branch = $branches->[$i];
|
|
350
|
+ % for (my $i = 0; $i < @$base_branches; $i++) {
|
|
351
|
+ % my $branch = $base_branches->[$i];
|
350
|
352
|
<li>
|
|
353
|
+ <%
|
|
354
|
+ my $url;
|
|
355
|
+ if ($base_user_id eq $target_user_id) {
|
|
356
|
+ $url = url_with("/$base_user_id/$base_project_id/compare/$branch->{name}...$target_branch");
|
|
357
|
+ }
|
|
358
|
+ else {
|
|
359
|
+ $url = url_with("/$base_user_id/$base_project_id/compare/$branch->{name}...$target_user_id:$target_branch");
|
|
360
|
+ }
|
|
361
|
+ %>
|
351
|
362
|
<a style="border-top-left-radius:0px;border-top-right-radius:0px;"
|
352
|
|
- href="<%= url_with("/$base_user_id/$base_project_id/compare/$branch->{name}...$target_branch") %>">
|
|
363
|
+ href="<%= $url %>">
|
353
|
364
|
<%= $branch->{name} %>
|
354
|
365
|
</a>
|
355
|
366
|
</li>
|
...
|
...
|
@@ -358,28 +369,36 @@
|
358
|
369
|
</div>
|
359
|
370
|
</div>
|
360
|
371
|
|
361
|
|
- <div id="compare-branch-popup" style="display:none;width:330px;position:absolute">
|
|
372
|
+ <div id="target-branch-popup" style="display:none;width:330px;position:absolute">
|
362
|
373
|
<div class="radius-top border-gray" style="background:#E6E6FA;padding:10px">
|
363
|
374
|
<div style="overflow:hidden">
|
364
|
375
|
<div style="float:left;width:90%;">
|
365
|
376
|
<b>Choose a compare branch</b>
|
366
|
377
|
</div>
|
367
|
378
|
<div style="float:left:width:10%;text-align:right;">
|
368
|
|
- <i id="compare-branch-close" class="icon-remove-circle"></i>
|
|
379
|
+ <i id="target-branch-close" class="icon-remove-circle"></i>
|
369
|
380
|
</div>
|
370
|
381
|
</div>
|
371
|
382
|
</div>
|
372
|
383
|
<div class="border-gray" style="background:#F5F5F5;border-top:none;border-bottom:none;text-align:center;padding:10px 0">
|
373
|
|
- %= text_field 'compare-branch', style => 'margin-bottom:0;width:270px', placeholder => 'Branch, tag, commit, or history marker';
|
|
384
|
+ %= text_field 'target-branch', style => 'margin-bottom:0;width:270px', placeholder => 'Branch, tag, commit, or history marker';
|
374
|
385
|
</div>
|
375
|
386
|
<div style="background:white;max-height:500px;overflow:auto;">
|
376
|
387
|
<ul class="nav nav-tabs nav-stacked">
|
377
|
|
- % for (my $i = 0; $i < @$branches; $i++) {
|
378
|
|
- % my $branch = $branches->[$i];
|
|
388
|
+ % for (my $i = 0; $i < @$target_branches; $i++) {
|
|
389
|
+ % my $target_branch = $target_branches->[$i];
|
379
|
390
|
<li>
|
380
|
|
- <a style="border-top-left-radius:0px;border-top-right-radius:0px;"
|
381
|
|
- href="<%= url_with("/$base_user_id/$base_project_id/compare/$base_branch...$branch->{name}") %>">
|
382
|
|
- <%= $branch->{name} %>
|
|
391
|
+ <%
|
|
392
|
+ my $url;
|
|
393
|
+ if ($base_user_id eq $target_user_id) {
|
|
394
|
+ $url = url_with("/$base_user_id/$base_project_id/compare/$base_branch...$target_branch->{name}");
|
|
395
|
+ }
|
|
396
|
+ else {
|
|
397
|
+ $url = url_with("/$base_user_id/$base_project_id/compare/$base_branch...$target_user_id:$target_branch->{name}");
|
|
398
|
+ }
|
|
399
|
+ %>
|
|
400
|
+ <a style="border-top-left-radius:0px;border-top-right-radius:0px;" href="<%= $url %>">
|
|
401
|
+ <%= $target_branch->{name} %>
|
383
|
402
|
</a>
|
384
|
403
|
</li>
|
385
|
404
|
% }
|