Skip to content

Commit

Permalink
Update getDomain method in ProviderConfig to support local repositori…
Browse files Browse the repository at this point in the history
…es - #1492 (#1624)

Signed-off-by: Emilio Palumbo <emiliopalumbo@gmail.com>
  • Loading branch information
emi80 committed Jun 12, 2020
1 parent 28e8c5a commit 651501a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
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
}

Expand Down
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

0 comments on commit 651501a

Please sign in to comment.