Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ProviderConfig to support local repositories #1624

Merged
merged 1 commit into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,14 @@ class ProviderConfig {
def p = result.indexOf('://')
if( p != -1 )
result = result.substring(p+3)
// a local file url (e.g. file:///path/to/repo or /path/to/repo)
// so we need to return the full path as the domain
if ( result.startsWith('/') )
return result
// a server url so we look for the domain without subdirectories
p = result.indexOf('/')
if( p != -1 )
result = result.substring(0,p)
result = result.substring(0, p)
return result
pditommaso marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,25 @@ class ProviderConfigTest extends Specification {
def 'should return provider attributes' () {

when:
def config = new ProviderConfig('custom',[platform: 'github', server:'http://local.host'])
def config = new ProviderConfig('local',[platform: 'file', path:'/local/repo'])
then:
config.name == 'local'
config.platform == 'file'
config.domain == '/local/repo'
config.server == null
config.endpoint == null

when:
config = new ProviderConfig('local',[platform: 'file', path:'file:///local/repo'])
then:
config.name == 'local'
config.platform == 'file'
config.domain == '/local/repo'
config.server == null
config.endpoint == null

when:
config = new ProviderConfig('custom',[platform: 'github', server:'http://local.host'])
then:
config.name == 'custom'
config.platform == 'github'
Expand Down