Service hook comes with empty commits array for new pushed branch
Created by: ayalaio
Suppose that in a sample project service I have:
def execute(push_data)
Gitlab::AppLogger.info push_data
end
Then in my local repo I do:
$ git checkout -b branch-2
$ vim myfile.rb
$ git commit -am "my commit"
$ git push origin branch-2
On the application log the push data comes with empty commits array.
{:before=>"0000000000000000000000000000000000000000", :after=>"053af2f9be90f6d05b61c502f59f8a293ed83521", :ref=>"refs/heads/branch-2", :user_id=>9, :user_name=>"david", :project_id=>46, :repository=>{:name=>"repo-1", :url=>"[email protected]:david/repo-1.git", :description=>nil, :homepage=>"http://gitlab.dev/david/repo-1"}, :commits=>[], :total_commits_count=>0}
But, if the branch exists (lets say I previously created it from the UI or could had been created because of the previous push) then it will not come empty.
In the UI:
create branch-2 in the UI
Local repo:
$ git checkout -b branch-2
$ vim myfile.rb
$ git commit -am "my other commit"
$ git push origin branch-2
application log as expected:
{:before=>"0000000000000000000000000000000000000000", :after=>"053af2f9be90f6d05b61c502f59f8a293ed83521", :ref=>"refs/heads/branch-2", :user_id=>9, :user_name=>"david", :project_id=>46, :repository=>{:name=>"repo-1", :url=>"[email protected]:david.a.rodriguez/repo-1.git", :description=>nil, :homepage=>"http://gitlab.dev/david/repo-1"}, :commits=>[{:id=>"0c9eaec43a081163b6b96c265a322853ae8479be", :message=>"my other commit", :timestamp=>"2014-04-07T15:14:42-07:00", :url=>"http://gitlab.dev/david/repo-1/commit/0c9eaec43a081163b6b96c265a322853ae8479be", :author=>{:name=>"David R", :email=>"[email protected]"}}], :total_commits_count=>1}