Welcome to mirror list, hosted at ThFree Co, Russian Federation.

commits_helper.rb « ci « helpers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 86f254223cbd0bf36ec1791ba12d674a8bcfb68f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module Ci
  module CommitsHelper
    def commit_status_alert_class(commit)
      return 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
  end
end