Module: CommitHelper
- Included in:
- ProblemPresenter
- Defined in:
- app/helpers/commit_helper.rb
Instance Method Summary collapse
- #format_commit(commit) ⇒ Object
- #format_sha(sha) ⇒ Object
- #format_with_tickets_linked(project, message) ⇒ Object
- #link_to_commit(commit, options = {}) ⇒ Object
- #link_to_commit_range(project, commit0, commit1) ⇒ Object
- #link_to_commit_range_for_deploy(deploy) ⇒ Object
- #link_to_err(project, err) ⇒ Object
- #link_to_release_commit_range(release) ⇒ Object
Instance Method Details
#format_commit(commit) ⇒ Object
3 4 5 6 7 8 |
# File 'app/helpers/commit_helper.rb', line 3 def format_commit(commit) = commit.summary = format_with_tickets_linked(commit.project, ) = mdown() end |
#format_sha(sha) ⇒ Object
37 38 39 40 |
# File 'app/helpers/commit_helper.rb', line 37 def format_sha(sha) return "_"*8 if sha.blank? sha[0...7] end |
#format_with_tickets_linked(project, message) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/commit_helper.rb', line 42 def format_with_tickets_linked(project, ) = h() .gsub! Commit::TICKET_PATTERN do |match| ticket_number = Commit::TICKET_PATTERN.match(match)[1] link_to match, project.ticket_tracker_ticket_url(ticket_number), "target" => "_blank", "rel" => "ticket", "data-number" => ticket_number end .gsub! Commit::EXTRA_ATTRIBUTE_PATTERN do |match| key, value = match.scan(Commit::EXTRA_ATTRIBUTE_PATTERN).first link_to_err(project, value) if key == "err" end .html_safe end |
#link_to_commit(commit, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/commit_helper.rb', line 10 def link_to_commit(commit, ={}) return nil if commit.nil? project = commit.project content = block_given? ? yield : "<span class=\"commit-sha\">#{commit.sha[0...7]}</span>".html_safe return content unless github_url?(project) link_to content, github_commit_url(project, commit.sha), .reverse_merge(target: "_blank") end |
#link_to_commit_range(project, commit0, commit1) ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/helpers/commit_helper.rb', line 29 def link_to_commit_range(project, commit0, commit1) range = "#{format_sha(commit0)}<span class=\"ellipsis\">...</span>#{format_sha(commit1)}".html_safe return range unless github_url?(project) return range if commit0.blank? or commit1.blank? link_to range, github_commit_range_url(project, commit0, commit1), target: "_blank", title: "Compare" end |
#link_to_commit_range_for_deploy(deploy) ⇒ Object
25 26 27 |
# File 'app/helpers/commit_helper.rb', line 25 def link_to_commit_range_for_deploy(deploy) link_to_commit_range deploy.project, deploy.previous_deploy.try(:sha), deploy.sha end |
#link_to_err(project, err) ⇒ Object
58 59 60 61 62 |
# File 'app/helpers/commit_helper.rb', line 58 def link_to_err(project, err) link_to project.error_tracker_error_url(err), "target" => "_blank" do (image_tag(image_url("bug-fixed-32.png"), "data-tooltip-placement" => "right", rel: "tooltip", title: "View Exception in Errbit", width: 16, height: 16) + err).html_safe end end |
#link_to_release_commit_range(release) ⇒ Object
20 21 22 23 |
# File 'app/helpers/commit_helper.rb', line 20 def link_to_release_commit_range(release) return "" if release.commit0.blank? && release.commit1.blank? link_to_commit_range(release.project, release.commit0, release.commit1) end |