NoMethodError for nil in pre-receive hook

Seen during today's outage / performance degradation, when GitLab.com was returning 500 / 502 errors.

lupine@gitlab-t470p:~/dev/gitlab.com/gitlab-com/migration$ git push --set-upstream upstream 437-reconciliation-runbooks
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 1.74 KiB | 1.74 MiB/s, done.
Total 5 (delta 3), reused 0 (delta 0)
remote: hooks/pre-receive:19:in `increase_reference_counter': undefined method `[]' for nil:NilClass (NoMethodError)
remote: 	from hooks/pre-receive:32:in `<main>'
To gitlab.com:gitlab-com/migration
 ! [remote rejected] 437-reconciliation-runbooks -> 437-reconciliation-runbooks (pre-receive hook declined)
error: failed to push some refs to 'git@gitlab.com:gitlab-com/migration'

Here's the code in the hook:

def increase_reference_counter(gl_repository, repo_path)
  result = GitlabNet.new.pre_receive(gl_repository)

  result['reference_counter_increased']
end

And that call to pre_receive:

  def pre_receive(gl_repository)
    resp = post("#{host}/pre_receive", gl_repository: gl_repository)

    raise NotFound if resp.code == '404'

    JSON.parse(resp.body) if resp.code == '200'
  end

We should fix this by not assuming that pre_receive returns a Hash. We should abort if the result is nil, instead.

It's possible that other calls to GitlabNet methods suffer from similar problems, so we should do a quick audit of them at the same time.