Skip to content

Commit

Permalink
Merge pull request #10233 from hirasawayuki/fix_inherit_from_remote
Browse files Browse the repository at this point in the history
[Fix #10174] Fix inherit_from_remote should follow remote includes path starting with `./`
  • Loading branch information
koic committed Nov 10, 2021
2 parents 0a80ac5 + 60e6f47 commit fa295f0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
@@ -0,0 +1 @@
* [#10174](https://github.com/rubocop/rubocop/issues/10174): Fix inherit_from_remote should follow remote includes path starting with `./`. ([@hirasawayuki][])
2 changes: 1 addition & 1 deletion lib/rubocop/remote_config.rb
Expand Up @@ -33,7 +33,7 @@ def file

def inherit_from_remote(file, path)
new_uri = @uri.dup
new_uri.path.gsub!(%r{/[^/]*$}, "/#{file}")
new_uri.path.gsub!(%r{/[^/]*$}, "/#{file.delete_prefix('./')}")
RemoteConfig.new(new_uri.to_s, File.dirname(path))
end

Expand Down
13 changes: 13 additions & 0 deletions spec/rubocop/remote_config_spec.rb
Expand Up @@ -189,4 +189,17 @@
end
end
end

describe '.inherit_from_remote' do
context 'when the remote includes file starting with `./`' do
let(:includes_file) { './base.yml' }

it 'returns remote includes URI' do
remote_config = described_class.new(remote_config_url, base_dir)
includes_config = remote_config.inherit_from_remote(includes_file, remote_config_url)

expect(includes_config.uri).to eq URI.parse('http://example.com/base.yml')
end
end
end
end

0 comments on commit fa295f0

Please sign in to comment.