diff options
author | Sean McGivern <sean@gitlab.com> | 2017-10-11 16:47:03 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-10-12 11:13:37 +0100 |
commit | 218e1f0963768fced0ed9a33762253c273c72069 (patch) | |
tree | 6ae59ba891b8291400820ec5cbd2f27b8b9cbc48 /lib/gitlab/file_detector.rb | |
parent | 90f95f2b8c25225bbd5601f9b8412931685d4bc0 (diff) | |
download | gitlab-ce-218e1f0963768fced0ed9a33762253c273c72069.tar.gz |
Match full file path in FileDetector
The basename appears to have been a holdover from the past - it doesn't look
necessary now. Some of the regexes were unanchored on one side, so explicitly
ensure that they only match the root.
Apart from that, this means that pushing to foo/README.md will no longer
invalidate the main README cache for a project.
Diffstat (limited to 'lib/gitlab/file_detector.rb')
-rw-r--r-- | lib/gitlab/file_detector.rb | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/gitlab/file_detector.rb b/lib/gitlab/file_detector.rb index a8cb7fc3fe7..1fa1399c531 100644 --- a/lib/gitlab/file_detector.rb +++ b/lib/gitlab/file_detector.rb @@ -6,10 +6,10 @@ module Gitlab module FileDetector PATTERNS = { # Project files - readme: /\Areadme/i, - changelog: /\A(changelog|history|changes|news)/i, - license: /\A(licen[sc]e|copying)(\..+|\z)/i, - contributing: /\Acontributing/i, + readme: /\Areadme[^\/]*\z/i, + changelog: /\A(changelog|history|changes|news)[^\/]*\z/i, + license: /\A(licen[sc]e|copying)(\.[^\/]+)?\z/i, + contributing: /\Acontributing[^\/]*\z/i, version: 'version', avatar: /\Alogo\.(png|jpg|gif)\z/, @@ -17,20 +17,20 @@ module Gitlab gitignore: '.gitignore', koding: '.koding.yml', gitlab_ci: '.gitlab-ci.yml', - route_map: 'route-map.yml', + route_map: '.gitlab/route-map.yml', # Dependency files - cartfile: /\ACartfile/, + cartfile: /\ACartfile[^\/]*\z/, composer_json: 'composer.json', gemfile: /\A(Gemfile|gems\.rb)\z/, gemfile_lock: 'Gemfile.lock', - gemspec: /\.gemspec\z/, + gemspec: /\A[^\/]*\.gemspec\z/, godeps_json: 'Godeps.json', package_json: 'package.json', podfile: 'Podfile', - podspec_json: /\.podspec\.json\z/, - podspec: /\.podspec\z/, - requirements_txt: /requirements\.txt\z/, + podspec_json: /\A[^\/]*\.podspec\.json\z/, + podspec: /\A[^\/]*\.podspec\z/, + requirements_txt: /\A[^\/]*requirements\.txt\z/, yarn_lock: 'yarn.lock' }.freeze @@ -63,13 +63,11 @@ module Gitlab # type_of('README.md') # => :readme # type_of('VERSION') # => :version def self.type_of(path) - name = File.basename(path) - PATTERNS.each do |type, search| did_match = if search.is_a?(Regexp) - name =~ search + path =~ search else - name.casecmp(search) == 0 + path.casecmp(search) == 0 end return type if did_match |