Ignore invalid lines in .gitmodules
Replaces !23 (closed)
A .gitmodules file that had any trailing lines (e.g. comments, tabs, etc.) after a valid submodule definition would cause 500 Errors in GitLab:
ActionView::Template::Error (undefined method `[]' for nil:NilClass): 11: = view_file_btn(@commit.parent_id, diff_file, project) 12: - elsif diff_file.diff.submodule? 13: - submodule_item = project.repository.blob_at(@commit.id, diff_file.file_path) 14: = submodule_link(submodule_item, @commit.id) 15: - else 16: - if diff_file.renamed_file 17: %span= "#{diff_file.old_path} renamed to #{diff_file.new_path}" app/models/repository.rb:170:in `method_missing' app/models/repository.rb:232:in `submodule_url_for' app/helpers/submodule_helper.rb:6:in `submodule_links`
I tried writing a test for it, but writing and committing to a .gitmodules file seemed unnecessarily painful in the unit tests. It would be easier just to add comments to the end of the existing .gitmodules file. I'll send a separate MR for that.
- Closes gitlab-org/gitlab-ce#1412
- https://github.com/gitlabhq/gitlabhq/issues/8135
- https://github.com/gitlabhq/gitlabhq/issues/8881 (for real)