EmailsOnPushService is not working for one commit in push

If you push to origin with a single commit since the last push, EmailsOnPushService does not send e-mail and gets stuck in sidekiq retry queue.

Reproduce:

  • Create project, activate EmailsOnPushService in project settings.
  • Create first commit, push to origin.
  • Create second commit, push to origin, no e-mail is sent and sidekiq job ends on a warning (see log below).
  • If you create two more commits and push again, e-mail will be sent.

I believe it was introduced here: https://gitlab.com/gitlab-org/gitlab-ce/commit/7ba0b502d3e6fdc5efc5619d803a1b9fcf9db791#ccbf8b7e8dadebf41b70cc6adc890d5c0a55820f_24_26

Censored relevant part of sidekiq.log:

2014-03-27T13:59:08Z 7931 TID-mxlg8 WARN: No route matches {:action=>"show", :controller=>"projects/commit", :project_id=>#<Project id: *, name: "*", path: "*", description: nil, created_at: "2013-04-22 08:12:47", updated_at: "2013-04-30 18:52:38", creator_id: *, issues_enabled: true, wall_enabled: false, merge_requests_enabled: true, wiki_enabled: true, namespace_id: *, issues_tracker: "gitlab", issues_tracker_id: nil, snippets_enabled: false, last_activity_at: "2014-03-27 13:52:52", import_url: nil, visibility_level: 0, archived: false, import_status: "none">, :id=>#<Gitlab::Git::Commit:0x0000000460e998 @raw_commit=#<Grit::Commit "627ff76efbf5d01dc9e6e50783e0b763a4dcdde8">, @id="627ff76efbf5d01dc9e6e50783e0b763a4dcdde8", @message="*", @authored_date=2014-03-27 14:37:59 +0100, @committed_date=2014-03-27 14:39:14 +0100, @author_name="Jirka Chadima", @author_email="*", @committer_name="Jirka Chadima", @committer_email="*", @parent_ids=["45d04967f2795dfc4768694c0e59643189f2e86f"], @head=nil>, :format=>nil} missing required keys: [:id]
2014-03-27T13:59:08Z 7931 TID-mxlg8 WARN: /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.3/lib/action_dispatch/journey/formatter.rb:39:in `generate'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.3/lib/action_dispatch/routing/route_set.rb:601:in `generate'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.3/lib/action_dispatch/routing/route_set.rb:631:in `generate'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.3/lib/action_dispatch/routing/route_set.rb:667:in `url_for'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.3/lib/action_dispatch/routing/url_for.rb:155:in `url_for'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.3/lib/action_dispatch/routing/route_set.rb:234:in `call'
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.3/lib/action_dispatch/routing/route_set.rb:274:in `block (2 levels) in define_url_helper'
/home/git/gitlab/app/mailers/emails/projects.rb:29:in `repository_push_email'

Environment:

System information
System:
Current User:   git
Using RVM:      no
Ruby Version:   1.9.3p327
Gem Version:    1.8.23
Bundler Version:1.2.3
Rake Version:   10.1.1

GitLab information
Version:        6.7.2
Revision:       dbbf4ea
Directory:      /home/git/gitlab
DB Adapter:     mysql2
URL:            http://*
HTTP Clone URL: http://*/some-project.git
SSH Clone URL:  git@*:some-project.git
Using LDAP:     no
Using Omniauth: no

GitLab Shell
Version:        1.9.1
Repositories:   /home/git/repositories/
Hooks:          /home/git/gitlab-shell/hooks/
Git:            /usr/bin/git