summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/main.js.coffee4
-rw-r--r--app/contexts/commit_load_context.rb1
-rw-r--r--app/controllers/projects/commit_controller.rb1
-rw-r--r--app/helpers/commits_helper.rb11
-rw-r--r--app/views/projects/commit/_commit_box.html.haml12
5 files changed, 29 insertions, 0 deletions
diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee
index 011244a5868..ccd5ad48dbf 100644
--- a/app/assets/javascripts/main.js.coffee
+++ b/app/assets/javascripts/main.js.coffee
@@ -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) ->
diff --git a/app/contexts/commit_load_context.rb b/app/contexts/commit_load_context.rb
index 2930c5b1668..0c684976b64 100644
--- a/app/contexts/commit_load_context.rb
+++ b/app/contexts/commit_load_context.rb
@@ -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]
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index bdc501d73bb..242aa41182d 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -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
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index 7e24cbd3e58..c340eb30be1 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -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
diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml
index 1f493452064..b45847f837e 100644
--- a/app/views/projects/commit/_commit_box.html.haml
+++ b/app/views/projects/commit/_commit_box.html.haml
@@ -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)