summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-21 11:53:09 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-21 11:53:09 -0800
commite5d491b7c702a7996190f85f94563252c5ca8fdb (patch)
tree0bdf73172d077482fb6558064cd1bf842fce8096
parent0c4bb8491027cab1306855e32e6bb144792e7e3a (diff)
parent3d2aaa169ea7cfa8d416103c70711a440c716dd9 (diff)
downloadgitlab-ce-e5d491b7c702a7996190f85f94563252c5ca8fdb.tar.gz
Merge pull request #7389 from skv-headless/show-submodules-in-diff
show diff in submodules
-rw-r--r--app/helpers/diff_helper.rb15
-rw-r--r--app/helpers/submodule_helper.rb4
-rw-r--r--app/views/projects/diffs/_file.html.haml3
-rw-r--r--app/views/projects/tree/_submodule_item.html.haml10
4 files changed, 21 insertions, 11 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index a15af0be01a..8c921cba543 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -135,4 +135,19 @@ module DiffHelper
'Side-by-side'
end
end
+
+ def submodule_link(blob, ref)
+ tree, commit = submodule_links(blob, ref)
+ commit_id = if commit.nil?
+ blob.id[0..10]
+ else
+ link_to "#{blob.id[0..10]}", commit
+ end
+
+ [
+ content_tag(:span, link_to(truncate(blob.name, length: 40), tree)),
+ '@',
+ content_tag(:span, commit_id, class: 'monospace'),
+ ].join(' ').html_safe
+ end
end
diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb
index 09e5c08e621..841e7fd17f6 100644
--- a/app/helpers/submodule_helper.rb
+++ b/app/helpers/submodule_helper.rb
@@ -2,8 +2,8 @@ module SubmoduleHelper
include Gitlab::ShellAdapter
# links to files listing for submodule if submodule is a project on this server
- def submodule_links(submodule_item)
- url = @repository.submodule_url_for(@ref, submodule_item.path)
+ def submodule_links(submodule_item, ref = nil)
+ url = @repository.submodule_url_for(ref, submodule_item.path)
return url, nil unless url =~ /([^\/:]+\/[^\/]+\.git)\Z/
diff --git a/app/views/projects/diffs/_file.html.haml b/app/views/projects/diffs/_file.html.haml
index 34d13502231..8d080f710d8 100644
--- a/app/views/projects/diffs/_file.html.haml
+++ b/app/views/projects/diffs/_file.html.haml
@@ -9,6 +9,9 @@
.diff-btn-group
- if @commit.parent_ids.present?
= view_file_btn(@commit.parent_id, diff_file, project)
+ - elsif diff_file.diff.submodule?
+ - submodule_item = project.repository.blob_at(@commit.id, diff_file.file_path)
+ = submodule_link(submodule_item, @commit.id)
- else
- if diff_file.renamed_file
%span= "#{diff_file.old_path} renamed to #{diff_file.new_path}"
diff --git a/app/views/projects/tree/_submodule_item.html.haml b/app/views/projects/tree/_submodule_item.html.haml
index 46e9be4af83..20c70cac699 100644
--- a/app/views/projects/tree/_submodule_item.html.haml
+++ b/app/views/projects/tree/_submodule_item.html.haml
@@ -1,14 +1,6 @@
-- tree, commit = submodule_links(submodule_item)
%tr{ class: "tree-item" }
%td.tree-item-file-name
%i.fa.fa-archive
- %span
- = link_to truncate(submodule_item.name, length: 40), tree
- @
- %span.monospace
- - if commit.nil?
- #{truncate_sha(submodule_item.id)}
- - else
- = link_to "#{truncate_sha(submodule_item.id)}", commit
+ = submodule_link(submodule_item, @ref)
%td
%td.hidden-xs