gitprep / lib / Gitprep / Manager.pm /
Newer Older
837 lines | 21.793kb
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
1
package Gitprep::Manager;
2
use Mojo::Base -base;
3

            
4
use Carp 'croak';
fixed bug that setting page ...
Yuki Kimoto authored on 2013-05-15
5
use Encode 'encode';
fix description file not cop...
Yuki Kimoto authored on 2013-05-25
6
use File::Copy qw/move copy/;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
7
use File::Path qw/mkpath rmtree/;
8
use File::Temp ();
add key delete feature and u...
gitprep authored on 2014-05-19
9
use Fcntl ':flock';
10
use Carp 'croak';
11
use File::Copy qw/copy move/;
fix bug that in CGI reposito...
Yuki Kimoto authored on 2015-11-05
12
use File::Spec;
13
use Gitprep::Util;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
14

            
15
has 'app';
add key delete feature and u...
gitprep authored on 2014-05-19
16
has 'authorized_keys_file';
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
17

            
add lock system
Yuki Kimoto authored on 2016-04-18
18
sub lock_rep {
19
  my ($self, $rep_info) = @_;
20
  
21
  my $git_dir = $rep_info->{git_dir};
22
  my $lock_file = "$git_dir/config";
23
  
24
  open my $lock_fh, '<', $lock_file
25
    or croak "Can't open lock file $lock_file: $!";
26
    
27
  flock $lock_fh, LOCK_EX
28
    or croak "Can't lock $lock_file";
29
  
30
  return $lock_fh;
31
}
32

            
add automatical merge checki...
Yuki Kimoto authored on 2016-04-18
33
sub check_merge_automatical {
34
  my ($self, $rep_info, $branch1, $branch2) = @_;
35
  
36
  # Create patch
37
  my @git_format_patch_cmd = $self->app->git->cmd(
38
    $rep_info,
39
    'format-patch',
40
    "$branch1..$branch2",
41
    "--stdout"
42
  );
43
  open my $git_format_patch_fh, '-|', @git_format_patch_cmd
44
    or Carp::croak "Can't execute git format-patch: @git_format_patch_cmd";
45
  my $patch_str = do { local $/; <$git_format_patch_fh> };
46
  
47
  # Write patch to file
48
  my $tmp_dir = File::Temp->newdir(DIR => $self->app->home->rel_file('/tmp'));
49
  my $patch_file = "$tmp_dir/test.patch";
50
  open my $patch_fh, '>', $patch_file
51
    or Carp::croak "Can't open patch file $patch_file: $!";
52
  print $patch_fh $patch_str;
53
  close $patch_fh;
54
  
55
  # Check if this patch can be applied
56
  my @git_apply_cmd = $self->app->git->cmd(
57
    $rep_info,
58
    'apply',
59
    $patch_file,
60
    '--check'
61
  );
62
  my $automatical = Gitprep::Util::run_command(@git_apply_cmd);
63
  
64
  return $automatical;
65
}
66

            
cleanup
Yuki Kimoto authored on 2016-04-16
67
sub create_work_rep {
improve create working repos...
Yuki Kimoto authored on 2016-04-15
68
  my ($self, $user, $project) = @_;
69
  
cleanup create working direc...
Yuki Kimoto authored on 2016-04-16
70
  # Remote repository
71
  my $rep_info = $self->app->rep_info($user, $project);
72
  my $rep_git_dir = $rep_info->{git_dir};
73
  
74
  # Working repository
75
  my $work_rep_info = $self->app->work_rep_info($user, $project);
76
  my $work_tree = $work_rep_info->{work_tree};
77
  
improve create working repos...
Yuki Kimoto authored on 2016-04-15
78
  # Create working repository if it don't exist
cleanup create working direc...
Yuki Kimoto authored on 2016-04-16
79
  unless (-e $work_tree) {
80

            
improve create working repos...
Yuki Kimoto authored on 2016-04-15
81
    # git clone
cleanup create working direc...
Yuki Kimoto authored on 2016-04-16
82
    my @git_clone_cmd = ($self->app->git->bin, 'clone', $rep_git_dir, $work_tree);
improve create working repos...
Yuki Kimoto authored on 2016-04-15
83
    Gitprep::Util::run_command(@git_clone_cmd)
84
      or croak "Can't git clone: @git_clone_cmd";
cleanup compare logic
Yuki Kimoto authored on 2016-04-18
85
    
86
    # Create temparary branch
87
    my $gitprep_tmp_branch_name = '__gitprep_tmp_branch__';
88
    my @git_branch_cmd = $self->app->git->cmd(
89
      $work_rep_info,
90
      'branch',
91
      $gitprep_tmp_branch_name,
92
    );
93
    Gitprep::Util::run_command(@git_branch_cmd)
94
      or Carp::croak "Can't execute git branch: @git_branch_cmd";
improve create working repos...
Yuki Kimoto authored on 2016-04-15
95

            
96
    # Set user name
cleanup create working direc...
Yuki Kimoto authored on 2016-04-16
97
    my @git_config_user_name = $self->app->git->cmd(
98
      $work_rep_info,
improve create working repos...
Yuki Kimoto authored on 2016-04-15
99
      'config',
100
      'user.name',
101
      $user
102
    );
103
    Gitprep::Util::run_command(@git_config_user_name)
104
      or croak "Can't execute git config: @git_config_user_name";
105
    
fix mail bug
Yuki Kimoto authored on 2016-04-21
106
    # Set user email
107
    my $user_email = $self->app->dbi->model('user')->select('email', where => {id => $user})->value;
108
    my @git_config_user_email = $self->app->git->cmd(
cleanup create working direc...
Yuki Kimoto authored on 2016-04-16
109
      $work_rep_info,
improve create working repos...
Yuki Kimoto authored on 2016-04-15
110
      'config',
111
      'user.email',
fix mail bug
Yuki Kimoto authored on 2016-04-21
112
      "$user_email"
improve create working repos...
Yuki Kimoto authored on 2016-04-15
113
    );
fix mail bug
Yuki Kimoto authored on 2016-04-21
114
    Gitprep::Util::run_command(@git_config_user_email)
115
      or croak "Can't execute git config: @git_config_user_email";
improve create working repos...
Yuki Kimoto authored on 2016-04-15
116
  }
117
}
118

            
added admin tests
Yuki Kimoto authored on 2013-05-16
119
sub admin_user {
cleanup
Yuki Kimoto authored on 2013-05-13
120
  my $self = shift;
121
  
122
  # Admin user
123
  my $admin_user = $self->app->dbi->model('user')
added admin tests
Yuki Kimoto authored on 2013-05-16
124
    ->select(where => {admin => 1})->one;
cleanup
Yuki Kimoto authored on 2013-05-13
125
  
126
  return $admin_user;
127
}
128

            
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
129
sub default_branch {
fix project page
Yuki Kimoto authored on 2016-04-21
130
  my ($self, $user_id, $project_id, $default_branch) = @_;
131
  
132
  my $user_row_id = $self->api->get_user_row_id($user_id);
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
133
  
added default branch change ...
Yuki Kimoto authored on 2013-05-22
134
  # Set default branch
135
  my $dbi = $self->app->dbi;
136
  if (defined $default_branch) {
137
    $dbi->model('project')->update(
138
      {default_branch => $default_branch},
fix project page
Yuki Kimoto authored on 2016-04-21
139
      where => {user => $user_row_id, id => $project_id}
added default branch change ...
Yuki Kimoto authored on 2013-05-22
140
    );
141
  }
142
  else {
143
    # Get default branch
144
    my $default_branch = $dbi->model('project')
fix project page
Yuki Kimoto authored on 2016-04-21
145
      ->select('default_branch', where => {user => $user_row_id, id => $project_id})
added default branch change ...
Yuki Kimoto authored on 2013-05-22
146
      ->value;
147
    
148
    return $default_branch;
149
  }
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
150
}
151

            
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
152
sub fork_project {
fix fork
Yuki Kimoto authored on 2016-04-21
153
  my ($self, $user_id, $original_user_id, $project_id) = @_;
154
  
155
  my $original_user_row_id = $self->api->get_user_row_id($original_user_id);
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
156
  
157
  # Fork project
158
  my $dbi = $self->app->dbi;
159
  my $error;
160
  eval {
161
    $dbi->connector->txn(sub {
162
      
163
      # Original project id
fix fork
Yuki Kimoto authored on 2016-04-21
164
      my $project = $dbi->model('project')->select(
165
        ['row_id', 'private'],
166
        where => {user => $original_user_row_id, id => $project_id}
version up and add descripti...
Yuki Kimoto authored on 2013-11-22
167
      )->one;
168
      
fix fork
Yuki Kimoto authored on 2016-04-21
169
      use D;d [$original_user_row_id, $project_id, $project];
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
170
      
171
      # Create project
172
      eval {
173
        $self->_create_project(
fix fork
Yuki Kimoto authored on 2016-04-21
174
          $user_id,
175
          $project_id,
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
176
          {
fix fork
Yuki Kimoto authored on 2016-04-21
177
            original_project => $project->{row_id},
178
            private => $project->{private}
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
179
          }
180
        );
181
      };
182
      croak $error = $@ if $@;
183
      
184
      # Create repository
185
      eval {
fix fork
Yuki Kimoto authored on 2016-04-21
186
        $self->_fork_rep($original_user_id, $project_id, $user_id, $project_id);
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
187
      };
188
      croak $error = $@ if $@;
189
    });
190
  };
191
  croak $error if $@;
192
}
193

            
cleanup
Yuki Kimoto authored on 2013-05-13
194
sub is_admin {
fix project page
Yuki Kimoto authored on 2016-04-21
195
  my ($self, $user_id) = @_;
cleanup
Yuki Kimoto authored on 2013-05-13
196
  
197
  # Check admin
198
  my $is_admin = $self->app->dbi->model('user')
fix project page
Yuki Kimoto authored on 2016-04-21
199
    ->select('admin', where => {id => $user_id})->value;
cleanup
Yuki Kimoto authored on 2013-05-13
200
  
201
  return $is_admin;
202
}
203

            
add private checkbox
Yuki Kimoto authored on 2013-11-16
204
sub is_private_project {
fix project page
Yuki Kimoto authored on 2016-04-21
205
  my ($self, $user_id, $project_id) = @_;
206
  
207
  my $user_row_id = $self->api->get_user_row_id($user_id);
add private checkbox
Yuki Kimoto authored on 2013-11-16
208
  
209
  # Is private
fix setting page
Yuki Kimoto authored on 2016-04-21
210
  my $private = $self->app->dbi->model('project')->select(
211
    'private', where => {user => $user_row_id, id => $project_id}
212
  )->value;
add private checkbox
Yuki Kimoto authored on 2013-11-16
213
  
214
  return $private;
215
}
216

            
fix project page
Yuki Kimoto authored on 2016-04-21
217
sub api { shift->app->gitprep_api }
218

            
219

            
fix network page
Yuki Kimoto authored on 2016-04-21
220
sub member_projects {
fix project page
Yuki Kimoto authored on 2016-04-21
221
  my ($self, $user_id, $project_id) = @_;
222
  
223
  my $user_row_id = $self->api->get_user_row_id($user_id);
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
224
  
225
  # DBI
226
  my $dbi = $self->app->dbi;
227
  
228
  # Original project id
fix network page
Yuki Kimoto authored on 2016-04-21
229
  my $project_row_id = $dbi->model('project')
230
    ->select('row_id', where => {user => $user_row_id, id => $project_id})->value;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
231
  
232
  # Members
233
  my $members = $dbi->model('project')->select(
fix project page
Yuki Kimoto authored on 2016-04-21
234
    [
fix network page
Yuki Kimoto authored on 2016-04-21
235
      {__MY__ => ['id']},
fix project page
Yuki Kimoto authored on 2016-04-21
236
      {user => ['id']}
237
    ],
fix network page
Yuki Kimoto authored on 2016-04-21
238
    where => {
239
      original_project => $project_row_id,
240
    },
241
    append => 'order by user.id, project.id'
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
242
  )->all;
243

            
244
  return $members;
245
}
246

            
247
sub create_project {
fix fork
Yuki Kimoto authored on 2016-04-21
248
  my ($self, $user_id, $project_id, $opts) = @_;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
249
  
add private checkbox to new ...
Yuki Kimoto authored on 2013-11-26
250
  my $params = {};
251
  if ($opts->{private}) {
252
    $params->{private} = 1;
253
  }
254
  
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
255
  # Create project
fixed bug that setting page ...
Yuki Kimoto authored on 2013-05-15
256
  my $dbi = $self->app->dbi;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
257
  my $error;
258
  eval {
259
    $dbi->connector->txn(sub {
fix fork
Yuki Kimoto authored on 2016-04-21
260
      eval { $self->_create_project($user_id, $project_id, $params) };
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
261
      croak $error = $@ if $@;
fix fork
Yuki Kimoto authored on 2016-04-21
262
      eval {$self->_create_rep($user_id, $project_id, $opts) };
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
263
      croak $error = $@ if $@;
264
    });
265
  };
266
  croak $error if $@;
267
}
268

            
269
sub create_user {
270
  my ($self, $user, $data) = @_;
271

            
272
  # Create user
fixed bug that setting page ...
Yuki Kimoto authored on 2013-05-15
273
  my $dbi = $self->app->dbi;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
274
  my $error;
275
  eval {
276
    $dbi->connector->txn(sub {
277
      eval { $self->_create_db_user($user, $data) };
278
      croak $error = $@ if $@;
279
      eval {$self->_create_user_dir($user) };
280
      croak $error = $@ if $@;
281
    });
282
  };
283
  croak $error if $@;
284
}
285

            
286
sub delete_project {
287
  my ($self, $user, $project) = @_;
288
  
289
  # Delete project
fixed bug that setting page ...
Yuki Kimoto authored on 2013-05-15
290
  my $dbi = $self->app->dbi;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
291
  my $error;
292
  eval {
293
    $dbi->connector->txn(sub {
294
      eval { $self->_delete_project($user, $project) };
295
      croak $error = $@ if $@;
296
      eval {$self->_delete_rep($user, $project) };
297
      croak $error = $@ if $@;
298
    });
299
  };
300
  croak $error if $@;
301
}
302

            
303
sub delete_user {
304
  my ($self, $user) = @_;
305
  
306
  # Delete user
fixed bug that setting page ...
Yuki Kimoto authored on 2013-05-15
307
  my $dbi = $self->app->dbi;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
308
  my $error;
added delete user test
Yuki Kimoto authored on 2013-05-18
309
  my $count;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
310
  eval {
311
    $dbi->connector->txn(sub {
added delete user test
Yuki Kimoto authored on 2013-05-18
312
      eval { $count = $self->_delete_db_user($user) };
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
313
      croak $error = $@ if $@;
314
      eval {$self->_delete_user_dir($user) };
315
      croak $error = $@ if $@;
316
    });
317
  };
318
  croak $error if $@;
added delete user test
Yuki Kimoto authored on 2013-05-18
319
  
320
  return $count;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
321
}
322

            
323
sub original_project {
fix project page
Yuki Kimoto authored on 2016-04-21
324
  my ($self, $user_id, $project_id) = @_;
325
  
326
  my $user_row_id = $self->api->get_user_row_id($user_id);
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
327
  
cleanup delete original_proj...
Yuki Kimoto authored on 2013-05-26
328
  # Original project id
329
  my $dbi = $self->app->dbi;
fix project page
Yuki Kimoto authored on 2016-04-21
330
  my $original_project_row_id = $dbi->model('project')->select(
331
    'original_project',
332
    where => {user => $user_row_id, id => $project_id}
333
  )->value;
cleanup delete original_proj...
Yuki Kimoto authored on 2013-05-26
334
  
fix project page
Yuki Kimoto authored on 2016-04-21
335
  croak "Original project don't eixsts." unless defined $original_project_row_id;
cleanup delete original_proj...
Yuki Kimoto authored on 2013-05-26
336
  
fixed bug that setting page ...
Yuki Kimoto authored on 2013-05-15
337
  # Original project
fix some tests
Yuki Kimoto authored on 2016-04-21
338
  $DB::single = 1 if $main::x;
cleanup delete original_proj...
Yuki Kimoto authored on 2013-05-26
339
  my $original_project = $dbi->model('project')->select(
fix project page
Yuki Kimoto authored on 2016-04-21
340
    [
341
      {__MY__ => '*'},
342
      {user => ['id']}
343
    ],
cleanup delete original_proj...
Yuki Kimoto authored on 2013-05-26
344
    where => {
fix project page
Yuki Kimoto authored on 2016-04-21
345
      'project.row_id' => $original_project_row_id
cleanup delete original_proj...
Yuki Kimoto authored on 2013-05-26
346
    }
fix project page
Yuki Kimoto authored on 2016-04-21
347
  )->one;
cleanup delete original_proj...
Yuki Kimoto authored on 2013-05-26
348
  
fix project page
Yuki Kimoto authored on 2016-04-21
349
  return unless defined $original_project;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
350
  
351
  return $original_project;
352
}
353

            
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
354
sub projects {
fix user page
Yuki Kimoto authored on 2016-04-21
355
  my ($self, $user_id) = @_;
356
  
357
  my $user_row_id = $self->app->dbi->model('user')->select('row_id', where => {id => $user_id})->value;
358
  
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
359
  # Projects
360
  my $projects = $self->app->dbi->model('project')->select(
fix user page
Yuki Kimoto authored on 2016-04-21
361
    where => {user => $user_row_id},
362
    append => 'order by id'
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
363
  )->all;
364
  
365
  return $projects;
366
}
367

            
cleanup
Yuki Kimoto authored on 2013-05-13
368
sub users {
369
  my $self = shift;
fixed bug that setting page ...
Yuki Kimoto authored on 2013-05-15
370
  
371
  # Users
cleanup
Yuki Kimoto authored on 2013-05-13
372
  my $users = $self->app->dbi->model('user')->select(
373
    where => [':admin{<>}',{admin => 1}],
374
    append => 'order by id'
375
  )->all;
376
  
377
  return $users;
378
}
379

            
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
380
sub rename_project {
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
381
  my ($self, $user, $project, $to_project) = @_;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
382
  
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
383
  # Rename project
revert encoding support
Yuki Kimoto authored on 2013-11-22
384
  my $git = $self->app->git;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
385
  my $dbi = $self->app->dbi;
simplify rename project
Yuki Kimoto authored on 2013-05-22
386
  my $error;
387
  eval {
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
388
    $dbi->connector->txn(sub {
simplify rename project
Yuki Kimoto authored on 2013-05-22
389
      eval { $self->_rename_project($user, $project, $to_project) };
390
      croak $error = $@ if $@;
391
      eval { $self->_rename_rep($user, $project, $to_project) };
392
      croak $error = $@ if $@;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
393
    });
simplify rename project
Yuki Kimoto authored on 2013-05-22
394
  };
395
  croak $error if $error;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
396
}
397

            
add key delete feature and u...
gitprep authored on 2014-05-19
398
sub update_authorized_keys_file {
399
  my $self = shift;
400

            
401
  my $authorized_keys_file = $self->authorized_keys_file;
402
  if (defined $authorized_keys_file) {
403
    
404
    # Lock file
fix update_authorized_keys_f...
gitprep authored on 2014-05-19
405
    my $lock_file = $self->app->home->rel_file('lock/authorized_keys');
add key delete feature and u...
gitprep authored on 2014-05-19
406
    open my $lock_fh, $lock_file
407
      or croak "Can't open lock file $lock_file";
408
    flock $lock_fh, LOCK_EX
409
      or croak "Can't lock $lock_file";
410
    
411
    # Create authorized_keys_file
412
    unless (-f $authorized_keys_file) {
413
      open my $fh, '>', $authorized_keys_file
fix gitprep-shell
gitprep authored on 2014-05-19
414
        or croak "Can't create authorized_keys file: $authorized_keys_file";
415
      chmod 0600, $authorized_keys_file
416
        or croak "Can't chmod authorized_keys file: $authorized_keys_file";
add key delete feature and u...
gitprep authored on 2014-05-19
417
    }
418
    
419
    # Parse file
forbidden public key which i...
Yuki Kimoto authored on 2014-12-15
420
    my $result = $self->parse_authorized_keys_file($authorized_keys_file);
fix update_authorized_keys_f...
gitprep authored on 2014-05-19
421
    my $before_part = $result->{before_part};
422
    my $gitprep_part = $result->{gitprep_part};
423
    my $after_part = $result->{after_part};
424
    my $start_symbol = $result->{start_symbol};
425
    my $end_symbol = $result->{end_symbol};
add key delete feature and u...
gitprep authored on 2014-05-19
426
    
427
    # Backup at first time
428
    if ($gitprep_part eq '') {
429
      # Backup original file
430
      my $to = "$authorized_keys_file.gitprep.original";
431
      unless (-f $to) {
432
        copy $authorized_keys_file, $to
433
          or croak "Can't copy $authorized_keys_file to $to";
434
      }
435
    }
fix update_authorized_keys_f...
gitprep authored on 2014-05-19
436

            
add key delete feature and u...
gitprep authored on 2014-05-19
437
    # Create public keys
fix update_authorized_keys_f...
gitprep authored on 2014-05-19
438
    my $ssh_public_keys = $self->app->dbi->model('ssh_public_key')->select->all;
add key delete feature and u...
gitprep authored on 2014-05-19
439
    my $ssh_public_keys_str = '';
440
    for my $key (@$ssh_public_keys) {
fix permission bug
gitprep authored on 2014-05-19
441
      my $ssh_public_key_str = 'command="' . $self->app->home->rel_file('script/gitprep-shell')
442
        . " $key->{user_id}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty $key->{key}";
fix update_authorized_keys_f...
gitprep authored on 2014-05-19
443
      $ssh_public_keys_str .= "$ssh_public_key_str $key->{user_id}\n\n";
add key delete feature and u...
gitprep authored on 2014-05-19
444
    }
445
    
446
    # Output tmp file
fix gitprep-shell
gitprep authored on 2014-05-19
447
    my $output = "$before_part$start_symbol\n\n$ssh_public_keys_str$end_symbol$after_part";
add key delete feature and u...
gitprep authored on 2014-05-19
448
    my $output_file = "$authorized_keys_file.gitprep.tmp";
449
    open my $out_fh, '>', $output_file
450
      or croak "Can't create authorized_keys tmp file $output_file";
451
    print $out_fh $output;
452
    close $out_fh
453
      or croak "Can't close authorized_keys tmp file $output_file";
fix update_authorized_keys_f...
gitprep authored on 2014-05-19
454

            
add key delete feature and u...
gitprep authored on 2014-05-19
455
    # Replace
fix permission bug
gitprep authored on 2014-05-19
456
    chmod 0600, $output_file
457
      or croak "Can't chmod authorized_keys tmp file: $output_file";
add key delete feature and u...
gitprep authored on 2014-05-19
458
    move $output_file, $authorized_keys_file
459
      or croak "Can't replace $authorized_keys_file by $output_file";
460
  }
461
  else {
462
    croak qq/authorized_keys file "$authorized_keys_file" is not found./;
463
  }
464
}
465

            
forbidden public key which i...
Yuki Kimoto authored on 2014-12-15
466
sub parse_authorized_keys_file {
fix update_authorized_keys_f...
gitprep authored on 2014-05-19
467
  my ($self, $file) = @_;
add key delete feature and u...
gitprep authored on 2014-05-19
468
  
469
  my $start_symbol = "# gitprep start";
470
  my $end_symbol = "# gitprep end";
471
  
472
  # Parse
473
  open my $fh, '<', $file
fix update_authorized_keys_f...
gitprep authored on 2014-05-19
474
    or croak "Can't open authorized_key file $file";
add key delete feature and u...
gitprep authored on 2014-05-19
475
  my $start_symbol_count = 0;
476
  my $end_symbol_count = 0;
477
  my $before_part = '';
478
  my $gitprep_part = '';
479
  my $after_part = '';
480
  my $error_prefix = "authorized_keys file $file format error:";
481
  while (my $line = <$fh>) {
482
    if ($line =~ /^$start_symbol/) {
483
      if ($start_symbol_count > 0) {
484
        croak qq/$error_prefix "$start_symbol" is found more than one/;
485
      }
486
      else {
487
        if ($end_symbol_count > 0) {
488
          croak qq/$error_prefix "$end_symbol" is found before "$start_symbol"/;
489
        }
490
        else {
491
          $start_symbol_count++;
492
        }
493
      }
494
    }
495
    elsif ($line =~ /^$end_symbol/) {
fix ssh key authentication b...
gitprep authored on 2014-05-20
496
      if ($end_symbol_count > 0) {
add key delete feature and u...
gitprep authored on 2014-05-19
497
        croak qq/$error_prefix "$end_symbol" is found more than one/;
498
      }
499
      else {
fix gitprep-shell
gitprep authored on 2014-05-19
500
        $end_symbol_count++;
add key delete feature and u...
gitprep authored on 2014-05-19
501
      }
502
    }
503
    elsif ($start_symbol_count == 0 && $end_symbol_count == 0) {
504
      $before_part .= $line;
505
    }
506
    elsif ($start_symbol_count == 1 && $end_symbol_count == 0) {
507
      $gitprep_part .= $line;
508
    }
509
    elsif ($start_symbol_count == 1 && $end_symbol_count == 1) {
510
      $after_part .= $line;
511
    }
512
  }
fix update_authorized_keys_f...
gitprep authored on 2014-05-19
513
  
514
  my $result = {
515
    start_symbol => $start_symbol,
516
    end_symbol => $end_symbol,
517
    before_part => $before_part,
518
    gitprep_part => $gitprep_part,
519
    after_part => $after_part
520
  };
521
  
522
  return $result;
add key delete feature and u...
gitprep authored on 2014-05-19
523
}
524

            
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
525
sub _create_project {
fix fork
Yuki Kimoto authored on 2016-04-21
526
  my ($self, $user_id, $project_id, $params) = @_;
527
  
528
  my $user_row_id = $self->api->get_user_row_id($user_id);
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
529
  $params ||= {};
fix fork
Yuki Kimoto authored on 2016-04-21
530
  $params->{user} = $user_row_id;
531
  $params->{id} = $project_id;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
532
  
533
  # Create project
cleanup
Yuki Kimoto authored on 2013-05-15
534
  my $dbi = $self->app->dbi;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
535
  $dbi->connector->txn(sub {
fix fork
Yuki Kimoto authored on 2016-04-21
536
    $dbi->model('project')->insert($params);
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
537
  });
538
}
539

            
540
sub _create_rep {
541
  my ($self, $user, $project, $opts) = @_;
542
  
543
  # Create repository directory
revert encoding support
Yuki Kimoto authored on 2013-11-22
544
  my $git = $self->app->git;
remove rep_path
Yuki Kimoto authored on 2016-04-16
545
  
546
  my $rep_info = $self->app->rep_info($user, $project);
547
  my $rep_git_dir = $rep_info->{git_dir};
548
  
549
  mkdir $rep_git_dir
550
    or croak "Can't create directory $rep_git_dir: $!";
fix bug that in CGI reposito...
Yuki Kimoto authored on 2015-11-05
551
  
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
552
  eval {
553
    # Git init
554
    {
remove cmd_dir
Yuki Kimoto authored on 2016-04-16
555
      my @git_init_cmd = $git->cmd($rep_info, 'init', '--bare');
fix bug that in CGI reposito...
Yuki Kimoto authored on 2015-11-05
556
      Gitprep::Util::run_command(@git_init_cmd)
fix git 2.0 create repositor...
Yuki Kimoto authored on 2015-11-04
557
        or croak  "Can't execute git init --bare:@git_init_cmd";
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
558
    }
559
    
560
    # Add git-daemon-export-ok
561
    {
remove rep_path
Yuki Kimoto authored on 2016-04-16
562
      my $file = "$rep_git_dir/git-daemon-export-ok";
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
563
      open my $fh, '>', $file
564
        or croak "Can't create git-daemon-export-ok: $!"
565
    }
566
    
567
    # HTTP support
remove cmd_dir
Yuki Kimoto authored on 2016-04-16
568
    my @git_update_server_info_cmd = $git->cmd(
569
      $rep_info,
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
570
      '--bare',
571
      'update-server-info'
572
    );
fix bug that in CGI reposito...
Yuki Kimoto authored on 2015-11-05
573
    Gitprep::Util::run_command(@git_update_server_info_cmd)
fix git 2.0 create repositor...
Yuki Kimoto authored on 2015-11-04
574
      or croak "Can't execute git --bare update-server-info";
remove rep_path
Yuki Kimoto authored on 2016-04-16
575
    move("$rep_git_dir/hooks/post-update.sample", "$rep_git_dir/hooks/post-update")
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
576
      or croak "Can't move post-update";
577
    
578
    # Description
version up and add descripti...
Yuki Kimoto authored on 2013-11-22
579
    my $description = $opts->{description};
580
    $description = '' unless defined $description;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
581
    {
remove rep_path
Yuki Kimoto authored on 2016-04-16
582
      my $file = "$rep_git_dir/description";
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
583
      open my $fh, '>', $file
584
        or croak "Can't open $file: $!";
585
      print $fh encode('UTF-8', $description)
586
        or croak "Can't write $file: $!";
587
      close $fh;
588
    }
589
    
590
    # Add README and commit
591
    if ($opts->{readme}) {
592
      # Create working directory
use own tmp directory to cre...
Yuki Kimoto authored on 2016-03-24
593
      my $home_tmp_dir = $self->app->home->rel_file('tmp');
594
      
remove cmd_work_dir
Yuki Kimoto authored on 2016-04-16
595
      # Temp directory
use own tmp directory to cre...
Yuki Kimoto authored on 2016-03-24
596
      my $temp_dir =  File::Temp->newdir(DIR => $home_tmp_dir);
remove cmd_work_dir
Yuki Kimoto authored on 2016-04-16
597
      
598
      # Working repository
599
      my $work_rep_work_tree = "$temp_dir/work";
600
      my $work_rep_git_dir = "$work_rep_work_tree/.git";
601
      my $work_rep_info = {
602
        work_tree => $work_rep_work_tree,
603
        git_dir => $work_rep_git_dir
604
      };
605
      
606
      mkdir $work_rep_work_tree
607
        or croak "Can't create directory $work_rep_work_tree: $!";
use own tmp directory to cre...
Yuki Kimoto authored on 2016-03-24
608
      
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
609
      # Git init
remove cmd_work_dir
Yuki Kimoto authored on 2016-04-16
610
      my @git_init_cmd = $git->cmd($work_rep_info, 'init', '-q');
fix bug that in CGI reposito...
Yuki Kimoto authored on 2015-11-05
611
      Gitprep::Util::run_command(@git_init_cmd)
fix git 2.0 create repositor...
Yuki Kimoto authored on 2015-11-04
612
        or croak "Can't execute git init: @git_init_cmd";
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
613
      
614
      # Add README
remove cmd_work_dir
Yuki Kimoto authored on 2016-04-16
615
      my $file = "$work_rep_work_tree/README.md";
default readme file is chang...
Yuki Kimoto authored on 2013-11-16
616
      open my $readme_fh, '>', $file
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
617
        or croak "Can't create $file: $!";
version up and add descripti...
Yuki Kimoto authored on 2013-11-22
618
      print $readme_fh "# $project\n";
619
      print $readme_fh "\n" . encode('UTF-8', $description) . "\n";
default readme file is chang...
Yuki Kimoto authored on 2013-11-16
620
      close $readme_fh;
621
      
remove cmd_work_dir
Yuki Kimoto authored on 2016-04-16
622
      my @git_add_cmd = $git->cmd(
623
        $work_rep_info,
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
624
        'add',
default readme file is chang...
Yuki Kimoto authored on 2013-11-16
625
        'README.md'
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
626
      );
improve create working repos...
Yuki Kimoto authored on 2016-04-15
627
      
fix bug that in CGI reposito...
Yuki Kimoto authored on 2015-11-05
628
      Gitprep::Util::run_command(@git_add_cmd)
fix git 2.0 create repositor...
Yuki Kimoto authored on 2015-11-04
629
        or croak "Can't execute git add: @git_add_cmd";
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
630
      
fix bug that repository with...
Yuki Kimoto authored on 2016-04-12
631
      # Set user name
remove cmd_work_dir
Yuki Kimoto authored on 2016-04-16
632
      my @git_config_user_name = $git->cmd(
633
        $work_rep_info,
fix bug that repository with...
Yuki Kimoto authored on 2016-04-12
634
        'config',
635
        'user.name',
636
        $user
637
      );
638
      Gitprep::Util::run_command(@git_config_user_name)
639
        or croak "Can't execute git config: @git_config_user_name";
640
      
fix mail bug
Yuki Kimoto authored on 2016-04-21
641
      # Set user email
642
      my $user_email = $self->app->dbi->model('user')->select('email', where => {id => $user})->value;
643
      my @git_config_user_email = $git->cmd(
remove cmd_work_dir
Yuki Kimoto authored on 2016-04-16
644
        $work_rep_info,
fix bug that repository with...
Yuki Kimoto authored on 2016-04-12
645
        'config',
646
        'user.email',
fix mail bug
Yuki Kimoto authored on 2016-04-21
647
        "$user_email"
fix bug that repository with...
Yuki Kimoto authored on 2016-04-12
648
      );
fix mail bug
Yuki Kimoto authored on 2016-04-21
649
      Gitprep::Util::run_command(@git_config_user_email)
650
        or croak "Can't execute git config: @git_config_user_email";
fix bug that repository with...
Yuki Kimoto authored on 2016-04-12
651
      
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
652
      # Commit
remove cmd_work_dir
Yuki Kimoto authored on 2016-04-16
653
      my @git_commit_cmd = $git->cmd(
654
        $work_rep_info,
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
655
        'commit',
656
        '-q',
657
        '-m',
658
        'first commit'
659
      );
fix bug that in CGI reposito...
Yuki Kimoto authored on 2015-11-05
660
      Gitprep::Util::run_command(@git_commit_cmd)
fix git 2.0 create repositor...
Yuki Kimoto authored on 2015-11-04
661
        or croak "Can't execute git commit: @git_commit_cmd";
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
662
      
663
      # Push
664
      {
remove cmd_work_dir
Yuki Kimoto authored on 2016-04-16
665
        my @git_push_cmd = $git->cmd(
666
          $work_rep_info,
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
667
          'push',
668
          '-q',
remove rep_path
Yuki Kimoto authored on 2016-04-16
669
          $rep_git_dir,
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
670
          'master'
671
        );
672
        # (This is bad, but --quiet option can't supress in old git)
fix bug that in CGI reposito...
Yuki Kimoto authored on 2015-11-05
673
        Gitprep::Util::run_command(@git_push_cmd)
fix git 2.0 create repositor...
Yuki Kimoto authored on 2015-11-04
674
          or croak "Can't execute git push: @git_push_cmd";
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
675
      }
676
    }
677
  };
improve faq of pushing lerge...
Yuki Kimoto authored on 2014-02-17
678
  if (my $e = $@) {
remove rep_path
Yuki Kimoto authored on 2016-04-16
679
    rmtree $rep_git_dir;
improve faq of pushing lerge...
Yuki Kimoto authored on 2014-02-17
680
    croak $e;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
681
  }
682
}
683

            
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
684
sub _create_db_user {
fix project page
Yuki Kimoto authored on 2016-04-21
685
  my ($self, $user_id, $data) = @_;
686
  
687
  $data->{id} = $user_id;
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
688
  
689
  # Create database user
fix project page
Yuki Kimoto authored on 2016-04-21
690
  $self->app->dbi->model('user')->insert($data);
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
691
}
692

            
693
sub _create_user_dir {
694
  my ($self, $user) = @_;
695
  
696
  # Create user directory
cleanup ->rep_home
Yuki Kimoto authored on 2016-04-14
697
  my $rep_home = $self->app->rep_home;
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
698
  my $user_dir = "$rep_home/$user";
699
  mkpath $user_dir;
700
}
701

            
702
sub _delete_db_user {
fix project page
Yuki Kimoto authored on 2016-04-21
703
  my ($self, $user_id) = @_;
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
704
  
705
  # Delete database user
fix project page
Yuki Kimoto authored on 2016-04-21
706
  my $count = $self->app->dbi->model('user')->delete(where => {id => $user_id});
added delete user test
Yuki Kimoto authored on 2013-05-18
707
  
708
  return $count;
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
709
}
710

            
711
sub _delete_user_dir {
712
  my ($self, $user) = @_;
713
  
714
  # Delete user directory
cleanup ->rep_home
Yuki Kimoto authored on 2016-04-14
715
  my $rep_home = $self->app->rep_home;
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
716
  my $user_dir = "$rep_home/$user";
717
  rmtree $user_dir;
718
}
719

            
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
720
sub _delete_project {
fix project page
Yuki Kimoto authored on 2016-04-21
721
  my ($self, $user_id, $project_id) = @_;
722
  
723
  my $user_row_id = $self->api->get_user_row_id($user_id);
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
724
  
cleanup
Yuki Kimoto authored on 2013-05-15
725
  # Delete project
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
726
  my $dbi = $self->app->dbi;
fix project page
Yuki Kimoto authored on 2016-04-21
727
  $dbi->model('project')->delete(where => {user => $user_row_id, id => $project_id});
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
728
}
729

            
730
sub _delete_rep {
731
  my ($self, $user, $project) = @_;
732

            
cleanup
Yuki Kimoto authored on 2013-05-15
733
  # Delete repository
cleanup ->rep_home
Yuki Kimoto authored on 2016-04-14
734
  my $rep_home = $self->app->rep_home;
add missing 'o'
reneeb authored on 2013-10-14
735
  croak "Can't remove repository. repository home is empty"
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
736
    if !defined $rep_home || $rep_home eq '';
737
  my $rep = "$rep_home/$user/$project.git";
738
  rmtree $rep;
739
  croak "Can't remove repository. repository is rest"
740
    if -e $rep;
741
}
742

            
fixed bug that setting page ...
Yuki Kimoto authored on 2013-05-15
743
sub exists_project {
fix project page
Yuki Kimoto authored on 2016-04-21
744
  my ($self, $user_id, $project_id) = @_;
745
  
746
  my $user_row_id = $self->api->get_user_row_id($user_id);
cleanup
Yuki Kimoto authored on 2013-05-15
747
  
748
  # Exists project
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
749
  my $dbi = $self->app->dbi;
fix project page
Yuki Kimoto authored on 2016-04-21
750
  my $row = $dbi->model('project')->select(where => {user => $user_row_id, id => $project_id})->one;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
751
  
752
  return $row ? 1 : 0;
753
}
754

            
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
755
sub exists_user {
fix project page
Yuki Kimoto authored on 2016-04-21
756
  my ($self, $user_id) = @_;
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
757
  
758
  # Exists project
fix project page
Yuki Kimoto authored on 2016-04-21
759
  my $row = $self->app->dbi->model('user')->select(where => {id => $user_id})->one;
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
760
  
761
  return $row ? 1 : 0;
762
}
763

            
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
764
sub _exists_rep {
765
  my ($self, $user, $project) = @_;
766
  
cleanup
Yuki Kimoto authored on 2013-05-15
767
  # Exists repository
remove rep_path
Yuki Kimoto authored on 2016-04-16
768
  my $rep_info = $self->app->rep_info($user, $project);
769
  my $rep_git_dir = $rep_info->{git_dir};
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
770
  
remove rep_path
Yuki Kimoto authored on 2016-04-16
771
  return -e $rep_git_dir;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
772
}
773

            
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
774
sub _fork_rep {
fix fork
Yuki Kimoto authored on 2016-04-21
775
  my ($self, $user_id, $project_id, $to_user_id, $to_project_id) = @_;
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
776
  
cleanup
Yuki Kimoto authored on 2013-05-15
777
  # Fork repository
revert encoding support
Yuki Kimoto authored on 2013-11-22
778
  my $git = $self->app->git;
remove rep_path
Yuki Kimoto authored on 2016-04-16
779
  
fix fork
Yuki Kimoto authored on 2016-04-21
780
  my $rep_info = $self->app->rep_info($user_id, $project_id);
remove rep_path
Yuki Kimoto authored on 2016-04-16
781
  my $rep_git_dir = $rep_info->{git_dir};
782
  
fix fork
Yuki Kimoto authored on 2016-04-21
783
  my $to_rep_info = $self->app->rep_info($to_user_id, $to_project_id);
remove rep_path
Yuki Kimoto authored on 2016-04-16
784
  my $to_rep_git_dir = $to_rep_info->{git_dir};
785

            
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
786
  my @cmd = (
787
    $git->bin,
788
    'clone',
789
    '-q',
790
    '--bare',
remove rep_path
Yuki Kimoto authored on 2016-04-16
791
    $rep_git_dir,
792
    $to_rep_git_dir
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
793
  );
fix bug that in CGI reposito...
Yuki Kimoto authored on 2015-11-05
794
  Gitprep::Util::run_command(@cmd)
fix description file not cop...
Yuki Kimoto authored on 2013-05-25
795
    or croak "Can't fork repository(_fork_rep): @cmd";
796
  
797
  # Copy description
remove rep_path
Yuki Kimoto authored on 2016-04-16
798
  copy "$rep_git_dir/description", "$to_rep_git_dir/description"
fix description file not cop...
Yuki Kimoto authored on 2013-05-25
799
    or croak "Can't copy description file(_fork_rep)";
show deleted repository in u...
Yuki Kimoto authored on 2013-05-15
800
}
801

            
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
802
sub _rename_project {
fix project page
Yuki Kimoto authored on 2016-04-21
803
  my ($self, $user_id, $project_id, $renamed_project_id) = @_;
804
  
805
  my $user_row_id = $self->api->get_user_row_id($user_id);
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
806
  
cleanup
Yuki Kimoto authored on 2013-05-15
807
  # Check arguments
add rename project and suppr...
Yuki Kimoto authored on 2013-05-24
808
  croak "Invalid parameters(_rename_project)"
fix project page
Yuki Kimoto authored on 2016-04-21
809
    unless defined $user_id && defined $project_id && defined $renamed_project_id;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
810
  
811
  # Rename project
cleanup
Yuki Kimoto authored on 2013-05-15
812
  my $dbi = $self->app->dbi;
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
813
  $dbi->model('project')->update(
fix project page
Yuki Kimoto authored on 2016-04-21
814
    {id => $renamed_project_id},
815
    where => {user => $user_row_id, id => $project_id}
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
816
  );
817
}
818

            
819
sub _rename_rep {
820
  my ($self, $user, $project, $renamed_project) = @_;
821
  
cleanup
Yuki Kimoto authored on 2013-05-15
822
  # Check arguments
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
823
  croak "Invalid user name or project"
824
    unless defined $user && defined $project && defined $renamed_project;
cleanup
Yuki Kimoto authored on 2013-05-15
825

            
826
  # Rename repository
remove rep_path
Yuki Kimoto authored on 2016-04-16
827
  my $rep_info = $self->app->rep_info($user, $project);
828
  my $rep_git_dir = $rep_info->{git_dir};
829
  
830
  my $renamed_rep_info = $self->app->rep_info($user, $renamed_project);
831
  my $renamed_rep_git_dir = $renamed_rep_info->{git_dir};
832

            
833
  move($rep_git_dir, $renamed_rep_git_dir)
834
    or croak "Can't move $rep_git_dir to $renamed_rep_git_dir: $!";
fixed tags page paging bug a...
Yuki Kimoto authored on 2013-05-01
835
}
836

            
837
1;