diff options
author | Nick Thomas <nick@gitlab.com> | 2019-07-26 11:27:00 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-07-26 11:27:00 +0000 |
commit | 55f99e930e1c147ec191a234ff4881ea7e70ea61 (patch) | |
tree | a9010c7ad25b30aba3670a9bc662a44c00184e25 /lib | |
parent | 08f5ea0544f03159980659697d736b6c54f02180 (diff) | |
parent | cfef1e8e99c275386d3680b90e95ba0cdf137f7c (diff) | |
download | gitlab-ce-55f99e930e1c147ec191a234ff4881ea7e70ea61.tar.gz |
Merge branch 'dm-submodule-links-nil' into 'master'
Fix error rendering submodules in MR diffs when there is no .gitmodules
See merge request gitlab-org/gitlab-ce!31162
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/submodule_links.rb | 11 |
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 |