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
5cd13175
Commit
5cd13175
authored
Apr 02, 2019
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Print console messages to $stderr if present
Using ConsoleHelper::write_stderr
parent
02088137
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
lib/gitlab_access_status.rb
lib/gitlab_access_status.rb
+7
-3
lib/gitlab_shell.rb
lib/gitlab_shell.rb
+2
-0
spec/gitlab_shell_spec.rb
spec/gitlab_shell_spec.rb
+16
-1
No files found.
lib/gitlab_access_status.rb
View file @
5cd13175
...
...
@@ -3,12 +3,14 @@ require 'json'
class
GitAccessStatus
HTTP_MULTIPLE_CHOICES
=
'300'
.
freeze
attr_reader
:message
,
:gl_repository
,
:gl_project_path
,
:gl_id
,
:gl_username
,
:gitaly
,
:git_protocol
,
:git_config_options
,
:payload
attr_reader
:message
,
:gl_repository
,
:gl_project_path
,
:gl_id
,
:gl_username
,
:gitaly
,
:git_protocol
,
:git_config_options
,
:payload
,
:gl_console_messages
def
initialize
(
status
,
status_code
,
message
,
gl_repository:
nil
,
gl_project_path:
nil
,
gl_id:
nil
,
gl_username:
nil
,
gitaly:
nil
,
git_protocol:
nil
,
git_config_options:
nil
,
payload:
nil
)
git_config_options:
nil
,
payload:
nil
,
gl_console_messages:
[]
)
@status
=
status
@status_code
=
status_code
@message
=
message
...
...
@@ -20,6 +22,7 @@ class GitAccessStatus
@gitaly
=
gitaly
@git_protocol
=
git_protocol
@payload
=
payload
@gl_console_messages
=
gl_console_messages
end
def
self
.
create_from_json
(
json
,
status_code
)
...
...
@@ -34,7 +37,8 @@ class GitAccessStatus
git_config_options:
values
[
"git_config_options"
],
gitaly:
values
[
"gitaly"
],
git_protocol:
values
[
"git_protocol"
],
payload:
values
[
"payload"
])
payload:
values
[
"payload"
],
gl_console_messages:
values
[
"gl_console_messages"
])
end
def
allowed?
...
...
lib/gitlab_shell.rb
View file @
5cd13175
...
...
@@ -66,6 +66,8 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
@username
=
access_status
.
gl_username
@git_config_options
=
access_status
.
git_config_options
@gl_id
=
access_status
.
gl_id
if
defined?
(
@who
)
write_stderr
(
access_status
.
gl_console_messages
)
elsif
!
defined?
(
@gl_id
)
# We're processing an API command like 2fa_recovery_codes, but
# don't have a @gl_id yet, that means we're in the "username"
...
...
spec/gitlab_shell_spec.rb
View file @
5cd13175
...
...
@@ -33,7 +33,8 @@ describe GitlabShell do
gl_username:
gl_username
,
git_config_options:
git_config_options
,
gitaly:
{
'repository'
=>
{
'relative_path'
=>
repo_name
,
'storage_name'
=>
'default'
}
,
'address'
=>
'unix:gitaly.socket'
},
git_protocol:
git_protocol
git_protocol:
git_protocol
,
gl_console_messages:
gl_console_messages
)
end
...
...
@@ -69,6 +70,7 @@ describe GitlabShell do
let
(
:gl_username
)
{
'testuser'
}
let
(
:git_config_options
)
{
[
'receive.MaxInputSize=10000'
]
}
let
(
:git_protocol
)
{
'version=2'
}
let
(
:gl_console_messages
)
{
nil
}
before
do
allow_any_instance_of
(
GitlabConfig
).
to
receive
(
:audit_usernames
).
and_return
(
false
)
...
...
@@ -438,6 +440,19 @@ describe GitlabShell do
end
end
end
context
'with a console message'
do
let
(
:ssh_cmd
)
{
"git-receive-pack gitlab-ci.git"
}
let
(
:gl_console_messages
)
{
'Very important message'
}
before
do
allow
(
api
).
to
receive
(
:check_access
).
and_return
(
gitaly_check_access
)
end
it
'displays the message on $stderr'
do
expect
{
subject
.
exec
(
ssh_cmd
)
}.
to
output
(
"> GitLab:
#{
gl_console_messages
}
\n
"
).
to_stderr
end
end
end
describe
'#validate_access'
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