This instance will be upgraded to Heptapod 0.31.0rc on 2022-05-19 at 11:00 UTC+2 (a few minutes of down time)

Commit 4a251849 authored by Jeroen van Baarsen's avatar Jeroen van Baarsen
Browse files

Added newrev and oldrev to the hook data

parent 020c87c5f5f4
class GitTagPushService
attr_accessor :project, :user, :push_data
def execute(project, user, ref)
def execute(project, user, oldrev, newrev, ref)
@project, @user = project, user
@push_data = create_push_data(ref)
@push_data = create_push_data(oldrev, newrev, ref)
project.execute_hooks(@push_data.dup, :tag_push_hooks)
end
private
def create_push_data(ref)
def create_push_data(oldrev, newrev, ref)
data = {
ref: ref,
oldrev: oldrev,
newrev: newrev,
user_id: user.id,
user_name: user.name,
project_id: project.id,
......
......@@ -30,7 +30,7 @@ def perform(repo_path, oldrev, newrev, ref, identifier)
end
if tag?(ref)
GitTagPushService.new.execute(project, user, ref)
GitTagPushService.new.execute(project, user, oldrev, newrev, ref)
else
GitPushService.new.execute(project, user, oldrev, newrev, ref)
end
......
......@@ -7,17 +7,21 @@
before do
@ref = 'refs/tags/super-tag'
@oldrev = 'b98a310def241a6fd9c9a9a3e7934c48e498fe81'
@newrev = 'b19a04f53caeebf4fe5ec2327cb83e9253dc91bb'
end
describe 'Git Tag Push Data' do
before do
service.execute(project, user, @ref)
service.execute(project, user, @oldrev, @newrev, @ref)
@push_data = service.push_data
end
subject { @push_data }
it { should include(ref: @ref) }
it { should include(oldrev: @oldrev) }
it { should include(newrev: @newrev) }
it { should include(user_id: user.id) }
it { should include(user_name: user.name) }
it { should include(project_id: project.id) }
......@@ -36,7 +40,7 @@
context "execute web hooks" do
it "when pushing tags" do
project.should_receive(:execute_hooks)
service.execute(project, user, 'refs/tags/v1.0.0')
service.execute(project, user, 'oldrev', 'newrev', 'refs/tags/v1.0.0')
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