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 @@ $ -> ...@@ -123,6 +123,10 @@ $ ->
$(@).next('table').show() $(@).next('table').show()
$(@).remove() $(@).remove()
$(".content").on "click", ".js-details-expand", ->
$(@).next('.js-details-contain').removeClass("hide")
$(@).remove()
(($) -> (($) ->
_chosen = $.fn.chosen _chosen = $.fn.chosen
$.fn.extend chosen: (options) -> $.fn.extend chosen: (options) ->
......
...@@ -18,6 +18,7 @@ class CommitLoadContext < BaseContext ...@@ -18,6 +18,7 @@ class CommitLoadContext < BaseContext
result[:note] = project.build_commit_note(commit) result[:note] = project.build_commit_note(commit)
result[:line_notes] = line_notes result[:line_notes] = line_notes
result[:notes_count] = project.notes.for_commit_id(commit.id).count result[:notes_count] = project.notes.for_commit_id(commit.id).count
result[:branches] = project.repository.branch_names_contains(commit.id)
begin begin
result[:suppress_diff] = true if commit.diff_suppress? && !params[:force_show_diff] result[:suppress_diff] = true if commit.diff_suppress? && !params[:force_show_diff]
......
...@@ -22,6 +22,7 @@ class Projects::CommitController < Projects::ApplicationController ...@@ -22,6 +22,7 @@ class Projects::CommitController < Projects::ApplicationController
@note = result[:note] @note = result[:note]
@line_notes = result[:line_notes] @line_notes = result[:line_notes]
@branches = result[:branches]
@notes_count = result[:notes_count] @notes_count = result[:notes_count]
@target_type = :commit @target_type = :commit
@target_id = @commit.id @target_id = @commit.id
......
...@@ -94,6 +94,17 @@ module CommitsHelper ...@@ -94,6 +94,17 @@ module CommitsHelper
crumbs.html_safe crumbs.html_safe
end 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 protected
# Private: Returns a link to a person. If the person has a matching user and # Private: Returns a link to a person. If the person has a matching user and
......
...@@ -39,6 +39,18 @@ ...@@ -39,6 +39,18 @@
- @commit.parents.each do |parent| - @commit.parents.each do |parent|
= link_to parent.id[0...10], project_commit_path(@project, 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 .commit-box
%h3.commit-title %h3.commit-title
= gfm escape_once(@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