diff options
author | Grzegorz Bizon <grzegorz.bizon@ntsn.pl> | 2015-12-14 11:24:45 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz.bizon@ntsn.pl> | 2015-12-14 12:25:37 +0100 |
commit | 32d83ee79fedc8760486ff40a2459ecb472fa51b (patch) | |
tree | 46b8032b6bcbfd1482707a9080e6538bf44faa1c /app/helpers | |
parent | b8f67c5e4735eb25a3d03daeb95900dc87692123 (diff) | |
parent | c81023435795766411c5954a4676ebb215af40a6 (diff) | |
download | gitlab-ce-32d83ee79fedc8760486ff40a2459ecb472fa51b.tar.gz |
Merge branch 'master' into ux/suppress-ci-yml-warning
* master: (24 commits)
Fix runners admin view
Fix migrations
Run builds from projects with enabled CI
Use Gitlab::Git instead of Ci::Git
Fix last specs
Fix specs
Fix after column rename
Fix errors
Update badge
Finishing touches
Fix triggers tests
Rename columns and rename migrations
Reimplement Trigger API
Remove ci_ prefix from all ci related things
Add runners token
Migrate CI::Project to Project
Fix indentation and BuildsEmailService
Change default values
Enhance migrate CI emails
Fix issue tracker service
...
Conflicts:
spec/features/commits_spec.rb
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/ci/gitlab_helper.rb | 17 | ||||
-rw-r--r-- | app/helpers/ci/projects_helper.rb | 36 | ||||
-rw-r--r-- | app/helpers/ci_badge_helper.rb | 13 | ||||
-rw-r--r-- | app/helpers/ci_status_helper.rb | 7 | ||||
-rw-r--r-- | app/helpers/graph_helper.rb | 10 | ||||
-rw-r--r-- | app/helpers/runners_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/triggers_helper.rb | 4 |
7 files changed, 32 insertions, 57 deletions
diff --git a/app/helpers/ci/gitlab_helper.rb b/app/helpers/ci/gitlab_helper.rb deleted file mode 100644 index e34c8be1dfc..00000000000 --- a/app/helpers/ci/gitlab_helper.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Ci - module GitlabHelper - def no_turbolink - { :"data-no-turbolink" => "data-no-turbolink" } - end - - def yaml_web_editor_link(project) - commits = project.commits - - if commits.any? && commits.last.ci_yaml_file - "#{project.gitlab_url}/edit/master/.gitlab-ci.yml" - else - "#{project.gitlab_url}/new/master" - end - end - end -end diff --git a/app/helpers/ci/projects_helper.rb b/app/helpers/ci/projects_helper.rb deleted file mode 100644 index fd991a4165a..00000000000 --- a/app/helpers/ci/projects_helper.rb +++ /dev/null @@ -1,36 +0,0 @@ -module Ci - module ProjectsHelper - def ref_tab_class ref = nil - 'active' if ref == @ref - end - - def success_ratio(success_builds, failed_builds) - failed_builds = failed_builds.count(:all) - success_builds = success_builds.count(:all) - - return 100 if failed_builds.zero? - - ratio = (success_builds.to_f / (success_builds + failed_builds)) * 100 - ratio.to_i - end - - def markdown_badge_code(project, ref) - url = status_ci_project_url(project, ref: ref, format: 'png') - "[![build status](#{url})](#{ci_project_url(project, ref: ref)})" - end - - def html_badge_code(project, ref) - url = status_ci_project_url(project, ref: ref, format: 'png') - "<a href='#{ci_project_url(project, ref: ref)}'><img src='#{url}' /></a>" - end - - def project_uses_specific_runner?(project) - project.runners.any? - end - - def no_runners_for_project?(project) - project.runners.blank? && - Ci::Runner.shared.blank? - end - end -end diff --git a/app/helpers/ci_badge_helper.rb b/app/helpers/ci_badge_helper.rb new file mode 100644 index 00000000000..27386133e36 --- /dev/null +++ b/app/helpers/ci_badge_helper.rb @@ -0,0 +1,13 @@ +module CiBadgeHelper + def markdown_badge_code(project, ref) + url = status_ci_project_url(project, ref: ref, format: 'png') + link = namespace_project_commits_path(project.namespace, project, ref) + "[![build status](#{url})](#{link})" + end + + def html_badge_code(project, ref) + url = status_ci_project_url(project, ref: ref, format: 'png') + link = namespace_project_commits_path(project.namespace, project, ref) + "<a href='#{link}'><img src='#{url}' /></a>" + end +end diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb index c202c592067..8554074d619 100644 --- a/app/helpers/ci_status_helper.rb +++ b/app/helpers/ci_status_helper.rb @@ -1,6 +1,6 @@ module CiStatusHelper def ci_status_path(ci_commit) - project = ci_commit.gl_project + project = ci_commit.project builds_namespace_project_commit_path(project.namespace, project, ci_commit.sha) end @@ -63,4 +63,9 @@ module CiStatusHelper ci_status_icon(ci_commit) end end + + def no_runners_for_project?(project) + project.runners.blank? && + Ci::Runner.shared.blank? + end end diff --git a/app/helpers/graph_helper.rb b/app/helpers/graph_helper.rb index 1e372d5631d..c2ab80f2e0d 100644 --- a/app/helpers/graph_helper.rb +++ b/app/helpers/graph_helper.rb @@ -16,4 +16,14 @@ module GraphHelper ids = parents.map { |p| p.id } ids.zip(parent_spaces) end + + def success_ratio(success_builds, failed_builds) + failed_builds = failed_builds.count(:all) + success_builds = success_builds.count(:all) + + return 100 if failed_builds.zero? + + ratio = (success_builds.to_f / (success_builds + failed_builds)) * 100 + ratio.to_i + end end diff --git a/app/helpers/runners_helper.rb b/app/helpers/runners_helper.rb index 46eb82a354f..9fb42487a75 100644 --- a/app/helpers/runners_helper.rb +++ b/app/helpers/runners_helper.rb @@ -19,7 +19,7 @@ module RunnersHelper id = "\##{runner.id}" if current_user && current_user.admin - link_to ci_admin_runner_path(runner) do + link_to admin_runner_path(runner) do display_name + id end else diff --git a/app/helpers/triggers_helper.rb b/app/helpers/triggers_helper.rb index 2a3a7e80fca..8cad994d10f 100644 --- a/app/helpers/triggers_helper.rb +++ b/app/helpers/triggers_helper.rb @@ -1,5 +1,5 @@ module TriggersHelper - def ci_build_trigger_url(project_id, ref_name) - "#{Settings.gitlab_ci.url}/ci/api/v1/projects/#{project_id}/refs/#{ref_name}/trigger" + def builds_trigger_url(project_id) + "#{Settings.gitlab.url}/api/v3/projects/#{project_id}/trigger/builds" end end |