summaryrefslogtreecommitdiff
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-01-29 15:31:53 -0600
committerDouwe Maan <douwe@selenight.nl>2017-02-06 16:12:24 -0600
commit8f85a11d9fcc1f4ccde7c46652f0be00edf46a78 (patch)
tree0b6034594c5994259b7ecfd16e294f767eec2043 /app/models/project.rb
parent5bf22606efa37f88a0f440205ff013d20227bd5e (diff)
downloadgitlab-ce-8f85a11d9fcc1f4ccde7c46652f0be00edf46a78.tar.gz
Validate route map
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb17
1 files changed, 5 insertions, 12 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index ad22ab7577e..42a79557136 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1312,7 +1312,7 @@ class Project < ActiveRecord::Base
deployments_query = with_tags ? 'ref = ? OR tag IS TRUE' : 'ref = ?'
deployments.where(deployments_query, ref.to_s)
elsif commit
- deps = deployments.where(sha: commit.sha)
+ deployments.where(sha: commit.sha)
else
Deployment.none
end
@@ -1348,13 +1348,9 @@ class Project < ActiveRecord::Base
data = repository.route_map_file(sha)
next unless data
- # TODO: Validate
- YAML.safe_load(data).map do |mapping|
- {
- source: Regexp.new("^#{mapping['source'][1...-1]}$"),
- public: mapping['public']
- }
- end
+ Gitlab::RouteMap.new(data)
+ rescue Gitlab::RouteMap::FormatError
+ nil
end
end
@@ -1365,10 +1361,7 @@ class Project < ActiveRecord::Base
map = route_map_for_commit(commit_sha)
return unless map
- mapping = map.find { |mapping| path =~ mapping[:source] }
- return unless mapping
-
- path.sub(mapping[:source], mapping[:public])
+ map.public_path_for_source_path(path)
end
private