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