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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-shell
Commits
7929e8bf
Commit
7929e8bf
authored
Mar 15, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent character encoding issues by sending received changes as raw data.
parent
f19eee99
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
5 deletions
+14
-5
CHANGELOG
CHANGELOG
+3
-0
VERSION
VERSION
+1
-1
lib/gitlab_post_receive.rb
lib/gitlab_post_receive.rb
+5
-1
spec/gitlab_post_receive_spec.rb
spec/gitlab_post_receive_spec.rb
+5
-3
No files found.
CHANGELOG
View file @
7929e8bf
v2.5.5
- Prevent character encoding issues by sending received changes as raw data.
v2.5.4
- Remove recursive commands from bin/install
...
...
VERSION
View file @
7929e8bf
2.5.
4
2.5.
5
lib/gitlab_post_receive.rb
View file @
7929e8bf
require_relative
'gitlab_init'
require_relative
'gitlab_net'
require
'json'
require
'base64'
class
GitlabPostReceive
attr_reader
:config
,
:repo_path
,
:changes
...
...
@@ -70,8 +71,11 @@ class GitlabPostReceive
end
def
update_redis
# Encode changes as base64 so we don't run into trouble with non-UTF-8 input.
changes
=
Base64
.
encode64
(
@changes
)
queue
=
"
#{
config
.
redis_namespace
}
:queue:post_receive"
msg
=
JSON
.
dump
({
'class'
=>
'PostReceive'
,
'args'
=>
[
@repo_path
,
@actor
,
@
changes
]
})
msg
=
JSON
.
dump
({
'class'
=>
'PostReceive'
,
'args'
=>
[
@repo_path
,
@actor
,
changes
]
})
if
system
(
*
config
.
redis_command
,
'rpush'
,
queue
,
msg
,
err:
'/dev/null'
,
out:
'/dev/null'
)
return
true
...
...
spec/gitlab_post_receive_spec.rb
View file @
7929e8bf
...
...
@@ -5,9 +5,11 @@ describe GitlabPostReceive do
let
(
:repository_path
)
{
"/home/git/repositories"
}
let
(
:repo_name
)
{
'dzaporozhets/gitlab-ci'
}
let
(
:actor
)
{
'key-123'
}
let
(
:changes
)
{
'wow'
}
let
(
:changes
)
{
"123456 789012 refs/heads/tést
\n
654321 210987 refs/tags/tag"
}
let
(
:wrongly_encoded_changes
)
{
changes
.
encode
(
"ISO-8859-1"
).
force_encoding
(
"UTF-8"
)
}
let
(
:base64_changes
)
{
Base64
.
encode64
(
wrongly_encoded_changes
)
}
let
(
:repo_path
)
{
File
.
join
(
repository_path
,
repo_name
)
+
".git"
}
let
(
:gitlab_post_receive
)
{
GitlabPostReceive
.
new
(
repo_path
,
actor
,
changes
)
}
let
(
:gitlab_post_receive
)
{
GitlabPostReceive
.
new
(
repo_path
,
actor
,
wrongly_encoded_
changes
)
}
let
(
:message
)
{
"test "
*
10
+
"message "
*
10
}
before
do
...
...
@@ -56,7 +58,7 @@ describe GitlabPostReceive do
expect
(
gitlab_post_receive
).
to
receive
(
:system
).
with
(
*
[
*
%w(env -i redis-cli rpush resque:gitlab:queue:post_receive)
,
%Q/{"class":"PostReceive","args":["
#{
repo_path
}
","
#{
actor
}
",
"
#{
changes
}
"
]}/
,
%Q/{"class":"PostReceive","args":["
#{
repo_path
}
","
#{
actor
}
",
#{
base64_changes
.
inspect
}
]}/
,
{
err:
"/dev/null"
,
out:
"/dev/null"
}
]
).
and_return
(
true
)
...
...
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