summaryrefslogtreecommitdiff
path: root/lib/gitlab
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2019-07-25 17:01:17 -0500
committerNick Thomas <nick@gitlab.com>2019-07-26 11:05:56 +0100
commitcfef1e8e99c275386d3680b90e95ba0cdf137f7c (patch)
treee132592be1abb1f6bdf953296cc77a6c1f679fbd /lib/gitlab
parent57aabe16b73890d798ab86dccb3a845aa25d5232 (diff)
downloadgitlab-ce-cfef1e8e99c275386d3680b90e95ba0cdf137f7c.tar.gz
Fix error rendering submodules in MR diffs when there is no .gitmodulesdm-submodule-links-nil
Without this change, we get a NoMethodError on nil
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/submodule_links.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/gitlab/submodule_links.rb b/lib/gitlab/submodule_links.rb
index a6c0369d864..18fd604a3b0 100644
--- a/lib/gitlab/submodule_links.rb
+++ b/lib/gitlab/submodule_links.rb
@@ -9,7 +9,7 @@ module Gitlab
end
def for(submodule, sha)
- submodule_url = submodule_url_for(sha)[submodule.path]
+ submodule_url = submodule_url_for(sha, submodule.path)
SubmoduleHelper.submodule_links_for_url(submodule.id, submodule_url, repository)
end
@@ -17,10 +17,15 @@ module Gitlab
attr_reader :repository
- def submodule_url_for(sha)
- strong_memoize(:"submodule_links_for_#{sha}") do
+ def submodule_urls_for(sha)
+ strong_memoize(:"submodule_urls_for_#{sha}") do
repository.submodule_urls_for(sha)
end
end
+
+ def submodule_url_for(sha, path)
+ urls = submodule_urls_for(sha)
+ urls && urls[path]
+ end
end
end