Commit ea7269e4 authored by Douwe Maan's avatar Douwe Maan

Remove entry variable

parent 0c7dd30c
...@@ -1006,40 +1006,39 @@ module Gitlab ...@@ -1006,40 +1006,39 @@ module Gitlab
# Parses the contents of a .gitmodules file and returns a hash of # Parses the contents of a .gitmodules file and returns a hash of
# submodule information. # submodule information.
def parse_gitmodules(commit, content) def parse_gitmodules(commit, content)
results = {} modules = {}
name = nil name = nil
entry = nil
content.each_line do |line| content.each_line do |line|
case line.strip case line.strip
when /\A\[submodule "(?<name>[^"]+)"\]\z/ # Submodule header when /\A\[submodule "(?<name>[^"]+)"\]\z/ # Submodule header
name = $~[:name] name = $~[:name]
entry = results[name] = {} modules[name] = {}
when /\A(?<key>\w+)\s*=\s*(?<value>.*)\z/ # Key/value pair when /\A(?<key>\w+)\s*=\s*(?<value>.*)\z/ # Key/value pair
key = $~[:key] key = $~[:key]
value = $~[:value].chomp value = $~[:value].chomp
next unless name && entry next unless name && modules[name]
entry[key] = value modules[name][key] = value
if key == 'path' if key == 'path'
begin begin
entry['id'] = blob_content(commit, value) modules[name]['id'] = blob_content(commit, value)
rescue InvalidBlobName rescue InvalidBlobName
# The current entry is invalid # The current entry is invalid
results.delete(name) modules.delete(name)
name = entry = nil name = nil
end end
end end
when /\A#/ # Comment when /\A#/ # Comment
next next
else # Invalid line else # Invalid line
name = entry = nil name = nil
end end
end end
results modules
end end
# Returns true if +commit+ introduced changes to +path+, using commit # Returns true if +commit+ introduced changes to +path+, using commit
......
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