Skip to content

Commit

Permalink
[Fix rubocop#10174] Fix inherit_from_remote should follow remote incl…
Browse files Browse the repository at this point in the history
…udes path starting with `./`
  • Loading branch information
hirasawayuki committed Nov 10, 2021
1 parent e496846 commit 60e6f47
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 60e6f47

Please sign in to comment.