Outdated `Project#has_ci?` and `MergeRequest#has_ci?`
Problem
Project#has_ci? and MergeRequest#has_ci? are outdated and have a couple of problems.
-
Project#has_ci?doesn't takeci_config_pathinto account. For example, when a user changed the default path of.gitlab-ci.yml, this function returns a wrong result. -
Project#has_ci?doesn't takeproject.ci_serviceinto account. For example, when a user setup external CI service as an integration, this function returns a wrong result. -
Project#has_ci?fetches full-sized blob for checking the file existence. This is not ideal from performance perspective. We can useGitlab::Git::Blob.findinstead with specifyinglimit:to zero. This way, Rails can ask Gitaly not to return the full-sized blob but just checking file existence. -
MergeRequest#has_ci?should be delegated toProject.has_ci?, as the current logic doesn't cover the whole cases. Simply, "Having no pipelines" does NOT mean "The project has not setup CI for MRs". Today, users can setup a complex pipeline/jobrules(oronly/except) and cannot concludehas_ci?by just checking the pipeline existence. Also, it contains a race condition that pipelines might not exist regardless of the .gitlab-ci.yml existence because of the nature of asynchronous pipeline creation.
Proposal
- Fix
Project#has_ci?to respect the other cases. - Avoid
repository.gitlab_ci_ymland usesGitlab::Git::Blob.findinstead. -
MergeReqest#has_ci?should be delegated tosource_project#has_ci?
Edited by Shinya Maeda