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
Boxiang Sun
gitlab-ce
Commits
847bba92
Commit
847bba92
authored
Oct 26, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Gitlab::Satellite::Action
parent
643ed9cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
lib/gitlab/satellite/action.rb
lib/gitlab/satellite/action.rb
+47
-0
No files found.
lib/gitlab/satellite/action.rb
0 → 100644
View file @
847bba92
module
Gitlab
module
Satellite
class
Action
DEFAULT_OPTIONS
=
{
git_timeout:
30
.
seconds
}
attr_accessor
:options
,
:project
def
initialize
(
project
,
options
=
{})
@project
=
project
@options
=
DEFAULT_OPTIONS
.
merge
(
options
)
end
protected
# * Sets a 30s timeout for Git
# * Locks the satellite repo
# * Yields the prepared satellite repo
def
in_locked_and_timed_satellite
Grit
::
Git
.
with_timeout
(
options
[
:git_timeout
])
do
File
.
open
(
lock_file
,
"w+"
)
do
|
f
|
f
.
flock
(
File
::
LOCK_EX
)
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
rescue
Errno
::
ENOMEM
=>
ex
Gitlab
::
GitLogger
.
error
(
ex
.
message
)
return
false
rescue
Grit
::
Git
::
GitTimeout
=>
ex
Gitlab
::
GitLogger
.
error
(
ex
.
message
)
return
false
end
def
lock_file
Rails
.
root
.
join
(
"tmp"
,
"
#{
project
.
path
}
.lock"
)
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