Added newrev and oldrev to the hook data
This commit is contained in:
parent
f096bd61bd
commit
4a251849cf
|
@ -1,16 +1,18 @@
|
|||
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 @@ class PostReceive
|
|||
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 @@ describe GitTagPushService do
|
|||
|
||||
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 @@ describe GitTagPushService do
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue