From 3b1543cd15fcc52c2f5f3b7f4ccf391334fb6028 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 24 Mar 2016 15:17:13 +0100 Subject: Detect build setup state based on gitlab_ci.yml presense Signed-off-by: Dmitriy Zaporozhets --- app/models/repository.rb | 4 ++++ app/views/projects/_builds_settings.html.haml | 2 +- app/views/projects/builds/index.html.haml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index 13154eb4205..f874017a8f2 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -467,6 +467,10 @@ class Repository end end + def gitlab_ci_yml + @gitlab_ci_yml ||= blob_at(head_commit.sha, '.gitlab-ci.yml') unless empty? + end + def head_commit @head_commit ||= commit(self.root_ref) end diff --git a/app/views/projects/_builds_settings.html.haml b/app/views/projects/_builds_settings.html.haml index f1edc800bbf..095e7e45df7 100644 --- a/app/views/projects/_builds_settings.html.haml +++ b/app/views/projects/_builds_settings.html.haml @@ -2,7 +2,7 @@ %legend Builds: - - unless @project.builds.any? + - unless @repository.gitlab_ci_yml .form-group .col-sm-offset-2.col-sm-10 %p Before you can use Builds (Continuous Integration) feature you need to setup it. diff --git a/app/views/projects/builds/index.html.haml b/app/views/projects/builds/index.html.haml index d21716e4887..aa85f495e39 100644 --- a/app/views/projects/builds/index.html.haml +++ b/app/views/projects/builds/index.html.haml @@ -27,7 +27,7 @@ = link_to 'Cancel running', cancel_all_namespace_project_builds_path(@project.namespace, @project), data: { confirm: 'Are you sure?' }, class: 'btn btn-danger', method: :post - - unless @project.builds.any? + - unless @repository.gitlab_ci_yml = link_to 'Get started with Builds', help_page_path('ci/quick_start', 'README'), class: 'btn btn-info' = link_to ci_lint_path, class: 'btn btn-default' do -- cgit v1.2.1