Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
d7707145
Commit
d7707145
authored
Jan 22, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use subproccess instead subshell for git calls
parent
68fa9882
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
14 deletions
+18
-14
lib/gitlab/backend/gitolite_config.rb
lib/gitlab/backend/gitolite_config.rb
+18
-14
No files found.
lib/gitlab/backend/gitolite_config.rb
View file @
d7707145
...
@@ -8,10 +8,11 @@ module Gitlab
...
@@ -8,10 +8,11 @@ module Gitlab
class
PushError
<
StandardError
;
end
class
PushError
<
StandardError
;
end
class
BrokenGitolite
<
StandardError
;
end
class
BrokenGitolite
<
StandardError
;
end
attr_reader
:config_tmp_dir
,
:ga_repo
,
:conf
attr_reader
:config_tmp_dir
,
:
tmp_dir
,
:
ga_repo
,
:conf
def
config_tmp_dir
def
initialize
@config_tmp_dir
||=
Rails
.
root
.
join
(
'tmp'
,
"gitlabhq-gitolite-
#{
Time
.
now
.
to_i
}
"
)
@tmp_dir
=
Rails
.
root
.
join
(
"tmp"
).
to_s
@config_tmp_dir
=
File
.
join
(
@tmp_dir
,
"gitlabhq-gitolite-
#{
Time
.
now
.
to_i
}
"
)
end
end
def
ga_repo
def
ga_repo
...
@@ -23,7 +24,7 @@ module Gitlab
...
@@ -23,7 +24,7 @@ module Gitlab
def
apply
def
apply
Timeout
::
timeout
(
30
)
do
Timeout
::
timeout
(
30
)
do
File
.
open
(
Rails
.
root
.
join
(
'tmp'
,
"gitlabhq-gitolite.lock"
),
"w+"
)
do
|
f
|
File
.
open
(
File
.
join
(
tmp_dir
,
"gitlabhq-gitolite.lock"
),
"w+"
)
do
|
f
|
begin
begin
# Set exclusive lock
# Set exclusive lock
# to prevent race condition
# to prevent race condition
...
@@ -31,7 +32,7 @@ module Gitlab
...
@@ -31,7 +32,7 @@ module Gitlab
# Pull gitolite-admin repo
# Pull gitolite-admin repo
# in tmp dir before do any changes
# in tmp dir before do any changes
pull
(
config_tmp_dir
)
pull
# Build ga_repo object and @conf
# Build ga_repo object and @conf
# to access gitolite-admin configuration
# to access gitolite-admin configuration
...
@@ -49,7 +50,7 @@ module Gitlab
...
@@ -49,7 +50,7 @@ module Gitlab
# Push gitolite-admin repo
# Push gitolite-admin repo
# to apply all changes
# to apply all changes
push
(
config_tmp_dir
)
push
ensure
ensure
# Remove tmp dir
# Remove tmp dir
# removing the gitolite folder first is important to avoid
# removing the gitolite folder first is important to avoid
...
@@ -192,16 +193,20 @@ module Gitlab
...
@@ -192,16 +193,20 @@ module Gitlab
private
private
def
pull
tmp_dir
def
pull
Dir
.
mkdir
tmp_dir
# Create config tmp dir like "RAILS_ROOT/tmp/gitlabhq-gitolite-132545"
`git clone
#{
Gitlab
.
config
.
gitolite
.
admin_uri
}
#{
tmp_dir
}
/gitolite`
Dir
.
mkdir
config_tmp_dir
unless
File
.
exists?
(
File
.
join
(
tmp_dir
,
'gitolite'
,
'conf'
,
'gitolite.conf'
))
# Clone gitolite-admin repo into tmp dir
popen
(
"git clone
#{
Gitlab
.
config
.
gitolite
.
admin_uri
}
#{
config_tmp_dir
}
/gitolite"
,
tmp_dir
)
# Ensure file with config presents after cloning
unless
File
.
exists?
(
File
.
join
(
config_tmp_dir
,
'gitolite'
,
'conf'
,
'gitolite.conf'
))
raise
PullError
,
"unable to clone gitolite-admin repo"
raise
PullError
,
"unable to clone gitolite-admin repo"
end
end
end
end
def
push
tmp_dir
def
push
output
,
status
=
popen
(
'git add -A'
)
output
,
status
=
popen
(
'git add -A'
)
raise
"Git add failed."
unless
status
.
zero?
raise
"Git add failed."
unless
status
.
zero?
...
@@ -222,8 +227,8 @@ module Gitlab
...
@@ -222,8 +227,8 @@ module Gitlab
end
end
end
end
def
popen
(
cmd
)
def
popen
(
cmd
,
path
=
nil
)
path
=
File
.
join
(
config_tmp_dir
,
'gitolite'
)
path
||
=
File
.
join
(
config_tmp_dir
,
'gitolite'
)
vars
=
{
"PWD"
=>
path
}
vars
=
{
"PWD"
=>
path
}
options
=
{
:chdir
=>
path
}
options
=
{
:chdir
=>
path
}
...
@@ -239,4 +244,3 @@ module Gitlab
...
@@ -239,4 +244,3 @@ module Gitlab
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment