summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-05-31 11:19:56 -0500
committerDouwe Maan <douwe@selenight.nl>2017-05-31 11:19:56 -0500
commitea7269e4c66a51eb4c66b9022ba4c2b35d8ad012 (patch)
tree3157bd820270d37619ae290b028e915673f5eceb
parent0c7dd30c78043ea3d4629e1e5739ccfcc7d968fe (diff)
downloadgitlab-ce-ea7269e4c66a51eb4c66b9022ba4c2b35d8ad012.tar.gz
Remove entry variabledm-gitmodules-parsing
-rw-r--r--lib/gitlab/git/repository.rb19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index c3bf32ca1cc..9d6adbdb4ac 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -1006,40 +1006,39 @@ module Gitlab
# Parses the contents of a .gitmodules file and returns a hash of
# submodule information.
def parse_gitmodules(commit, content)
- results = {}
+ modules = {}
name = nil
- entry = nil
content.each_line do |line|
case line.strip
when /\A\[submodule "(?<name>[^"]+)"\]\z/ # Submodule header
name = $~[:name]
- entry = results[name] = {}
+ modules[name] = {}
when /\A(?<key>\w+)\s*=\s*(?<value>.*)\z/ # Key/value pair
key = $~[:key]
value = $~[:value].chomp
- next unless name && entry
+ next unless name && modules[name]
- entry[key] = value
+ modules[name][key] = value
if key == 'path'
begin
- entry['id'] = blob_content(commit, value)
+ modules[name]['id'] = blob_content(commit, value)
rescue InvalidBlobName
# The current entry is invalid
- results.delete(name)
- name = entry = nil
+ modules.delete(name)
+ name = nil
end
end
when /\A#/ # Comment
next
else # Invalid line
- name = entry = nil
+ name = nil
end
end
- results
+ modules
end
# Returns true if +commit+ introduced changes to +path+, using commit