Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #6721

Closed
Open
Created Apr 07, 2014 by Administrator@rootOwner

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}
Assignee
Assign to
Time tracking