Skip to content

Commit

Permalink
Merge branch '9217-warn-on-git-fetch-over-ssh-if-the-secondary-is-lag…
Browse files Browse the repository at this point in the history
…ging-the-primary' into 'master'

Display console messages, if available

See merge request gitlab-org/gitlab-ce!26692
  • Loading branch information
dbalexandre committed Apr 5, 2019
2 parents 3ccb4d9 + 6b7a9b7 commit b54228a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/api/internal.rb
Expand Up @@ -87,7 +87,8 @@ def lfs_authentication_url(project)
gl_id: Gitlab::GlId.gl_id(user),
gl_username: user&.username,
git_config_options: [],
gitaly: gitaly_payload(params[:action])
gitaly: gitaly_payload(params[:action]),
gl_console_messages: check_result.console_messages
}

# Custom option for git-receive-pack command
Expand Down
6 changes: 5 additions & 1 deletion lib/gitlab/git_access.rb
Expand Up @@ -85,7 +85,7 @@ def check(cmd, changes)
check_push_access!
end

::Gitlab::GitAccessResult::Success.new
::Gitlab::GitAccessResult::Success.new(console_messages: check_for_console_messages(cmd))
end

def guest_can_download_code?
Expand Down Expand Up @@ -116,6 +116,10 @@ def check_custom_action(cmd)
nil
end

def check_for_console_messages(cmd)
[]
end

def check_valid_actor!
return unless actor.is_a?(Key)

Expand Down
5 changes: 5 additions & 0 deletions lib/gitlab/git_access_result/success.rb
Expand Up @@ -3,6 +3,11 @@
module Gitlab
module GitAccessResult
class Success
attr_reader :console_messages

def initialize(console_messages: [])
@console_messages = console_messages
end
end
end
end
34 changes: 34 additions & 0 deletions spec/requests/api/internal_spec.rb
Expand Up @@ -498,6 +498,40 @@
end
end

context "console message" do
before do
project.add_developer(user)
end

context "git pull" do
context "with no console message" do
it "has the correct payload" do
pull(key, project)

expect(response).to have_gitlab_http_status(200)
expect(json_response['gl_console_messages']).to eq([])
end
end

context "with a console message" do
let(:console_messages) { ['message for the console'] }

it "has the correct payload" do
expect_next_instance_of(Gitlab::GitAccess) do |access|
expect(access).to receive(:check_for_console_messages)
.with('git-upload-pack')
.and_return(console_messages)
end

pull(key, project)

expect(response).to have_gitlab_http_status(200)
expect(json_response['gl_console_messages']).to eq(console_messages)
end
end
end
end

context "blocked user" do
let(:personal_project) { create(:project, namespace: user.namespace) }

Expand Down

0 comments on commit b54228a

Please sign in to comment.