Commit 6173d0a9 authored by Andrey Kumanyaev's avatar Andrey Kumanyaev

Show branches list (which branches contains commit) on commit page

parent 57173040
......@@ -123,6 +123,10 @@ $ ->
$(@).next('table').show()
$(@).remove()
$(".content").on "click", ".js-details-expand", ->
$(@).next('.js-details-contain').removeClass("hide")
$(@).remove()
(($) ->
_chosen = $.fn.chosen
$.fn.extend chosen: (options) ->
......
......@@ -18,6 +18,7 @@ class CommitLoadContext < BaseContext
result[:note] = project.build_commit_note(commit)
result[:line_notes] = line_notes
result[:notes_count] = project.notes.for_commit_id(commit.id).count
result[:branches] = project.repository.branch_names_contains(commit.id)
begin
result[:suppress_diff] = true if commit.diff_suppress? && !params[:force_show_diff]
......
......@@ -22,6 +22,7 @@ class Projects::CommitController < Projects::ApplicationController
@note = result[:note]
@line_notes = result[:line_notes]
@branches = result[:branches]
@notes_count = result[:notes_count]
@target_type = :commit
@target_id = @commit.id
......
......@@ -94,6 +94,17 @@ module CommitsHelper
crumbs.html_safe
end
# Return Project default branch, if it present in array
# Else - first branch in array (mb last actual branch)
def commit_default_branch(project, branches)
branches.include?(project.default_branch) ? branches.delete(project.default_branch) : branches.pop
end
# Returns the sorted alphabetically links to branches, separated by a comma
def commit_branches_links(project, branches)
branches.sort.map { |branch| link_to(branch, project_tree_path(project, branch)) }.join(", ").html_safe
end
protected
# Private: Returns a link to a person. If the person has a matching user and
......
......@@ -39,6 +39,18 @@
- @commit.parents.each do |parent|
= link_to parent.id[0...10], project_commit_path(@project, parent)
.commit-info-row
%span.cgray
Exists in
%span
- branch = commit_default_branch(@project, @branches)
= link_to(branch, project_tree_path(@project, branch))
- if @branches.any?
and in
= link_to("#{pluralize(@branches.count, "other branch")}", "#", class: "js-details-expand")
%span.js-details-contain.hide
= commit_branches_links(@project, @branches)
.commit-box
%h3.commit-title
= gfm escape_once(@commit.title)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment