Using Only:Changes with Only:Ref on multiple jobs stops one from triggering

Summary

Customer on [zd-2146320(https://gitlab.zendesk.com/agent/tickets/214632)(internal) In Gitlab 13.9.1 and until 13.11.0-ee. Using Only:Changes in combination with Only:Ref on gitlab-ci.yml on multiple jobs stops the second job from being created. This is obvious by commenting out one of the Changes in one of the jobs and seeing both jobs created.

Steps to reproduce

  1. Create a project
  2. Create a gitlab-ci.yml file
  3. Add two jobs that include the keywords Only:Changes and Only:Ref
  4. Edit a file inside the Changes path
  5. Check pipeline and see only first was created

Example Project

https://gitlab.com/gitlab-gold/ggutierrez/221469-30jun21

What is the current bug behavior?

Only one job is created

What is the expected correct behavior?

Both jobs should be created

Relevant logs and/or screenshots

Sample gitlab-ci.yml

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes