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

Added newrev and oldrev to the hook data

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