Look for new branches more carefully

In certain cases, GitLab can miss a PostReceive invocation the first
time a branch is pushed. When this happens, the "branch created" hooks
are not run, which means various features don't work until the branch
is deleted and pushed again.

This MR changes the `Git::BranchPushService` so it checks the cache of
existing branches in addition to the `oldrev` reported for the branch.
If the branch name isn't in the cache, chances are we haven't run the
service yet (it's what refreshes the cache), so we can go ahead and
run it, even through `oldrev` is set.

If the cache has been cleared by some other means in the meantime, then
we'll still fail to run the hooks when we should. Fixing that in the
general case is a larger problem, and we'd need to devote significant
engineering effort to it.

There's a chance that we'll run the relevant hooks *multiple times*
with this change, if there's a race between the branch being created,
and the `PostReceive` worker being run multiple times, but this can
already happen, since Sidekiq is "at-least-once" execution of jobs. So,
this should be safe.
84 jobs for 59257-find-new-branches-harder in 51 minutes and 45 seconds (queued for 8 seconds)
Status Job ID Name Coverage
  Prepare
passed #233438589
gitlab-org
compile-assets pull-cache

00:15:33

passed #233438597
gitlab-org
retrieve-tests-metadata

00:02:01

passed #233438593
gitlab-org
setup-test-env

00:06:37

 
  Test
passed #233438655
allowed to fail
code_quality

00:07:31

passed #233438820
gitlab-org
db:check-schema-pg

00:02:48

passed #233438818
gitlab-org
db:migrate:reset-mysql

00:05:32

passed #233438816
gitlab-org
db:migrate:reset-pg

00:03:12

passed #233438829
gitlab-org
db:rollback-mysql

00:06:49

passed #233438827
gitlab-org
db:rollback-pg

00:05:16

passed #233438660
allowed to fail
dependency_scanning

00:19:21

passed #233438602
gitlab-org
docs lint

00:03:20

passed #233438809
gitlab-org
downtime_check

00:02:29

passed #233438814
gitlab-org
ee_compat_check

00:05:39

passed #233438833
gitlab-org
gitlab:setup-mysql

00:05:57

passed #233438831
gitlab-org
gitlab:setup-pg

00:07:47

failed #233438616
gitlab-org allowed to fail
gitlab:ui:visual

00:01:34

passed #233438835
gitlab-org
gitlab_git_test

00:01:08

passed #233438624
gitlab-org
jest

00:18:08

passed #233438619
gitlab-org
karma

00:11:53

54.55%
passed #233438839
gitlab-org
lint-ci-gitlab

00:01:23

passed #233438825
gitlab-org
migration:path-mysql

00:08:18

passed #233438822
gitlab-org
migration:path-pg

00:06:21

passed #233438648
gitlab-org
qa-frontend-node:10

00:11:04

passed #233438642
gitlab-org
qa-frontend-node:8

00:13:52

passed #233438653
gitlab-org allowed to fail
qa-frontend-node:latest

00:12:55

passed #233438626
gitlab-org
qa:internal

00:03:29

passed #233438633
gitlab-org
qa:selectors

00:05:11

passed #233438723
gitlab-org
rspec integration pg 1/6

00:17:50

passed #233438725
gitlab-org
rspec integration pg 2/6

00:16:31

passed #233438727
gitlab-org
rspec integration pg 3/6

00:16:47

passed #233438729
gitlab-org
rspec integration pg 4/6

00:16:20

passed #233438731
gitlab-org
rspec integration pg 5/6

00:15:20

passed #233438734
gitlab-org
rspec integration pg 6/6

00:15:12

passed #233438739
gitlab-org
rspec system pg 1/24

00:16:13

passed #233438765
gitlab-org
rspec system pg 10/24

00:13:00

passed #233438767
gitlab-org
rspec system pg 11/24

00:13:02

passed #233438769
gitlab-org
rspec system pg 12/24

00:12:47

passed #233438772
gitlab-org
rspec system pg 13/24

00:13:59

passed #233438774
gitlab-org
rspec system pg 14/24

00:15:23

passed #233438776
gitlab-org
rspec system pg 15/24

00:12:23

passed #233438778
gitlab-org
rspec system pg 16/24

00:14:11

passed #233438781
gitlab-org
rspec system pg 17/24

00:14:06

passed #233438783
gitlab-org
rspec system pg 18/24

00:14:01

passed #233438786
gitlab-org
rspec system pg 19/24

00:14:43

passed #233438743
gitlab-org
rspec system pg 2/24

00:15:03

passed #233438788
gitlab-org
rspec system pg 20/24

00:13:49

passed #233438790
gitlab-org
rspec system pg 21/24

00:15:31

passed #233438792
gitlab-org
rspec system pg 22/24

00:14:25

passed #233438795
gitlab-org
rspec system pg 23/24

00:12:23

passed #233438799
gitlab-org
rspec system pg 24/24

00:11:55

passed #233438745
gitlab-org
rspec system pg 3/24

00:14:45

passed #233438747
gitlab-org
rspec system pg 4/24

00:13:31

passed #233438749
gitlab-org
rspec system pg 5/24

00:12:58

passed #233438754
gitlab-org
rspec system pg 6/24

00:16:01

passed #233438757
gitlab-org
rspec system pg 7/24

00:12:08

passed #233438759
gitlab-org
rspec system pg 8/24

00:12:53

passed #233438763
gitlab-org
rspec system pg 9/24

00:14:40

passed #233438662
gitlab-org
rspec unit pg 1/20

00:14:40

passed #233438700
gitlab-org
rspec unit pg 10/20

00:17:14

passed #233438702
gitlab-org
rspec unit pg 11/20

00:15:12

passed #233438704
gitlab-org
rspec unit pg 12/20

00:19:17

passed #233438706
gitlab-org
rspec unit pg 13/20

00:15:58

passed #233438708
gitlab-org
rspec unit pg 14/20

00:17:19

passed #233438710
gitlab-org
rspec unit pg 15/20

00:15:43

passed #233438712
gitlab-org
rspec unit pg 16/20

00:17:32

passed #233438715
gitlab-org
rspec unit pg 17/20

00:18:57

passed #233438717
gitlab-org
rspec unit pg 18/20

00:17:37

passed #233438719
gitlab-org
rspec unit pg 19/20

00:16:37

passed #233438665
gitlab-org
rspec unit pg 2/20

00:12:54

passed #233438721
gitlab-org
rspec unit pg 20/20

00:20:39

passed #233438667
gitlab-org
rspec unit pg 3/20

00:14:47

passed #233438671
gitlab-org
rspec unit pg 4/20

00:14:05

passed #233438676
gitlab-org
rspec unit pg 5/20

00:14:45

passed #233438685
gitlab-org
rspec unit pg 6/20

00:15:56

passed #233438692
gitlab-org
rspec unit pg 7/20

00:17:28

passed #233438696
gitlab-org
rspec unit pg 8/20

00:16:45

passed #233438699
gitlab-org
rspec unit pg 9/20

00:19:00

passed #233438804
gitlab-org
rspec-fast-spec-helper

00:03:47

failed #233438657
allowed to fail
sast

00:32:30

passed #233438808
gitlab-org
static-analysis

00:25:41

 
  Post Test
passed #233438851
gitlab-org
coverage

00:03:25

95.73%
passed #233438853
gitlab-org allowed to fail
flaky-examples-check

00:01:29

passed #233438848
gitlab-org
jsdoc

00:01:35

passed #233438844
gitlab-org
lint:javascript:report

00:00:58

 
Name Stage Failure
failed
sast Test
2019/06/18 10:51:10 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
2019/06/18 10:51:10 Timeout when running the analyzer
Running after script...
$ date
Tue Jun 18 10:51:18 UTC 2019
Uploading artifacts...
WARNING: gl-sast-report.json: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1
failed
gitlab:ui:visual Test
$ rm -r node_modules
$ git clone https://gitlab.com/gitlab-org/gitlab-ui.git
Cloning into 'gitlab-ui'...
$ cp public/assets/application-*.css gitlab-ui/styles/application.css
cp: cannot create regular file 'gitlab-ui/styles/application.css': No such file or directory
Running after script...
$ date
Tue Jun 18 10:20:18 UTC 2019
Uploading artifacts...
gitlab-ui/tests/__image_snapshots__/: found 112 matching files