diff options
Diffstat (limited to 'app/helpers/ci/commits_helper.rb')
-rw-r--r-- | app/helpers/ci/commits_helper.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/app/helpers/ci/commits_helper.rb b/app/helpers/ci/commits_helper.rb new file mode 100644 index 00000000000..74de30e006e --- /dev/null +++ b/app/helpers/ci/commits_helper.rb @@ -0,0 +1,39 @@ +module Ci + module CommitsHelper + def commit_status_alert_class(commit) + return 'alert-info' unless commit + + case commit.status + when 'success' + 'alert-success' + when 'failed', 'canceled' + 'alert-danger' + when 'skipped' + 'alert-disabled' + else + 'alert-warning' + end + end + + def ci_commit_path(commit) + ci_project_ref_commits_path(commit.project, commit.ref, commit.sha) + end + + def commit_link(commit) + link_to(commit.short_sha, ci_commit_path(commit)) + end + + def truncate_first_line(message, length = 50) + truncate(message.each_line.first.chomp, length: length) if message + end + + def ci_commit_title(commit) + content_tag :span do + link_to( + simple_sanitize(commit.project.name), ci_project_path(commit.project) + ) + ' @ ' + + gitlab_commit_link(@project, @commit.sha) + end + end + end +end |