... | ... |
@@ -44,6 +44,18 @@ sub rep_info { |
44 | 44 |
return $info; |
45 | 45 |
} |
46 | 46 |
|
47 |
+sub work_rep_info { |
|
48 |
+ my ($self, $user, $project) = @_; |
|
49 |
+ |
|
50 |
+ my $info = {}; |
|
51 |
+ $info->{user} = $user; |
|
52 |
+ $info->{project} = $project; |
|
53 |
+ $info->{git_dir} = $self->rep_work_home . "/$user/$project/.git"; |
|
54 |
+ $info->{work_tree} = $self->rep_work_home . "/$user/$project"; |
|
55 |
+ |
|
56 |
+ return $info; |
|
57 |
+} |
|
58 |
+ |
|
47 | 59 |
sub rep_home { |
48 | 60 |
my $self = shift; |
49 | 61 |
|
... | ... |
@@ -164,15 +164,6 @@ sub cmd_dir { |
164 | 164 |
return ($self->bin, "--git-dir=$dir", @cmd); |
165 | 165 |
} |
166 | 166 |
|
167 |
-sub cmd_rep_work { |
|
168 |
- my ($self, $user, $project, @cmd) = @_; |
|
169 |
- |
|
170 |
- # Working directory |
|
171 |
- my $work_rep_info = $self->app->rep_work_path($user, $project); |
|
172 |
- |
|
173 |
- return $self->cmd_work_dir($work_rep_info, @cmd); |
|
174 |
-} |
|
175 |
- |
|
176 | 167 |
sub cmd_work_dir { |
177 | 168 |
my ($self, $dir, @cmd) = @_; |
178 | 169 |
|
... | ... |
@@ -18,25 +18,25 @@ has 'authorized_keys_file'; |
18 | 18 |
sub create_rep_work { |
19 | 19 |
my ($self, $user, $project) = @_; |
20 | 20 |
|
21 |
+ # Remote repository |
|
22 |
+ my $rep_info = $self->app->rep_info($user, $project); |
|
23 |
+ my $rep_git_dir = $rep_info->{git_dir}; |
|
24 |
+ |
|
25 |
+ # Working repository |
|
26 |
+ my $work_rep_info = $self->app->work_rep_info($user, $project); |
|
27 |
+ my $work_tree = $work_rep_info->{work_tree}; |
|
28 |
+ |
|
21 | 29 |
# Create working repository if it don't exist |
22 |
- my $rep_work = $self->app->rep_work_path($user, $project); |
|
23 |
- unless (-e $rep_work) { |
|
24 |
- # Repository |
|
25 |
- my $rep = $self->app->rep_path($user, $project); |
|
26 |
- |
|
27 |
- # Working directory |
|
28 |
- my $rep_work = $self->app->rep_work_path($user, $project); |
|
29 |
- |
|
30 |
+ unless (-e $work_tree) { |
|
31 |
+ |
|
30 | 32 |
# git clone |
31 |
- my @git_clone_cmd = ($self->app->git->bin, 'clone', $rep, $rep_work); |
|
33 |
+ my @git_clone_cmd = ($self->app->git->bin, 'clone', $rep_git_dir, $work_tree); |
|
32 | 34 |
Gitprep::Util::run_command(@git_clone_cmd) |
33 | 35 |
or croak "Can't git clone: @git_clone_cmd"; |
34 |
- |
|
35 |
- warn $rep_work; |
|
36 | 36 |
|
37 | 37 |
# Set user name |
38 |
- my @git_config_user_name = $self->app->git->cmd_work_dir( |
|
39 |
- $rep_work, |
|
38 |
+ my @git_config_user_name = $self->app->git->cmd( |
|
39 |
+ $work_rep_info, |
|
40 | 40 |
'config', |
41 | 41 |
'user.name', |
42 | 42 |
$user |
... | ... |
@@ -46,8 +46,8 @@ sub create_rep_work { |
46 | 46 |
|
47 | 47 |
# Set user mail |
48 | 48 |
my $user_mail = $self->app->dbi->model('user')->select('mail', where => {id => $user})->value; |
49 |
- my @git_config_user_mail = $self->app->git->cmd_work_dir( |
|
50 |
- $rep_work, |
|
49 |
+ my @git_config_user_mail = $self->app->git->cmd( |
|
50 |
+ $work_rep_info, |
|
51 | 51 |
'config', |
52 | 52 |
'user.email', |
53 | 53 |
"$user_mail" |
... | ... |
@@ -66,14 +66,14 @@ |
66 | 66 |
|
67 | 67 |
# Fetch repository |
68 | 68 |
my $rep = $self->app->rep_path($user, $project); |
69 |
- my @git_fetch_cmd = $self->app->git->cmd_rep_work($user, $project, 'fetch'); |
|
69 |
+ my @git_fetch_cmd = $self->app->git->cmd(app->work_rep_info($user, $project), 'fetch'); |
|
70 | 70 |
Gitprep::Util::run_command(@git_fetch_cmd) |
71 | 71 |
or Carp::croak "Can't execute git fetch: @git_fetch_cmd"; |
72 | 72 |
|
73 | 73 |
# git checkout -b origin/$from_rev |
74 | 74 |
# my $gitprep_tmp_branch_name = '__gitprep_tmp_branch_name__'; |
75 |
- # my @git_checkout_tmp_branch = $self->app->git->cmd_rep_work( |
|
76 |
- # $user, $project, 'checkout', '-b', $gitprep_tmp_branch_name, "origin/$from_rev"); |
|
75 |
+ # my @git_checkout_tmp_branch = $self->app->git->cmd( |
|
76 |
+ # app->work_rep_info($user, $project), 'checkout', '-b', $gitprep_tmp_branch_name, "origin/$from_rev"); |
|
77 | 77 |
# Gitprep::Util::run_command(@git_checkout_tmp_branch) |
78 | 78 |
# or Carp::croak "Can't execute git checkout: @git_checkout_tmp_branch"; |
79 | 79 |
} |