| ... | ... |
@@ -434,8 +434,8 @@ sub startup {
|
| 434 | 434 |
$r->get('/pulls' => sub { shift->render_maybe('/pulls') })->to(tab => 'pulls');
|
| 435 | 435 |
|
| 436 | 436 |
# Pull request |
| 437 |
- $r->get('/pull/(:row_id).patch' => sub { shift->render_maybe('/pull') })->to(tab => 'pulls', patch => 1);
|
|
| 438 |
- $r->any('/pull/:row_id' => sub { shift->render_maybe('/pull') })->to(tab => 'pulls');
|
|
| 437 |
+ $r->get('/pull/(:number).patch' => sub { shift->render_maybe('/pull') })->to(tab => 'pulls', patch => 1);
|
|
| 438 |
+ $r->any('/pull/:number' => sub { shift->render_maybe('/pull') })->to(tab => 'pulls');
|
|
| 439 | 439 |
|
| 440 | 440 |
# Commit |
| 441 | 441 |
$r->get('/commit/*diff' => sub { shift->render_maybe('/commit') });
|
| ... | ... |
@@ -91,14 +91,14 @@ |
| 91 | 91 |
$issue = app->dbi->model('issue')->select(
|
| 92 | 92 |
where => {pull_request => $pull_request->{row_id}}
|
| 93 | 93 |
)->one; |
| 94 |
- $self->redirect_to("/$base_user_id/$base_project_id/pull/$issue->{row_id}");
|
|
| 94 |
+ $self->redirect_to("/$base_user_id/$base_project_id/pull/$issue->{number}");
|
|
| 95 | 95 |
return; |
| 96 | 96 |
} |
| 97 | 97 |
else {
|
| 98 | 98 |
my $now_tm = Time::Moment->now_utc; |
| 99 | 99 |
my $now_epoch = $now_tm->epoch; |
| 100 | 100 |
my $session_user_row_id = $api->session_user_row_id; |
| 101 |
- my $new_issue_row_id; |
|
| 101 |
+ my $issue_number; |
|
| 102 | 102 |
app->dbi->connector->txn(sub {
|
| 103 | 103 |
|
| 104 | 104 |
# New pull request |
| ... | ... |
@@ -109,19 +109,30 @@ |
| 109 | 109 |
target_branch => $target_branch, |
| 110 | 110 |
}; |
| 111 | 111 |
|
| 112 |
+ # last pull request row id |
|
| 112 | 113 |
app->dbi->model('pull_request')->insert($new_pull_request);
|
| 113 | 114 |
my $new_pull_request_row_id = app->dbi->execute("select LAST_INSERT_ROWID()")->value;
|
| 114 | 115 |
|
| 116 |
+ # issue number |
|
| 117 |
+ $issue_number = app->dbi->model('issue')->select(
|
|
| 118 |
+ 'max(number)', |
|
| 119 |
+ where => {project => $project_row_id},
|
|
| 120 |
+ append => 'group by project' |
|
| 121 |
+ )->value; |
|
| 122 |
+ $issue_number++; |
|
| 123 |
+ |
|
| 115 | 124 |
# New issue |
| 116 | 125 |
my $new_issue = {
|
| 117 | 126 |
title => $title, |
| 118 | 127 |
open => 1, |
| 119 | 128 |
open_time => $now_epoch, |
| 120 | 129 |
open_user => $session_user_row_id, |
| 121 |
- pull_request => $new_pull_request_row_id |
|
| 130 |
+ pull_request => $new_pull_request_row_id, |
|
| 131 |
+ project => $project_row_id, |
|
| 132 |
+ number => $issue_number |
|
| 122 | 133 |
}; |
| 123 | 134 |
app->dbi->model('issue')->insert($new_issue);
|
| 124 |
- $new_issue_row_id = app->dbi->execute("select LAST_INSERT_ROWID()")->value;
|
|
| 135 |
+ my $new_issue_row_id = app->dbi->execute("select LAST_INSERT_ROWID()")->value;
|
|
| 125 | 136 |
|
| 126 | 137 |
# New issue message |
| 127 | 138 |
my $new_issue_message = {
|
| ... | ... |
@@ -136,7 +147,7 @@ |
| 136 | 147 |
app->dbi->model('issue_message')->insert($new_issue_message);
|
| 137 | 148 |
}); |
| 138 | 149 |
|
| 139 |
- $self->redirect_to("/$base_user_id/$base_project_id/pull/$new_issue_row_id");
|
|
| 150 |
+ $self->redirect_to("/$base_user_id/$base_project_id/pull/$issue_number");
|
|
| 140 | 151 |
return; |
| 141 | 152 |
} |
| 142 | 153 |
} |
| ... | ... |
@@ -5,7 +5,7 @@ |
| 5 | 5 |
# Parameters |
| 6 | 6 |
my $base_user_id = param('user');
|
| 7 | 7 |
my $base_project_id = param('project');
|
| 8 |
- my $row_id = param('row_id');
|
|
| 8 |
+ my $issue_number = param('number');
|
|
| 9 | 9 |
|
| 10 | 10 |
# Issue |
| 11 | 11 |
my $issue = app->dbi->model('issue')->select(
|
| ... | ... |
@@ -13,7 +13,10 @@ |
| 13 | 13 |
{__MY__ => '*'},
|
| 14 | 14 |
{open_user => ['id']}
|
| 15 | 15 |
], |
| 16 |
- where => {'issue.row_id' => $row_id}
|
|
| 16 |
+ where => {
|
|
| 17 |
+ 'project.id' => $base_project_id, |
|
| 18 |
+ 'issue.number' => $issue_number |
|
| 19 |
+ } |
|
| 17 | 20 |
)->one; |
| 18 | 21 |
|
| 19 | 22 |
# Pull requests |
| ... | ... |
@@ -105,10 +108,12 @@ |
| 105 | 108 |
if ($op eq 'close') {
|
| 106 | 109 |
app->dbi->model('issue')->update(
|
| 107 | 110 |
{
|
| 108 |
- open => 0, |
|
| 109 |
- open_user => $session_user_row_id |
|
| 111 |
+ open => 0 |
|
| 110 | 112 |
}, |
| 111 |
- where => {row_id => $row_id}
|
|
| 113 |
+ where => {
|
|
| 114 |
+ 'project.id' => $base_project_id, |
|
| 115 |
+ 'issue.number' => $issue_number |
|
| 116 |
+ } |
|
| 112 | 117 |
); |
| 113 | 118 |
$self->redirect_to('current');
|
| 114 | 119 |
return; |
| ... | ... |
@@ -121,7 +126,10 @@ |
| 121 | 126 |
open_time => $open_time, |
| 122 | 127 |
open_user => $session_user_row_id |
| 123 | 128 |
}, |
| 124 |
- where => {row_id => $row_id}
|
|
| 129 |
+ where => {
|
|
| 130 |
+ 'project.id' => $base_project_id, |
|
| 131 |
+ 'issue.number' => $issue_number |
|
| 132 |
+ } |
|
| 125 | 133 |
); |
| 126 | 134 |
$self->redirect_to('current');
|
| 127 | 135 |
return; |
| ... | ... |
@@ -152,11 +160,15 @@ |
| 152 | 160 |
# Push |
| 153 | 161 |
app->manager->push($work_rep_info, $base_branch); |
| 154 | 162 |
|
| 163 |
+ # Close |
|
| 155 | 164 |
app->dbi->model('issue')->update(
|
| 156 | 165 |
{
|
| 157 | 166 |
open => 0 |
| 158 | 167 |
}, |
| 159 |
- where => {row_id => $row_id}
|
|
| 168 |
+ where => {
|
|
| 169 |
+ 'project.id' => $base_project_id, |
|
| 170 |
+ 'issue.number' => $issue_number |
|
| 171 |
+ } |
|
| 160 | 172 |
); |
| 161 | 173 |
|
| 162 | 174 |
$self->redirect_to("/$base_user_id/$base_project_id/tree/$base_branch");
|
| ... | ... |
@@ -189,7 +201,7 @@ |
| 189 | 201 |
{__MY__ => '*'},
|
| 190 | 202 |
{user => ['id']}
|
| 191 | 203 |
], |
| 192 |
- where => {issue => $row_id, number => 1}
|
|
| 204 |
+ where => {issue => $issue->{row_id}, number => 1}
|
|
| 193 | 205 |
)->one; |
| 194 | 206 |
|
| 195 | 207 |
# Check merge automatically |
| ... | ... |
@@ -229,7 +241,7 @@ |
| 229 | 241 |
my $ssh_rep_url = "ssh://$execute_user\@" . $url->host |
| 230 | 242 |
. ($ssh_port ? ":$ssh_port" : '') . "$ssh_rep_url_base/$user/$project.git"; |
| 231 | 243 |
|
| 232 |
- my $patch_url = url_for("/$base_user_id/$base_project_id/pull/$issue->{row_id}.patch")->to_abs;
|
|
| 244 |
+ my $patch_url = url_for("/$base_user_id/$base_project_id/pull/$issue->{number}.patch")->to_abs;
|
|
| 233 | 245 |
|
| 234 | 246 |
my $pre_content_base = "git checkout -b $target_user_id-$target_branch $base_branch"; |
| 235 | 247 |
my $pre_content_http = "git pull $http_rep_url $target_branch"; |
| ... | ... |
@@ -256,7 +268,7 @@ |
| 256 | 268 |
$pull_title = ucfirst $pull_title; |
| 257 | 269 |
%> |
| 258 | 270 |
|
| 259 |
- <%= $pull_title %> <span style="color:#767676;">#<%= $issue->{row_id} %></span>
|
|
| 271 |
+ <%= $pull_title %> <span style="color:#767676;">#<%= $issue->{number} %></span>
|
|
| 260 | 272 |
</div> |
| 261 | 273 |
<div> |
| 262 | 274 |
<div style="display:inline-block;color:white;margin-right:4px;"> |
| ... | ... |
@@ -78,12 +78,12 @@ |
| 78 | 78 |
%> |
| 79 | 79 |
<li> |
| 80 | 80 |
<div class="pulls-title"> |
| 81 |
- <a href="<%= "/$user_id/$project_id/pull/$issue->{row_id}" %>">
|
|
| 81 |
+ <a href="<%= "/$user_id/$project_id/pull/$issue->{number}" %>">
|
|
| 82 | 82 |
<b><%= $issue->{title} %></b>
|
| 83 | 83 |
</a> |
| 84 | 84 |
</div> |
| 85 | 85 |
<div class="pulls-description"> |
| 86 |
- #<%= $issue->{row_id} %> <%= $issue->{open} ? 'opened' : 'closed' %>
|
|
| 86 |
+ #<%= $issue->{number} %> <%= $issue->{open} ? 'opened' : 'closed' %>
|
|
| 87 | 87 |
<%= $open_time_age_string %> |
| 88 | 88 |
by <%= $issue->{'open_user.id'} %>
|
| 89 | 89 |
</div> |