Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
nexedi
gitlab-shell
Commits
c110d110
Commit
c110d110
authored
Apr 19, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix and refactor redis command
parent
34d1be9b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
13 deletions
+23
-13
lib/gitlab_config.rb
lib/gitlab_config.rb
+19
-0
lib/gitlab_update.rb
lib/gitlab_update.rb
+4
-13
No files found.
lib/gitlab_config.rb
View file @
c110d110
...
...
@@ -26,4 +26,23 @@ class GitlabConfig
def
redis
@config
[
'redis'
]
||=
{}
end
def
redis_namespace
redis
[
'namespace'
]
||
'resque:gitlab'
end
# Build redis command to write update event in gitlab queue
def
redis_command
if
redis
.
empty?
# Default to old method of connecting to redis
# for users that haven't updated their configuration
"env -i redis-cli"
else
if
redis
.
has_key?
(
"socket"
)
"
#{
redis
[
'bin'
]
}
-s
#{
redis
[
'socket'
]
}
"
else
"
#{
redis
[
'bin'
]
}
-h
#{
redis
[
'host'
]
}
-p
#{
redis
[
'port'
]
}
"
end
end
end
end
lib/gitlab_update.rb
View file @
c110d110
...
...
@@ -2,8 +2,10 @@ require_relative 'gitlab_init'
require_relative
'gitlab_net'
class
GitlabUpdate
attr_reader
:config
def
initialize
(
repo_path
,
key_id
,
refname
)
config
=
GitlabConfig
.
new
@
config
=
GitlabConfig
.
new
@repo_path
=
repo_path
.
strip
@repo_name
=
repo_path
...
...
@@ -17,8 +19,6 @@ class GitlabUpdate
@oldrev
=
ARGV
[
1
]
@newrev
=
ARGV
[
2
]
@redis
=
config
.
redis
end
def
exec
...
...
@@ -53,16 +53,7 @@ class GitlabUpdate
end
def
update_redis
if
!
@redis
.
empty?
&&
!
@redis
.
has_key?
(
"socket"
)
redis_command
=
"
#{
@redis
[
'bin'
]
}
-h
#{
@redis
[
'host'
]
}
-p
#{
@redis
[
'port'
]
}
"
elsif
!
@redis
.
empty?
&&
@redis
.
has_key?
(
"socket"
)
redis_command
=
"
#{
@redis
[
'bin'
]
}
-s
#{
@redis
[
'socket'
]
}
"
else
# Default to old method of connecting to redis for users that haven't updated their configuration
redis_command
=
"env -i redis-cli"
end
command
=
"
#{
redis_command
}
rpush '
#{
@redis
[
'namespace'
]
}
:queue:post_receive' '{
\"
class
\"
:
\"
PostReceive
\"
,
\"
args
\"
:[
\"
#{
@repo_path
}
\"
,
\"
#{
@oldrev
}
\"
,
\"
#{
@newrev
}
\"
,
\"
#{
@refname
}
\"
,
\"
#{
@key_id
}
\"
]}' > /dev/null 2>&1"
command
=
"
#{
config
.
redis_command
}
rpush '
#{
config
.
redis_namespace
}
:queue:post_receive' '{
\"
class
\"
:
\"
PostReceive
\"
,
\"
args
\"
:[
\"
#{
@repo_path
}
\"
,
\"
#{
@oldrev
}
\"
,
\"
#{
@newrev
}
\"
,
\"
#{
@refname
}
\"
,
\"
#{
@key_id
}
\"
]}' > /dev/null 2>&1"
system
(
command
)
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