Commit 2395b8f0 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'show_tags_in_commit_view' into 'master'

Show tags in commit view

### What does this MR do?
With this MR you can see the assigned tags for a commit in the commit view.
### Are there points in the code the reviewer needs to double check?
I don't think so. But it would be awesome if the reviewer can tell me how to add a tag to the sample_commit in spec/support/repo_helpers.rb.
Then I can add a test for the new tag_names_contains method as soon as possible :)

### Why was this MR needed?
At the moment if one click on a commit will see details such as: parent commit, amount of additions, deletions, but will not see if this commit has Tag linked to it.
Showing branch, tag details will give better overview about the commit

### What are the relevant issue numbers / Feature requests?
Feature request: http://feedback.gitlab.com/forums/176466-general/suggestions/3962044-show-tags-in-commit-view
### Screenshots
![gitlab_feature_show_tags](https://gitlab.com/uploads/haynes/gitlab-ce/771c1a36bb/gitlab_feature_show_tags.png)

@dblessing Can you take a look at this MR as well please?

See merge request !297
parents 1050f523 8243eb3f
......@@ -14,7 +14,7 @@ v 7.8.0
-
-
-
-
- Show tags in commit view (Hannes Rosenögger)
-
-
-
......
......@@ -12,6 +12,7 @@ class Projects::CommitController < Projects::ApplicationController
@line_notes = @project.notes.for_commit_id(commit.id).inline
@branches = @project.repository.branch_names_contains(commit.id)
@tags = @project.repository.tag_names_contains(commit.id)
@diffs = @commit.diffs
@note = @project.build_commit_note(commit)
@notes_count = @project.notes.for_commit_id(commit.id).count
......
......@@ -65,6 +65,12 @@ module CommitsHelper
branches.sort.map { |branch| link_to(branch, project_tree_path(project, branch)) }.join(", ").html_safe
end
# Returns the sorted links to tags, separated by a comma
def commit_tags_links(project, tags)
sorted = VersionSorter.rsort(tags)
sorted.map { |tag| link_to(tag, project_commits_path(project, project.repository.find_tag(tag).name)) }.join(", ").html_safe
end
def link_to_browse_code(project, commit)
if current_controller?(:projects, :commits)
if @repo.blob_at(commit.id, @path)
......
......@@ -312,4 +312,21 @@ class Repository
[]
end
end
def tag_names_contains(sha)
args = %W(git tag --contains #{sha})
names = Gitlab::Popen.popen(args, path_to_repo).first
if names.respond_to?(:split)
names = names.split("\n").map(&:strip)
names.each do |name|
name.slice! '* '
end
names
else
[]
end
end
end
......@@ -50,6 +50,13 @@
%span.js-details-content.hide
= commit_branches_links(@project, @branches)
- if @tags.any?
.commit-info-row
%span.cgray
Tags:
%span
= commit_tags_links(@project, @tags)
.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