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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
0ebcc60a
Commit
0ebcc60a
authored
Oct 26, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move locking from Satellite::Action to Satellite and add checks
parent
0e9d4f30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
22 deletions
+27
-22
lib/gitlab/satellite/action.rb
lib/gitlab/satellite/action.rb
+2
-16
lib/gitlab/satellite/satellite.rb
lib/gitlab/satellite/satellite.rb
+25
-6
No files found.
lib/gitlab/satellite/action.rb
View file @
0ebcc60a
...
@@ -18,18 +18,8 @@ module Gitlab
...
@@ -18,18 +18,8 @@ module Gitlab
# * Yields the prepared satellite repo
# * Yields the prepared satellite repo
def
in_locked_and_timed_satellite
def
in_locked_and_timed_satellite
Grit
::
Git
.
with_timeout
(
options
[
:git_timeout
])
do
Grit
::
Git
.
with_timeout
(
options
[
:git_timeout
])
do
File
.
open
(
lock_file
,
"w+"
)
do
|
f
|
project
.
satellite
.
lock
do
f
.
flock
(
File
::
LOCK_EX
)
return
yield
project
.
satellite
.
repo
unless
project
.
satellite
.
exists?
raise
"Satellite doesn't exist"
end
Dir
.
chdir
(
project
.
satellite
.
path
)
do
repo
=
Grit
::
Repo
.
new
(
'.'
)
return
yield
repo
end
end
end
end
end
rescue
Errno
::
ENOMEM
=>
ex
rescue
Errno
::
ENOMEM
=>
ex
...
@@ -40,10 +30,6 @@ module Gitlab
...
@@ -40,10 +30,6 @@ module Gitlab
return
false
return
false
end
end
def
lock_file
Rails
.
root
.
join
(
"tmp"
,
"
#{
project
.
path
}
.lock"
)
end
# * Clears the satellite
# * Clears the satellite
# * Updates the satellite from Gitolite
# * Updates the satellite from Gitolite
# * Sets up Git variables for the user
# * Sets up Git variables for the user
...
...
lib/gitlab/satellite/satellite.rb
View file @
0ebcc60a
...
@@ -10,6 +10,8 @@ module Gitlab
...
@@ -10,6 +10,8 @@ module Gitlab
end
end
def
clear_and_update!
def
clear_and_update!
raise
"Satellite doesn't exist"
unless
exists?
delete_heads!
delete_heads!
clear_working_dir!
clear_working_dir!
update_from_source!
update_from_source!
...
@@ -23,10 +25,31 @@ module Gitlab
...
@@ -23,10 +25,31 @@ module Gitlab
File
.
exists?
path
File
.
exists?
path
end
end
# Locks the satellite and yields
def
lock
raise
"Satellite doesn't exist"
unless
exists?
File
.
open
(
lock_file
,
"w+"
)
do
|
f
|
f
.
flock
(
File
::
LOCK_EX
)
return
yield
end
end
def
lock_file
Rails
.
root
.
join
(
"tmp"
,
"
#{
project
.
path
}
.lock"
)
end
def
path
def
path
Rails
.
root
.
join
(
"tmp"
,
"repo_satellites"
,
project
.
path
)
Rails
.
root
.
join
(
"tmp"
,
"repo_satellites"
,
project
.
path
)
end
end
def
repo
raise
"Satellite doesn't exist"
unless
exists?
@repo
||=
Grit
::
Repo
.
new
(
path
)
end
private
private
# Clear the working directory
# Clear the working directory
...
@@ -39,7 +62,7 @@ module Gitlab
...
@@ -39,7 +62,7 @@ module Gitlab
# This ensures we have no name clashes or issues updating branches when
# This ensures we have no name clashes or issues updating branches when
# working with the satellite.
# working with the satellite.
def
delete_heads!
def
delete_heads!
heads
=
repo
.
heads
.
map
{
|
head
|
head
.
name
}
heads
=
repo
.
heads
.
map
(
&
:name
)
# update or create the parking branch
# update or create the parking branch
if
heads
.
include?
PARKING_BRANCH
if
heads
.
include?
PARKING_BRANCH
...
@@ -54,15 +77,11 @@ module Gitlab
...
@@ -54,15 +77,11 @@ module Gitlab
heads
.
each
{
|
head
|
repo
.
git
.
branch
({
D
:
true
},
head
)
}
heads
.
each
{
|
head
|
repo
.
git
.
branch
({
D
:
true
},
head
)
}
end
end
def
repo
@repo
||=
Grit
::
Repo
.
new
(
path
)
end
# Updates the satellite from Gitolite
# Updates the satellite from Gitolite
#
#
# Note: this will only update remote branches (i.e. origin/*)
# Note: this will only update remote branches (i.e. origin/*)
def
update_from_source!
def
update_from_source!
repo
.
git
.
fetch
({},
:origin
)
repo
.
git
.
fetch
({
timeout:
true
},
:origin
)
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