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
3fe84f0f
Commit
3fe84f0f
authored
May 03, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass GL_REPOSITORY in Workhorse responses
parent
c1de0a38
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
6 deletions
+32
-6
app/controllers/projects/git_http_controller.rb
app/controllers/projects/git_http_controller.rb
+1
-1
app/workers/post_receive.rb
app/workers/post_receive.rb
+7
-0
lib/api/internal.rb
lib/api/internal.rb
+1
-1
lib/gitlab/gl_repository.rb
lib/gitlab/gl_repository.rb
+4
-0
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+4
-2
spec/lib/gitlab/workhorse_spec.rb
spec/lib/gitlab/workhorse_spec.rb
+15
-2
No files found.
app/controllers/projects/git_http_controller.rb
View file @
3fe84f0f
...
@@ -59,7 +59,7 @@ class Projects::GitHttpController < Projects::GitHttpClientController
...
@@ -59,7 +59,7 @@ class Projects::GitHttpController < Projects::GitHttpClientController
def
render_ok
def
render_ok
set_workhorse_internal_api_content_type
set_workhorse_internal_api_content_type
render
json:
Gitlab
::
Workhorse
.
git_http_ok
(
repository
,
user
,
action_name
)
render
json:
Gitlab
::
Workhorse
.
git_http_ok
(
repository
,
wiki?
,
user
,
action_name
)
end
end
def
render_http_not_allowed
def
render_http_not_allowed
...
...
app/workers/post_receive.rb
View file @
3fe84f0f
...
@@ -66,6 +66,13 @@ class PostReceive
...
@@ -66,6 +66,13 @@ class PostReceive
private
private
# To maintain backwards compatibility, we accept both gl_repository or
# repository paths as project identifiers. Our plan is to migrate to
# gl_repository only with the following plan:
# 9.2: Handle both possible values. Keep Gitlab-Shell sending only repo paths
# 9.3 (or patch release): Make GitLab Shell pass gl_repository if present
# 9.4 (or patch release): Make GitLab Shell always pass gl_repository
# 9.5 (or patch release): Handle only gl_repository as project identifier on this method
def
parse_project_identifier
(
project_identifier
)
def
parse_project_identifier
(
project_identifier
)
if
project_identifier
.
start_with?
(
'/'
)
if
project_identifier
.
start_with?
(
'/'
)
Gitlab
::
RepoPath
.
parse
(
project_identifier
)
Gitlab
::
RepoPath
.
parse
(
project_identifier
)
...
...
lib/api/internal.rb
View file @
3fe84f0f
...
@@ -44,7 +44,7 @@ module API
...
@@ -44,7 +44,7 @@ module API
# Project id to pass between components that don't share/don't have
# Project id to pass between components that don't share/don't have
# access to the same filesystem mounts
# access to the same filesystem mounts
response
[
:gl_repository
]
=
"
#{
wiki?
?
'wiki'
:
'project'
}
-
#{
project
.
id
}
"
response
[
:gl_repository
]
=
Gitlab
::
GlRepository
.
gl_repository
(
project
,
wiki?
)
# Return the repository full path so that gitlab-shell has it when
# Return the repository full path so that gitlab-shell has it when
# handling ssh commands
# handling ssh commands
...
...
lib/gitlab/gl_repository.rb
View file @
3fe84f0f
module
Gitlab
module
Gitlab
module
GlRepository
module
GlRepository
def
self
.
gl_repository
(
project
,
is_wiki
)
"
#{
is_wiki
?
'wiki'
:
'project'
}
-
#{
project
.
id
}
"
end
def
self
.
parse
(
gl_repository
)
def
self
.
parse
(
gl_repository
)
match_data
=
/\A(project|wiki)-([1-9][0-9]*)\z/
.
match
(
gl_repository
)
match_data
=
/\A(project|wiki)-([1-9][0-9]*)\z/
.
match
(
gl_repository
)
unless
match_data
unless
match_data
...
...
lib/gitlab/workhorse.rb
View file @
3fe84f0f
...
@@ -16,15 +16,17 @@ module Gitlab
...
@@ -16,15 +16,17 @@ module Gitlab
SECRET_LENGTH
=
32
SECRET_LENGTH
=
32
class
<<
self
class
<<
self
def
git_http_ok
(
repository
,
user
,
action
)
def
git_http_ok
(
repository
,
is_wiki
,
user
,
action
)
project
=
repository
.
project
repo_path
=
repository
.
path_to_repo
repo_path
=
repository
.
path_to_repo
params
=
{
params
=
{
GL_ID
:
Gitlab
::
GlId
.
gl_id
(
user
),
GL_ID
:
Gitlab
::
GlId
.
gl_id
(
user
),
GL_REPOSITORY
:
Gitlab
::
GlRepository
.
gl_repository
(
project
,
is_wiki
),
RepoPath
:
repo_path
,
RepoPath
:
repo_path
,
}
}
if
Gitlab
.
config
.
gitaly
.
enabled
if
Gitlab
.
config
.
gitaly
.
enabled
address
=
Gitlab
::
GitalyClient
.
get_address
(
repository
.
project
.
repository_storage
)
address
=
Gitlab
::
GitalyClient
.
get_address
(
project
.
repository_storage
)
params
[
:Repository
]
=
repository
.
gitaly_repository
.
to_h
params
[
:Repository
]
=
repository
.
gitaly_repository
.
to_h
feature_enabled
=
case
action
.
to_s
feature_enabled
=
case
action
.
to_s
...
...
spec/lib/gitlab/workhorse_spec.rb
View file @
3fe84f0f
...
@@ -181,10 +181,23 @@ describe Gitlab::Workhorse, lib: true do
...
@@ -181,10 +181,23 @@ describe Gitlab::Workhorse, lib: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:repo_path
)
{
repository
.
path_to_repo
}
let
(
:repo_path
)
{
repository
.
path_to_repo
}
let
(
:action
)
{
'info_refs'
}
let
(
:action
)
{
'info_refs'
}
let
(
:params
)
do
{
GL_ID
:
"user-
#{
user
.
id
}
"
,
GL_REPOSITORY
:
"project-
#{
project
.
id
}
"
,
RepoPath
:
repo_path
}
end
subject
{
described_class
.
git_http_ok
(
repository
,
false
,
user
,
action
)
}
it
{
expect
(
subject
).
to
include
(
params
)
}
subject
{
described_class
.
git_http_ok
(
repository
,
user
,
action
)
}
context
'when is_wiki'
do
let
(
:params
)
do
{
GL_ID
:
"user-
#{
user
.
id
}
"
,
GL_REPOSITORY
:
"wiki-
#{
project
.
id
}
"
,
RepoPath
:
repo_path
}
end
subject
{
described_class
.
git_http_ok
(
repository
,
true
,
user
,
action
)
}
it
{
expect
(
subject
).
to
include
({
GL_ID
:
"user-
#{
user
.
id
}
"
,
RepoPath
:
repo_path
})
}
it
{
expect
(
subject
).
to
include
(
params
)
}
end
context
'when Gitaly is enabled'
do
context
'when Gitaly is enabled'
do
let
(
:gitaly_params
)
do
let
(
:gitaly_params
)
do
...
...
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