BigW Consortium Gitlab

Commit 7ece18f1 by Douwe Maan

Merge branch 'gl-username-hook-fix' into 'master'

Fix the incorrect value being used to set GL_USERNAME on hooks See merge request gitlab-org/gitlab-ce!15038
parents cd08fd23 42a45392
...@@ -8,7 +8,7 @@ module Gitlab ...@@ -8,7 +8,7 @@ module Gitlab
def execute(pusher, repository, oldrev, newrev, ref) def execute(pusher, repository, oldrev, newrev, ref)
@repository = repository @repository = repository
@gl_id = pusher.gl_id @gl_id = pusher.gl_id
@gl_username = pusher.name @gl_username = pusher.username
@oldrev = oldrev @oldrev = oldrev
@newrev = newrev @newrev = newrev
@ref = ref @ref = ref
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Git::HooksService, seed_helper: true do describe Gitlab::Git::HooksService, seed_helper: true do
let(:user) { Gitlab::Git::User.new('janedoe', 'Jane Doe', 'janedoe@example.com', 'user-456') } let(:gl_id) { 'user-456' }
let(:gl_username) { 'janedoe' }
let(:user) { Gitlab::Git::User.new(gl_username, 'Jane Doe', 'janedoe@example.com', gl_id) }
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, 'project-123') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, 'project-123') }
let(:service) { described_class.new } let(:service) { described_class.new }
let(:blankrev) { Gitlab::Git::BLANK_SHA }
before do let(:oldrev) { SeedRepo::Commit::PARENT_ID }
@blankrev = Gitlab::Git::BLANK_SHA let(:newrev) { SeedRepo::Commit::ID }
@oldrev = SeedRepo::Commit::PARENT_ID let(:ref) { 'refs/heads/feature' }
@newrev = SeedRepo::Commit::ID
@ref = 'refs/heads/feature'
end
describe '#execute' do describe '#execute' do
context 'when receive hooks were successful' do context 'when receive hooks were successful' do
it 'calls post-receive hook' do let(:hook) { double(:hook) }
hook = double(trigger: [true, nil])
it 'calls all three hooks' do
expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook) expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook)
expect(hook).to receive(:trigger).with(gl_id, gl_username, blankrev, newrev, ref)
.exactly(3).times.and_return([true, nil])
service.execute(user, repository, @blankrev, @newrev, @ref) { } service.execute(user, repository, blankrev, newrev, ref) { }
end end
end end
...@@ -28,7 +30,7 @@ describe Gitlab::Git::HooksService, seed_helper: true do ...@@ -28,7 +30,7 @@ describe Gitlab::Git::HooksService, seed_helper: true do
expect(service).not_to receive(:run_hook).with('post-receive') expect(service).not_to receive(:run_hook).with('post-receive')
expect do expect do
service.execute(user, repository, @blankrev, @newrev, @ref) service.execute(user, repository, blankrev, newrev, ref)
end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end.to raise_error(Gitlab::Git::HooksService::PreReceiveError)
end end
end end
...@@ -40,7 +42,7 @@ describe Gitlab::Git::HooksService, seed_helper: true do ...@@ -40,7 +42,7 @@ describe Gitlab::Git::HooksService, seed_helper: true do
expect(service).not_to receive(:run_hook).with('post-receive') expect(service).not_to receive(:run_hook).with('post-receive')
expect do expect do
service.execute(user, repository, @blankrev, @newrev, @ref) service.execute(user, repository, blankrev, newrev, ref)
end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end.to raise_error(Gitlab::Git::HooksService::PreReceiveError)
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment