fixed tags page paging bug a...
|
1 |
package Gitprep::Manager; |
2 |
use Mojo::Base -base; |
|
3 | ||
4 |
use Carp 'croak'; |
|
fixed bug that setting page ...
|
5 |
use Encode 'encode'; |
fix description file not cop...
|
6 |
use File::Copy qw/move copy/; |
fixed tags page paging bug a...
|
7 |
use File::Path qw/mkpath rmtree/; |
8 |
use File::Temp (); |
|
add key delete feature and u...
|
9 |
use Fcntl ':flock'; |
10 |
use Carp 'croak'; |
|
11 |
use File::Copy qw/copy move/; |
|
fix bug that in CGI reposito...
|
12 |
use File::Spec; |
13 |
use Gitprep::Util; |
|
fixed tags page paging bug a...
|
14 | |
15 |
has 'app'; |
|
add key delete feature and u...
|
16 |
has 'authorized_keys_file'; |
fixed tags page paging bug a...
|
17 | |
cleanup prepare merge
|
18 |
has '_tmp_branch' => '__gitprep_tmp_branch__'; |
19 | ||
20 |
sub prepare_merge { |
|
fix tests
|
21 |
my ($self, $work_rep_info, $base_rep_info, $base_branch, $target_rep_info, $target_branch) = @_; |
add lock system
|
22 |
|
cleanup prepare merge
|
23 |
# Fetch base repository |
fix tests
|
24 |
my $base_user_id = $base_rep_info->{user}; |
fix pull_request table bug
|
25 |
my @git_fetch_base_cmd = $self->app->git->cmd($work_rep_info, 'fetch', 'origin'); |
cleanup prepare merge
|
26 |
Gitprep::Util::run_command(@git_fetch_base_cmd) |
27 |
or Carp::croak "Can't execute git fetch: @git_fetch_base_cmd"; |
|
add lock system
|
28 |
|
cleanup prepare merge
|
29 |
# Fetch target repository |
fix tests
|
30 |
my @git_fetch_target_cmd = $self->app->git->cmd($work_rep_info, 'fetch', $target_rep_info->{git_dir}); |
cleanup prepare merge
|
31 |
Gitprep::Util::run_command(@git_fetch_target_cmd) |
32 |
or Carp::croak "Can't execute git fetch: @git_fetch_target_cmd"; |
|
cleanup merge and push logic
|
33 | |
34 |
# Ensure no diff |
|
35 |
my @git_reset_hard_cmd = $self->app->git->cmd( |
|
36 |
$work_rep_info, |
|
37 |
'reset', |
|
38 |
'--hard' |
|
39 |
); |
|
40 |
Gitprep::Util::run_command(@git_reset_hard_cmd) |
|
41 |
or Carp::croak "Can't execute git reset --hard: @git_reset_hard_cmd"; |
|
42 | ||
43 |
# Checkout first branch |
|
44 |
my $tmp_branch = $self->_tmp_branch; |
|
45 |
my $branch_names = $self->app->git->branch_names($work_rep_info); |
|
46 |
my $first_branch; |
|
47 |
for my $branch_name (@$branch_names) { |
|
48 |
if ($branch_name ne $tmp_branch) { |
|
49 |
$first_branch = $branch_name; |
|
50 |
last; |
|
51 |
} |
|
52 |
} |
|
53 |
my @git_checkout_first_branch = $self->app->git->cmd( |
|
54 |
$work_rep_info, |
|
55 |
'checkout', |
|
56 |
$first_branch |
|
57 |
); |
|
58 |
Gitprep::Util::run_command(@git_checkout_first_branch) |
|
59 |
or Carp::croak "Can't execute git checkout: @git_checkout_first_branch"; |
|
60 |
|
|
61 |
# Delete temparary branch if it eixsts |
|
62 |
if (grep { $_ eq $tmp_branch } @$branch_names) { |
|
63 |
my @git_branch_remove_cmd = $self->app->git->cmd( |
|
64 |
$work_rep_info, |
|
65 |
'branch', |
|
66 |
'-D', |
|
67 |
$tmp_branch |
|
68 |
); |
|
69 |
Gitprep::Util::run_command(@git_branch_remove_cmd) |
|
70 |
or Carp::croak "Can't execute git branch: @git_branch_remove_cmd"; |
|
71 |
} |
|
72 | ||
73 |
# Create temparary branch |
|
74 |
my @git_branch_cmd = $self->app->git->cmd( |
|
75 |
$work_rep_info, |
|
76 |
'branch', |
|
77 |
$tmp_branch |
|
78 |
); |
|
79 |
Gitprep::Util::run_command(@git_branch_cmd) |
|
80 |
or Carp::croak "Can't execute git branch: @git_branch_cmd"; |
|
cleanup prepare merge
|
81 |
|
82 |
# Checkout tmp branch and git reset --hard from my remote branch |
|
83 |
my @git_checkout_tmp_branch = $self->app->git->cmd( |
|
84 |
$work_rep_info, |
|
85 |
'checkout', |
|
cleanup merge and push logic
|
86 |
$tmp_branch |
cleanup prepare merge
|
87 |
); |
88 |
Gitprep::Util::run_command(@git_checkout_tmp_branch) |
|
89 |
or Carp::croak "Can't execute git checkout: @git_checkout_tmp_branch"; |
|
90 |
|
|
fix merge pull request bug
|
91 |
# git reset --hard |
fix tests
|
92 |
my $base_object_id = $self->app->git->ref_to_object_id($base_rep_info, $base_branch); |
fix merge pull request bug
|
93 |
my @git_reset_hard_base_cmd = $self->app->git->cmd( |
cleanup prepare merge
|
94 |
$work_rep_info, |
95 |
'reset', |
|
96 |
'--hard', |
|
fix tests
|
97 |
$base_object_id |
cleanup prepare merge
|
98 |
); |
fix merge pull request bug
|
99 |
Gitprep::Util::run_command(@git_reset_hard_base_cmd) |
100 |
or Carp::croak "Can't execute git reset --hard: @git_reset_hard_base_cmd"; |
|
add lock system
|
101 |
} |
102 | ||
cleanup merge and push logic
|
103 |
sub merge { |
add --no-ff option to merge ...
|
104 |
my ($self, $work_rep_info, $target_rep_info, $target_branch, $pull_request_number) = @_; |
cleanup merge and push logic
|
105 |
|
fix tests
|
106 |
my $object_id = $self->app->git->ref_to_object_id($target_rep_info, $target_branch); |
fix pull_request table bug
|
107 |
|
add --no-ff option to merge ...
|
108 |
my $message; |
fix tests
|
109 |
my $target_user_id = $target_rep_info->{user}; |
add --no-ff option to merge ...
|
110 |
if (defined $pull_request_number) { |
111 |
$message = "Merge pull request #$pull_request_number from $target_user_id/$target_branch"; |
|
112 |
} |
|
113 |
else { |
|
114 |
$message = "Merge from $target_user_id/$target_branch"; |
|
115 |
} |
|
116 |
|
|
117 |
# Merge |
|
cleanup merge and push logic
|
118 |
my @git_merge_cmd = $self->app->git->cmd( |
119 |
$work_rep_info, |
|
120 |
'merge', |
|
add --no-ff option to merge ...
|
121 |
'--no-ff', |
122 |
"--message=$message", |
|
fix pull_request table bug
|
123 |
$object_id |
cleanup merge and push logic
|
124 |
); |
add --no-ff option to merge ...
|
125 |
# |
cleanup merge and push logic
|
126 |
|
127 |
my $success = Gitprep::Util::run_command(@git_merge_cmd); |
|
128 |
|
|
129 |
return $success; |
|
130 |
} |
|
131 | ||
add patch feature
|
132 |
sub get_patch { |
133 |
my ($self, $work_rep_info, $target_rep_info, $target_branch) = @_; |
|
134 |
|
|
135 |
my $object_id = $self->app->git->ref_to_object_id($target_rep_info, $target_branch); |
|
136 |
|
|
137 |
# Merge |
|
138 |
my @git_format_patch_cmd = $self->app->git->cmd( |
|
139 |
$work_rep_info, |
|
140 |
'format-patch', |
|
141 |
'--stdout', |
|
142 |
"HEAD..$object_id" |
|
143 |
); |
|
144 |
|
|
145 |
open my $fh, '-|', @git_format_patch_cmd |
|
146 |
or croak "Execute git format-patch cmd:@git_format_patch_cmd"; |
|
147 |
|
|
148 |
my $patch = do { local $/; <$fh> }; |
|
149 |
|
|
150 |
return $patch; |
|
151 |
} |
|
152 | ||
cleanup merge and push logic
|
153 |
sub push { |
fix merge pull request bug
|
154 |
my ($self, $work_rep_info, $base_branch) = @_; |
cleanup merge and push logic
|
155 |
|
156 |
# Push |
|
fix merge pull request bug
|
157 |
my $tmp_branch = $self->_tmp_branch; |
158 |
my @git_push_cmd = $self->app->git->cmd( |
|
159 |
$work_rep_info, |
|
160 |
'push', |
|
161 |
'origin', |
|
162 |
"$tmp_branch:$base_branch" |
|
163 |
); |
|
cleanup merge and push logic
|
164 |
Gitprep::Util::run_command(@git_push_cmd) |
165 |
or Carp::croak "Can't execute git push: @git_push_cmd"; |
|
166 |
} |
|
167 | ||
cleanup prepare merge
|
168 |
sub lock_rep { |
169 |
my ($self, $rep_info) = @_; |
|
170 |
|
|
171 |
my $git_dir = $rep_info->{git_dir}; |
|
172 |
my $lock_file = "$git_dir/config"; |
|
173 |
|
|
174 |
open my $lock_fh, '<', $lock_file |
|
175 |
or croak "Can't open lock file $lock_file: $!"; |
|
176 |
|
|
177 |
flock $lock_fh, LOCK_EX |
|
178 |
or croak "Can't lock $lock_file"; |
|
179 |
|
|
180 |
return $lock_fh; |
|
181 |
} |
|
182 | ||
cleanup
|
183 |
sub create_work_rep { |
improve create working repos...
|
184 |
my ($self, $user, $project) = @_; |
185 |
|
|
cleanup create working direc...
|
186 |
# Remote repository |
187 |
my $rep_info = $self->app->rep_info($user, $project); |
|
188 |
my $rep_git_dir = $rep_info->{git_dir}; |
|
189 |
|
|
190 |
# Working repository |
|
191 |
my $work_rep_info = $self->app->work_rep_info($user, $project); |
|
192 |
my $work_tree = $work_rep_info->{work_tree}; |
|
193 |
|
|
improve create working repos...
|
194 |
# Create working repository if it don't exist |
cleanup create working direc...
|
195 |
unless (-e $work_tree) { |
196 | ||
improve create working repos...
|
197 |
# git clone |
cleanup create working direc...
|
198 |
my @git_clone_cmd = ($self->app->git->bin, 'clone', $rep_git_dir, $work_tree); |
improve create working repos...
|
199 |
Gitprep::Util::run_command(@git_clone_cmd) |
200 |
or croak "Can't git clone: @git_clone_cmd"; |
|
cleanup compare logic
|
201 |
|
improve create working repos...
|
202 |
# Set user name |
cleanup create working direc...
|
203 |
my @git_config_user_name = $self->app->git->cmd( |
204 |
$work_rep_info, |
|
improve create working repos...
|
205 |
'config', |
206 |
'user.name', |
|
207 |
$user |
|
208 |
); |
|
209 |
Gitprep::Util::run_command(@git_config_user_name) |
|
210 |
or croak "Can't execute git config: @git_config_user_name"; |
|
211 |
|
|
fix mail bug
|
212 |
# Set user email |
213 |
my $user_email = $self->app->dbi->model('user')->select('email', where => {id => $user})->value; |
|
214 |
my @git_config_user_email = $self->app->git->cmd( |
|
cleanup create working direc...
|
215 |
$work_rep_info, |
improve create working repos...
|
216 |
'config', |
217 |
'user.email', |
|
fix mail bug
|
218 |
"$user_email" |
improve create working repos...
|
219 |
); |
fix mail bug
|
220 |
Gitprep::Util::run_command(@git_config_user_email) |
221 |
or croak "Can't execute git config: @git_config_user_email"; |
|
improve create working repos...
|
222 |
} |
223 |
} |
|
224 | ||
added admin tests
|
225 |
sub admin_user { |
cleanup
|
226 |
my $self = shift; |
227 |
|
|
228 |
# Admin user |
|
229 |
my $admin_user = $self->app->dbi->model('user') |
|
added admin tests
|
230 |
->select(where => {admin => 1})->one; |
cleanup
|
231 |
|
232 |
return $admin_user; |
|
233 |
} |
|
234 | ||
fixed tags page paging bug a...
|
235 |
sub default_branch { |
fix project page
|
236 |
my ($self, $user_id, $project_id, $default_branch) = @_; |
237 |
|
|
238 |
my $user_row_id = $self->api->get_user_row_id($user_id); |
|
fixed tags page paging bug a...
|
239 |
|
added default branch change ...
|
240 |
# Set default branch |
241 |
my $dbi = $self->app->dbi; |
|
242 |
if (defined $default_branch) { |
|
243 |
$dbi->model('project')->update( |
|
244 |
{default_branch => $default_branch}, |
|
fix project page
|
245 |
where => {user => $user_row_id, id => $project_id} |
added default branch change ...
|
246 |
); |
247 |
} |
|
248 |
else { |
|
249 |
# Get default branch |
|
250 |
my $default_branch = $dbi->model('project') |
|
fix project page
|
251 |
->select('default_branch', where => {user => $user_row_id, id => $project_id}) |
added default branch change ...
|
252 |
->value; |
253 |
|
|
254 |
return $default_branch; |
|
255 |
} |
|
fixed tags page paging bug a...
|
256 |
} |
257 | ||
show deleted repository in u...
|
258 |
sub fork_project { |
cleanup
|
259 |
my ($self, $forked_user_id, $user_id, $project_id) = @_; |
fix fork
|
260 |
|
cleanup
|
261 |
my $user_row_id = $self->api->get_user_row_id($user_id); |
show deleted repository in u...
|
262 |
|
263 |
# Fork project |
|
264 |
my $dbi = $self->app->dbi; |
|
265 |
my $error; |
|
266 |
eval { |
|
267 |
$dbi->connector->txn(sub { |
|
268 |
|
|
269 |
# Original project id |
|
fix fork
|
270 |
my $project = $dbi->model('project')->select( |
cleanup
|
271 |
{__MY__ => ['row_id', 'private']}, |
remove table __ prefix
|
272 |
where => {'user.id' => $user_id, 'project.id' => $project_id} |
version up and add descripti...
|
273 |
)->one; |
274 |
|
|
show deleted repository in u...
|
275 |
# Create project |
276 |
eval { |
|
277 |
$self->_create_project( |
|
cleanup
|
278 |
$forked_user_id, |
fix fork
|
279 |
$project_id, |
show deleted repository in u...
|
280 |
{ |
fix fork
|
281 |
original_project => $project->{row_id}, |
282 |
private => $project->{private} |
|
show deleted repository in u...
|
283 |
} |
284 |
); |
|
285 |
}; |
|
286 |
croak $error = $@ if $@; |
|
287 |
|
|
288 |
# Create repository |
|
289 |
eval { |
|
cleanup
|
290 |
$self->_fork_rep($user_id, $project_id, $forked_user_id, $project_id); |
show deleted repository in u...
|
291 |
}; |
292 |
croak $error = $@ if $@; |
|
293 |
}); |
|
294 |
}; |
|
295 |
croak $error if $@; |
|
296 |
} |
|
297 | ||
cleanup
|
298 |
sub is_admin { |
fix project page
|
299 |
my ($self, $user_id) = @_; |
cleanup
|
300 |
|
301 |
# Check admin |
|
302 |
my $is_admin = $self->app->dbi->model('user') |
|
fix project page
|
303 |
->select('admin', where => {id => $user_id})->value; |
cleanup
|
304 |
|
305 |
return $is_admin; |
|
306 |
} |
|
307 | ||
add private checkbox
|
308 |
sub is_private_project { |
fix project page
|
309 |
my ($self, $user_id, $project_id) = @_; |
310 |
|
|
311 |
my $user_row_id = $self->api->get_user_row_id($user_id); |
|
add private checkbox
|
312 |
|
313 |
# Is private |
|
fix setting page
|
314 |
my $private = $self->app->dbi->model('project')->select( |
315 |
'private', where => {user => $user_row_id, id => $project_id} |
|
316 |
)->value; |
|
add private checkbox
|
317 |
|
318 |
return $private; |
|
319 |
} |
|
320 | ||
fix project page
|
321 |
sub api { shift->app->gitprep_api } |
322 | ||
323 | ||
fix network page
|
324 |
sub member_projects { |
fix project page
|
325 |
my ($self, $user_id, $project_id) = @_; |
326 |
|
|
fixed tags page paging bug a...
|
327 |
# DBI |
328 |
my $dbi = $self->app->dbi; |
|
329 |
|
|
cleanup
|
330 |
# project id |
331 |
my $project_row_id = $dbi->model('project')->select( |
|
332 |
'project.row_id', |
|
remove table __ prefix
|
333 |
where => {'user.id' => $user_id, 'project.id' => $project_id} |
cleanup
|
334 |
)->value; |
fixed tags page paging bug a...
|
335 |
|
336 |
# Members |
|
cleanup
|
337 |
my $member_projects = $dbi->model('project')->select( |
fix project page
|
338 |
[ |
fix network page
|
339 |
{__MY__ => ['id']}, |
remove table __ prefix
|
340 |
{user => ['id']} |
fix project page
|
341 |
], |
fix network page
|
342 |
where => { |
343 |
original_project => $project_row_id, |
|
344 |
}, |
|
remove table __ prefix
|
345 |
append => 'order by user.id, project.id' |
fixed tags page paging bug a...
|
346 |
)->all; |
347 | ||
cleanup
|
348 |
return $member_projects; |
fixed tags page paging bug a...
|
349 |
} |
350 | ||
351 |
sub create_project { |
|
fix fork
|
352 |
my ($self, $user_id, $project_id, $opts) = @_; |
fixed tags page paging bug a...
|
353 |
|
add private checkbox to new ...
|
354 |
my $params = {}; |
355 |
if ($opts->{private}) { |
|
356 |
$params->{private} = 1; |
|
357 |
} |
|
358 |
|
|
fixed tags page paging bug a...
|
359 |
# Create project |
fixed bug that setting page ...
|
360 |
my $dbi = $self->app->dbi; |
fixed tags page paging bug a...
|
361 |
my $error; |
362 |
eval { |
|
363 |
$dbi->connector->txn(sub { |
|
fix fork
|
364 |
eval { $self->_create_project($user_id, $project_id, $params) }; |
fixed tags page paging bug a...
|
365 |
croak $error = $@ if $@; |
fix fork
|
366 |
eval {$self->_create_rep($user_id, $project_id, $opts) }; |
fixed tags page paging bug a...
|
367 |
croak $error = $@ if $@; |
368 |
}); |
|
369 |
}; |
|
370 |
croak $error if $@; |
|
371 |
} |
|
372 | ||
373 |
sub create_user { |
|
374 |
my ($self, $user, $data) = @_; |
|
375 | ||
376 |
# Create user |
|
fixed bug that setting page ...
|
377 |
my $dbi = $self->app->dbi; |
fixed tags page paging bug a...
|
378 |
my $error; |
379 |
eval { |
|
380 |
$dbi->connector->txn(sub { |
|
381 |
eval { $self->_create_db_user($user, $data) }; |
|
382 |
croak $error = $@ if $@; |
|
383 |
eval {$self->_create_user_dir($user) }; |
|
384 |
croak $error = $@ if $@; |
|
385 |
}); |
|
386 |
}; |
|
387 |
croak $error if $@; |
|
388 |
} |
|
389 | ||
390 |
sub delete_project { |
|
391 |
my ($self, $user, $project) = @_; |
|
392 |
|
|
393 |
# Delete project |
|
fixed bug that setting page ...
|
394 |
my $dbi = $self->app->dbi; |
fixed tags page paging bug a...
|
395 |
my $error; |
396 |
eval { |
|
397 |
$dbi->connector->txn(sub { |
|
398 |
eval { $self->_delete_project($user, $project) }; |
|
399 |
croak $error = $@ if $@; |
|
400 |
eval {$self->_delete_rep($user, $project) }; |
|
401 |
croak $error = $@ if $@; |
|
402 |
}); |
|
403 |
}; |
|
404 |
croak $error if $@; |
|
405 |
} |
|
406 | ||
407 |
sub delete_user { |
|
408 |
my ($self, $user) = @_; |
|
409 |
|
|
410 |
# Delete user |
|
fixed bug that setting page ...
|
411 |
my $dbi = $self->app->dbi; |
fixed tags page paging bug a...
|
412 |
my $error; |
added delete user test
|
413 |
my $count; |
fixed tags page paging bug a...
|
414 |
eval { |
415 |
$dbi->connector->txn(sub { |
|
added delete user test
|
416 |
eval { $count = $self->_delete_db_user($user) }; |
fixed tags page paging bug a...
|
417 |
croak $error = $@ if $@; |
418 |
eval {$self->_delete_user_dir($user) }; |
|
419 |
croak $error = $@ if $@; |
|
420 |
}); |
|
421 |
}; |
|
422 |
croak $error if $@; |
|
added delete user test
|
423 |
|
424 |
return $count; |
|
fixed tags page paging bug a...
|
425 |
} |
426 | ||
427 |
sub original_project { |
|
fix project page
|
428 |
my ($self, $user_id, $project_id) = @_; |
429 |
|
|
430 |
my $user_row_id = $self->api->get_user_row_id($user_id); |
|
fixed tags page paging bug a...
|
431 |
|
cleanup delete original_proj...
|
432 |
# Original project id |
433 |
my $dbi = $self->app->dbi; |
|
fix project page
|
434 |
my $original_project_row_id = $dbi->model('project')->select( |
435 |
'original_project', |
|
436 |
where => {user => $user_row_id, id => $project_id} |
|
437 |
)->value; |
|
cleanup delete original_proj...
|
438 |
|
fix project page
|
439 |
croak "Original project don't eixsts." unless defined $original_project_row_id; |
cleanup delete original_proj...
|
440 |
|
fixed bug that setting page ...
|
441 |
# Original project |
cleanup delete original_proj...
|
442 |
my $original_project = $dbi->model('project')->select( |
fix project page
|
443 |
[ |
444 |
{__MY__ => '*'}, |
|
remove table __ prefix
|
445 |
{user => ['id']} |
fix project page
|
446 |
], |
cleanup delete original_proj...
|
447 |
where => { |
fix project page
|
448 |
'project.row_id' => $original_project_row_id |
cleanup delete original_proj...
|
449 |
} |
fix project page
|
450 |
)->one; |
cleanup delete original_proj...
|
451 |
|
fix project page
|
452 |
return unless defined $original_project; |
fixed tags page paging bug a...
|
453 |
|
454 |
return $original_project; |
|
455 |
} |
|
456 | ||
get target branch logic
|
457 |
sub child_project { |
458 |
my ($self, $user_id, $project_id, $child_user_id) = @_; |
|
459 |
|
|
460 |
my $project_row_id = $self->app->dbi->model('project')->select( |
|
remove table __ prefix
|
461 |
'project.row_id', where => {'user.id' => $user_id, 'project.id' => $project_id} |
get target branch logic
|
462 |
)->value; |
463 |
|
|
464 |
my $child_project = $self->app->dbi->model('project')->select( |
|
465 |
[ |
|
466 |
{__MY__ => '*'}, |
|
remove table __ prefix
|
467 |
{user => ['id']} |
get target branch logic
|
468 |
], |
469 |
where => { |
|
470 |
'project.original_project' => $project_row_id, |
|
remove table __ prefix
|
471 |
'user.id' => $child_user_id |
get target branch logic
|
472 |
} |
473 |
)->one; |
|
474 |
|
|
475 |
return $child_project; |
|
476 |
} |
|
477 | ||
show deleted repository in u...
|
478 |
sub projects { |
fix user page
|
479 |
my ($self, $user_id) = @_; |
480 |
|
|
481 |
my $user_row_id = $self->app->dbi->model('user')->select('row_id', where => {id => $user_id})->value; |
|
482 |
|
|
show deleted repository in u...
|
483 |
# Projects |
484 |
my $projects = $self->app->dbi->model('project')->select( |
|
fix user page
|
485 |
where => {user => $user_row_id}, |
486 |
append => 'order by id' |
|
show deleted repository in u...
|
487 |
)->all; |
488 |
|
|
489 |
return $projects; |
|
490 |
} |
|
491 | ||
cleanup
|
492 |
sub users { |
493 |
my $self = shift; |
|
fixed bug that setting page ...
|
494 |
|
495 |
# Users |
|
cleanup
|
496 |
my $users = $self->app->dbi->model('user')->select( |
497 |
where => [':admin{<>}',{admin => 1}], |
|
498 |
append => 'order by id' |
|
499 |
)->all; |
|
500 |
|
|
501 |
return $users; |
|
502 |
} |
|
503 | ||
fixed tags page paging bug a...
|
504 |
sub rename_project { |
show deleted repository in u...
|
505 |
my ($self, $user, $project, $to_project) = @_; |
fixed tags page paging bug a...
|
506 |
|
show deleted repository in u...
|
507 |
# Rename project |
revert encoding support
|
508 |
my $git = $self->app->git; |
fixed tags page paging bug a...
|
509 |
my $dbi = $self->app->dbi; |
simplify rename project
|
510 |
my $error; |
511 |
eval { |
|
fixed tags page paging bug a...
|
512 |
$dbi->connector->txn(sub { |
simplify rename project
|
513 |
eval { $self->_rename_project($user, $project, $to_project) }; |
514 |
croak $error = $@ if $@; |
|
515 |
eval { $self->_rename_rep($user, $project, $to_project) }; |
|
516 |
croak $error = $@ if $@; |
|
fixed tags page paging bug a...
|
517 |
}); |
simplify rename project
|
518 |
}; |
519 |
croak $error if $error; |
|
fixed tags page paging bug a...
|
520 |
} |
521 | ||
add key delete feature and u...
|
522 |
sub update_authorized_keys_file { |
523 |
my $self = shift; |
|
524 | ||
525 |
my $authorized_keys_file = $self->authorized_keys_file; |
|
526 |
if (defined $authorized_keys_file) { |
|
527 |
|
|
528 |
# Lock file |
|
fix update_authorized_keys_f...
|
529 |
my $lock_file = $self->app->home->rel_file('lock/authorized_keys'); |
add key delete feature and u...
|
530 |
open my $lock_fh, $lock_file |
531 |
or croak "Can't open lock file $lock_file"; |
|
532 |
flock $lock_fh, LOCK_EX |
|
533 |
or croak "Can't lock $lock_file"; |
|
534 |
|
|
535 |
# Create authorized_keys_file |
|
536 |
unless (-f $authorized_keys_file) { |
|
537 |
open my $fh, '>', $authorized_keys_file |
|
fix gitprep-shell
|
538 |
or croak "Can't create authorized_keys file: $authorized_keys_file"; |
539 |
chmod 0600, $authorized_keys_file |
|
540 |
or croak "Can't chmod authorized_keys file: $authorized_keys_file"; |
|
add key delete feature and u...
|
541 |
} |
542 |
|
|
543 |
# Parse file |
|
forbidden public key which i...
|
544 |
my $result = $self->parse_authorized_keys_file($authorized_keys_file); |
fix update_authorized_keys_f...
|
545 |
my $before_part = $result->{before_part}; |
546 |
my $gitprep_part = $result->{gitprep_part}; |
|
547 |
my $after_part = $result->{after_part}; |
|
548 |
my $start_symbol = $result->{start_symbol}; |
|
549 |
my $end_symbol = $result->{end_symbol}; |
|
add key delete feature and u...
|
550 |
|
551 |
# Backup at first time |
|
552 |
if ($gitprep_part eq '') { |
|
553 |
# Backup original file |
|
554 |
my $to = "$authorized_keys_file.gitprep.original"; |
|
555 |
unless (-f $to) { |
|
556 |
copy $authorized_keys_file, $to |
|
557 |
or croak "Can't copy $authorized_keys_file to $to"; |
|
558 |
} |
|
559 |
} |
|
fix update_authorized_keys_f...
|
560 | |
add key delete feature and u...
|
561 |
# Create public keys |
fix ssh public key bug
|
562 |
my $ssh_public_keys = $self->app->dbi->model('ssh_public_key')->select( |
563 |
[ |
|
564 |
{__MY__ => '*'}, |
|
remove table __ prefix
|
565 |
{user => ['id']} |
fix ssh public key bug
|
566 |
] |
567 |
)->all; |
|
add key delete feature and u...
|
568 |
my $ssh_public_keys_str = ''; |
569 |
for my $key (@$ssh_public_keys) { |
|
fix permission bug
|
570 |
my $ssh_public_key_str = 'command="' . $self->app->home->rel_file('script/gitprep-shell') |
remove table __ prefix
|
571 |
. " $key->{'user.id'}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty $key->{key}"; |
572 |
$ssh_public_keys_str .= "$ssh_public_key_str $key->{'user.id'}\n\n"; |
|
add key delete feature and u...
|
573 |
} |
574 |
|
|
575 |
# Output tmp file |
|
fix gitprep-shell
|
576 |
my $output = "$before_part$start_symbol\n\n$ssh_public_keys_str$end_symbol$after_part"; |
add key delete feature and u...
|
577 |
my $output_file = "$authorized_keys_file.gitprep.tmp"; |
578 |
open my $out_fh, '>', $output_file |
|
579 |
or croak "Can't create authorized_keys tmp file $output_file"; |
|
580 |
print $out_fh $output; |
|
581 |
close $out_fh |
|
582 |
or croak "Can't close authorized_keys tmp file $output_file"; |
|
fix update_authorized_keys_f...
|
583 | |
add key delete feature and u...
|
584 |
# Replace |
fix permission bug
|
585 |
chmod 0600, $output_file |
586 |
or croak "Can't chmod authorized_keys tmp file: $output_file"; |
|
add key delete feature and u...
|
587 |
move $output_file, $authorized_keys_file |
588 |
or croak "Can't replace $authorized_keys_file by $output_file"; |
|
589 |
} |
|
590 |
else { |
|
591 |
croak qq/authorized_keys file "$authorized_keys_file" is not found./; |
|
592 |
} |
|
593 |
} |
|
594 | ||
forbidden public key which i...
|
595 |
sub parse_authorized_keys_file { |
fix update_authorized_keys_f...
|
596 |
my ($self, $file) = @_; |
add key delete feature and u...
|
597 |
|
598 |
my $start_symbol = "# gitprep start"; |
|
599 |
my $end_symbol = "# gitprep end"; |
|
600 |
|
|
601 |
# Parse |
|
602 |
open my $fh, '<', $file |
|
fix update_authorized_keys_f...
|
603 |
or croak "Can't open authorized_key file $file"; |
add key delete feature and u...
|
604 |
my $start_symbol_count = 0; |
605 |
my $end_symbol_count = 0; |
|
606 |
my $before_part = ''; |
|
607 |
my $gitprep_part = ''; |
|
608 |
my $after_part = ''; |
|
609 |
my $error_prefix = "authorized_keys file $file format error:"; |
|
610 |
while (my $line = <$fh>) { |
|
611 |
if ($line =~ /^$start_symbol/) { |
|
612 |
if ($start_symbol_count > 0) { |
|
613 |
croak qq/$error_prefix "$start_symbol" is found more than one/; |
|
614 |
} |
|
615 |
else { |
|
616 |
if ($end_symbol_count > 0) { |
|
617 |
croak qq/$error_prefix "$end_symbol" is found before "$start_symbol"/; |
|
618 |
} |
|
619 |
else { |
|
620 |
$start_symbol_count++; |
|
621 |
} |
|
622 |
} |
|
623 |
} |
|
624 |
elsif ($line =~ /^$end_symbol/) { |
|
fix ssh key authentication b...
|
625 |
if ($end_symbol_count > 0) { |
add key delete feature and u...
|
626 |
croak qq/$error_prefix "$end_symbol" is found more than one/; |
627 |
} |
|
628 |
else { |
|
fix gitprep-shell
|
629 |
$end_symbol_count++; |
add key delete feature and u...
|
630 |
} |
631 |
} |
|
632 |
elsif ($start_symbol_count == 0 && $end_symbol_count == 0) { |
|
633 |
$before_part .= $line; |
|
634 |
} |
|
635 |
elsif ($start_symbol_count == 1 && $end_symbol_count == 0) { |
|
636 |
$gitprep_part .= $line; |
|
637 |
} |
|
638 |
elsif ($start_symbol_count == 1 && $end_symbol_count == 1) { |
|
639 |
$after_part .= $line; |
|
640 |
} |
|
641 |
} |
|
fix update_authorized_keys_f...
|
642 |
|
643 |
my $result = { |
|
644 |
start_symbol => $start_symbol, |
|
645 |
end_symbol => $end_symbol, |
|
646 |
before_part => $before_part, |
|
647 |
gitprep_part => $gitprep_part, |
|
648 |
after_part => $after_part |
|
649 |
}; |
|
650 |
|
|
651 |
return $result; |
|
add key delete feature and u...
|
652 |
} |
653 | ||
fixed tags page paging bug a...
|
654 |
sub _create_project { |
fix fork
|
655 |
my ($self, $user_id, $project_id, $params) = @_; |
656 |
|
|
657 |
my $user_row_id = $self->api->get_user_row_id($user_id); |
|
fixed tags page paging bug a...
|
658 |
$params ||= {}; |
fix fork
|
659 |
$params->{user} = $user_row_id; |
660 |
$params->{id} = $project_id; |
|
fixed tags page paging bug a...
|
661 |
|
662 |
# Create project |
|
cleanup
|
663 |
my $dbi = $self->app->dbi; |
fixed tags page paging bug a...
|
664 |
$dbi->connector->txn(sub { |
fix fork
|
665 |
$dbi->model('project')->insert($params); |
fixed tags page paging bug a...
|
666 |
}); |
667 |
} |
|
668 | ||
669 |
sub _create_rep { |
|
670 |
my ($self, $user, $project, $opts) = @_; |
|
671 |
|
|
672 |
# Create repository directory |
|
revert encoding support
|
673 |
my $git = $self->app->git; |
remove rep_path
|
674 |
|
675 |
my $rep_info = $self->app->rep_info($user, $project); |
|
676 |
my $rep_git_dir = $rep_info->{git_dir}; |
|
677 |
|
|
678 |
mkdir $rep_git_dir |
|
679 |
or croak "Can't create directory $rep_git_dir: $!"; |
|
fix bug that in CGI reposito...
|
680 |
|
fixed tags page paging bug a...
|
681 |
eval { |
682 |
# Git init |
|
683 |
{ |
|
remove cmd_dir
|
684 |
my @git_init_cmd = $git->cmd($rep_info, 'init', '--bare'); |
fix bug that in CGI reposito...
|
685 |
Gitprep::Util::run_command(@git_init_cmd) |
fix git 2.0 create repositor...
|
686 |
or croak "Can't execute git init --bare:@git_init_cmd"; |
fixed tags page paging bug a...
|
687 |
} |
688 |
|
|
689 |
# Add git-daemon-export-ok |
|
690 |
{ |
|
remove rep_path
|
691 |
my $file = "$rep_git_dir/git-daemon-export-ok"; |
fixed tags page paging bug a...
|
692 |
open my $fh, '>', $file |
693 |
or croak "Can't create git-daemon-export-ok: $!" |
|
694 |
} |
|
695 |
|
|
696 |
# HTTP support |
|
remove cmd_dir
|
697 |
my @git_update_server_info_cmd = $git->cmd( |
698 |
$rep_info, |
|
fixed tags page paging bug a...
|
699 |
'--bare', |
700 |
'update-server-info' |
|
701 |
); |
|
fix bug that in CGI reposito...
|
702 |
Gitprep::Util::run_command(@git_update_server_info_cmd) |
fix git 2.0 create repositor...
|
703 |
or croak "Can't execute git --bare update-server-info"; |
remove rep_path
|
704 |
move("$rep_git_dir/hooks/post-update.sample", "$rep_git_dir/hooks/post-update") |
fixed tags page paging bug a...
|
705 |
or croak "Can't move post-update"; |
706 |
|
|
707 |
# Description |
|
version up and add descripti...
|
708 |
my $description = $opts->{description}; |
709 |
$description = '' unless defined $description; |
|
fixed tags page paging bug a...
|
710 |
{ |
remove rep_path
|
711 |
my $file = "$rep_git_dir/description"; |
fixed tags page paging bug a...
|
712 |
open my $fh, '>', $file |
713 |
or croak "Can't open $file: $!"; |
|
714 |
print $fh encode('UTF-8', $description) |
|
715 |
or croak "Can't write $file: $!"; |
|
716 |
close $fh; |
|
717 |
} |
|
718 |
|
|
719 |
# Add README and commit |
|
720 |
if ($opts->{readme}) { |
|
721 |
# Create working directory |
|
use own tmp directory to cre...
|
722 |
my $home_tmp_dir = $self->app->home->rel_file('tmp'); |
723 |
|
|
remove cmd_work_dir
|
724 |
# Temp directory |
use own tmp directory to cre...
|
725 |
my $temp_dir = File::Temp->newdir(DIR => $home_tmp_dir); |
remove cmd_work_dir
|
726 |
|
727 |
# Working repository |
|
728 |
my $work_rep_work_tree = "$temp_dir/work"; |
|
729 |
my $work_rep_git_dir = "$work_rep_work_tree/.git"; |
|
730 |
my $work_rep_info = { |
|
731 |
work_tree => $work_rep_work_tree, |
|
732 |
git_dir => $work_rep_git_dir |
|
733 |
}; |
|
734 |
|
|
735 |
mkdir $work_rep_work_tree |
|
736 |
or croak "Can't create directory $work_rep_work_tree: $!"; |
|
use own tmp directory to cre...
|
737 |
|
fixed tags page paging bug a...
|
738 |
# Git init |
remove cmd_work_dir
|
739 |
my @git_init_cmd = $git->cmd($work_rep_info, 'init', '-q'); |
fix bug that in CGI reposito...
|
740 |
Gitprep::Util::run_command(@git_init_cmd) |
fix git 2.0 create repositor...
|
741 |
or croak "Can't execute git init: @git_init_cmd"; |
fixed tags page paging bug a...
|
742 |
|
743 |
# Add README |
|
remove cmd_work_dir
|
744 |
my $file = "$work_rep_work_tree/README.md"; |
default readme file is chang...
|
745 |
open my $readme_fh, '>', $file |
fixed tags page paging bug a...
|
746 |
or croak "Can't create $file: $!"; |
version up and add descripti...
|
747 |
print $readme_fh "# $project\n"; |
748 |
print $readme_fh "\n" . encode('UTF-8', $description) . "\n"; |
|
default readme file is chang...
|
749 |
close $readme_fh; |
750 |
|
|
remove cmd_work_dir
|
751 |
my @git_add_cmd = $git->cmd( |
752 |
$work_rep_info, |
|
fixed tags page paging bug a...
|
753 |
'add', |
default readme file is chang...
|
754 |
'README.md' |
fixed tags page paging bug a...
|
755 |
); |
improve create working repos...
|
756 |
|
fix bug that in CGI reposito...
|
757 |
Gitprep::Util::run_command(@git_add_cmd) |
fix git 2.0 create repositor...
|
758 |
or croak "Can't execute git add: @git_add_cmd"; |
fixed tags page paging bug a...
|
759 |
|
fix bug that repository with...
|
760 |
# Set user name |
remove cmd_work_dir
|
761 |
my @git_config_user_name = $git->cmd( |
762 |
$work_rep_info, |
|
fix bug that repository with...
|
763 |
'config', |
764 |
'user.name', |
|
765 |
$user |
|
766 |
); |
|
767 |
Gitprep::Util::run_command(@git_config_user_name) |
|
768 |
or croak "Can't execute git config: @git_config_user_name"; |
|
769 |
|
|
fix mail bug
|
770 |
# Set user email |
771 |
my $user_email = $self->app->dbi->model('user')->select('email', where => {id => $user})->value; |
|
772 |
my @git_config_user_email = $git->cmd( |
|
remove cmd_work_dir
|
773 |
$work_rep_info, |
fix bug that repository with...
|
774 |
'config', |
775 |
'user.email', |
|
fix mail bug
|
776 |
"$user_email" |
fix bug that repository with...
|
777 |
); |
fix mail bug
|
778 |
Gitprep::Util::run_command(@git_config_user_email) |
779 |
or croak "Can't execute git config: @git_config_user_email"; |
|
fix bug that repository with...
|
780 |
|
fixed tags page paging bug a...
|
781 |
# Commit |
remove cmd_work_dir
|
782 |
my @git_commit_cmd = $git->cmd( |
783 |
$work_rep_info, |
|
fixed tags page paging bug a...
|
784 |
'commit', |
785 |
'-q', |
|
786 |
'-m', |
|
787 |
'first commit' |
|
788 |
); |
|
fix bug that in CGI reposito...
|
789 |
Gitprep::Util::run_command(@git_commit_cmd) |
fix git 2.0 create repositor...
|
790 |
or croak "Can't execute git commit: @git_commit_cmd"; |
fixed tags page paging bug a...
|
791 |
|
792 |
# Push |
|
793 |
{ |
|
remove cmd_work_dir
|
794 |
my @git_push_cmd = $git->cmd( |
795 |
$work_rep_info, |
|
fixed tags page paging bug a...
|
796 |
'push', |
797 |
'-q', |
|
remove rep_path
|
798 |
$rep_git_dir, |
fixed tags page paging bug a...
|
799 |
'master' |
800 |
); |
|
801 |
# (This is bad, but --quiet option can't supress in old git) |
|
fix bug that in CGI reposito...
|
802 |
Gitprep::Util::run_command(@git_push_cmd) |
fix git 2.0 create repositor...
|
803 |
or croak "Can't execute git push: @git_push_cmd"; |
fixed tags page paging bug a...
|
804 |
} |
805 |
} |
|
806 |
}; |
|
improve faq of pushing lerge...
|
807 |
if (my $e = $@) { |
remove rep_path
|
808 |
rmtree $rep_git_dir; |
improve faq of pushing lerge...
|
809 |
croak $e; |
fixed tags page paging bug a...
|
810 |
} |
811 |
} |
|
812 | ||
show deleted repository in u...
|
813 |
sub _create_db_user { |
fix project page
|
814 |
my ($self, $user_id, $data) = @_; |
815 |
|
|
816 |
$data->{id} = $user_id; |
|
show deleted repository in u...
|
817 |
|
818 |
# Create database user |
|
fix project page
|
819 |
$self->app->dbi->model('user')->insert($data); |
show deleted repository in u...
|
820 |
} |
821 | ||
822 |
sub _create_user_dir { |
|
823 |
my ($self, $user) = @_; |
|
824 |
|
|
825 |
# Create user directory |
|
cleanup ->rep_home
|
826 |
my $rep_home = $self->app->rep_home; |
show deleted repository in u...
|
827 |
my $user_dir = "$rep_home/$user"; |
828 |
mkpath $user_dir; |
|
829 |
} |
|
830 | ||
831 |
sub _delete_db_user { |
|
fix project page
|
832 |
my ($self, $user_id) = @_; |
show deleted repository in u...
|
833 |
|
834 |
# Delete database user |
|
fix project page
|
835 |
my $count = $self->app->dbi->model('user')->delete(where => {id => $user_id}); |
added delete user test
|
836 |
|
837 |
return $count; |
|
show deleted repository in u...
|
838 |
} |
839 | ||
840 |
sub _delete_user_dir { |
|
841 |
my ($self, $user) = @_; |
|
842 |
|
|
843 |
# Delete user directory |
|
cleanup ->rep_home
|
844 |
my $rep_home = $self->app->rep_home; |
show deleted repository in u...
|
845 |
my $user_dir = "$rep_home/$user"; |
846 |
rmtree $user_dir; |
|
847 |
} |
|
848 | ||
fixed tags page paging bug a...
|
849 |
sub _delete_project { |
fix project page
|
850 |
my ($self, $user_id, $project_id) = @_; |
851 |
|
|
852 |
my $user_row_id = $self->api->get_user_row_id($user_id); |
|
fixed tags page paging bug a...
|
853 |
|
cleanup
|
854 |
# Delete project |
fixed tags page paging bug a...
|
855 |
my $dbi = $self->app->dbi; |
fix project page
|
856 |
$dbi->model('project')->delete(where => {user => $user_row_id, id => $project_id}); |
fixed tags page paging bug a...
|
857 |
} |
858 | ||
859 |
sub _delete_rep { |
|
860 |
my ($self, $user, $project) = @_; |
|
861 | ||
cleanup
|
862 |
# Delete repository |
cleanup ->rep_home
|
863 |
my $rep_home = $self->app->rep_home; |
add missing 'o'
|
864 |
croak "Can't remove repository. repository home is empty" |
fixed tags page paging bug a...
|
865 |
if !defined $rep_home || $rep_home eq ''; |
866 |
my $rep = "$rep_home/$user/$project.git"; |
|
867 |
rmtree $rep; |
|
868 |
croak "Can't remove repository. repository is rest" |
|
869 |
if -e $rep; |
|
870 |
} |
|
871 | ||
fixed bug that setting page ...
|
872 |
sub exists_project { |
fix project page
|
873 |
my ($self, $user_id, $project_id) = @_; |
874 |
|
|
875 |
my $user_row_id = $self->api->get_user_row_id($user_id); |
|
cleanup
|
876 |
|
877 |
# Exists project |
|
fixed tags page paging bug a...
|
878 |
my $dbi = $self->app->dbi; |
fix project page
|
879 |
my $row = $dbi->model('project')->select(where => {user => $user_row_id, id => $project_id})->one; |
fixed tags page paging bug a...
|
880 |
|
881 |
return $row ? 1 : 0; |
|
882 |
} |
|
883 | ||
add rename project and suppr...
|
884 |
sub exists_user { |
fix project page
|
885 |
my ($self, $user_id) = @_; |
add rename project and suppr...
|
886 |
|
887 |
# Exists project |
|
fix project page
|
888 |
my $row = $self->app->dbi->model('user')->select(where => {id => $user_id})->one; |
add rename project and suppr...
|
889 |
|
890 |
return $row ? 1 : 0; |
|
891 |
} |
|
892 | ||
fixed tags page paging bug a...
|
893 |
sub _exists_rep { |
894 |
my ($self, $user, $project) = @_; |
|
895 |
|
|
cleanup
|
896 |
# Exists repository |
remove rep_path
|
897 |
my $rep_info = $self->app->rep_info($user, $project); |
898 |
my $rep_git_dir = $rep_info->{git_dir}; |
|
fixed tags page paging bug a...
|
899 |
|
remove rep_path
|
900 |
return -e $rep_git_dir; |
fixed tags page paging bug a...
|
901 |
} |
902 | ||
show deleted repository in u...
|
903 |
sub _fork_rep { |
fix fork
|
904 |
my ($self, $user_id, $project_id, $to_user_id, $to_project_id) = @_; |
show deleted repository in u...
|
905 |
|
cleanup
|
906 |
# Fork repository |
revert encoding support
|
907 |
my $git = $self->app->git; |
remove rep_path
|
908 |
|
fix fork
|
909 |
my $rep_info = $self->app->rep_info($user_id, $project_id); |
remove rep_path
|
910 |
my $rep_git_dir = $rep_info->{git_dir}; |
911 |
|
|
fix fork
|
912 |
my $to_rep_info = $self->app->rep_info($to_user_id, $to_project_id); |
remove rep_path
|
913 |
my $to_rep_git_dir = $to_rep_info->{git_dir}; |
914 | ||
show deleted repository in u...
|
915 |
my @cmd = ( |
916 |
$git->bin, |
|
917 |
'clone', |
|
918 |
'-q', |
|
919 |
'--bare', |
|
remove rep_path
|
920 |
$rep_git_dir, |
921 |
$to_rep_git_dir |
|
show deleted repository in u...
|
922 |
); |
fix bug that in CGI reposito...
|
923 |
Gitprep::Util::run_command(@cmd) |
fix description file not cop...
|
924 |
or croak "Can't fork repository(_fork_rep): @cmd"; |
925 |
|
|
926 |
# Copy description |
|
remove rep_path
|
927 |
copy "$rep_git_dir/description", "$to_rep_git_dir/description" |
fix description file not cop...
|
928 |
or croak "Can't copy description file(_fork_rep)"; |
show deleted repository in u...
|
929 |
} |
930 | ||
fixed tags page paging bug a...
|
931 |
sub _rename_project { |
fix project page
|
932 |
my ($self, $user_id, $project_id, $renamed_project_id) = @_; |
933 |
|
|
934 |
my $user_row_id = $self->api->get_user_row_id($user_id); |
|
fixed tags page paging bug a...
|
935 |
|
cleanup
|
936 |
# Check arguments |
add rename project and suppr...
|
937 |
croak "Invalid parameters(_rename_project)" |
fix project page
|
938 |
unless defined $user_id && defined $project_id && defined $renamed_project_id; |
fixed tags page paging bug a...
|
939 |
|
940 |
# Rename project |
|
cleanup
|
941 |
my $dbi = $self->app->dbi; |
fixed tags page paging bug a...
|
942 |
$dbi->model('project')->update( |
fix project page
|
943 |
{id => $renamed_project_id}, |
944 |
where => {user => $user_row_id, id => $project_id} |
|
fixed tags page paging bug a...
|
945 |
); |
946 |
} |
|
947 | ||
948 |
sub _rename_rep { |
|
949 |
my ($self, $user, $project, $renamed_project) = @_; |
|
950 |
|
|
cleanup
|
951 |
# Check arguments |
fixed tags page paging bug a...
|
952 |
croak "Invalid user name or project" |
953 |
unless defined $user && defined $project && defined $renamed_project; |
|
cleanup
|
954 | |
955 |
# Rename repository |
|
remove rep_path
|
956 |
my $rep_info = $self->app->rep_info($user, $project); |
957 |
my $rep_git_dir = $rep_info->{git_dir}; |
|
958 |
|
|
959 |
my $renamed_rep_info = $self->app->rep_info($user, $renamed_project); |
|
960 |
my $renamed_rep_git_dir = $renamed_rep_info->{git_dir}; |
|
961 | ||
962 |
move($rep_git_dir, $renamed_rep_git_dir) |
|
963 |
or croak "Can't move $rep_git_dir to $renamed_rep_git_dir: $!"; |
|
fixed tags page paging bug a...
|
964 |
} |
965 | ||
966 |
1; |