Skip to content

Commit

Permalink
Support mysterious versions
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Jan 4, 2021
1 parent fc7f94a commit e6fb407
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/RemoteRepository/SilverStripeRemoteRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getFileUrl($projectVersion, $relativePath, $line)
}
if (isset($packageConfig['versionmap'])) {
$versionMaps = Config::getConfig()['versionmaps'];
$projectVersion = $versionMaps[$packageConfig['versionmap']][(string) $projectVersion];
$projectVersion = $versionMaps[$packageConfig['versionmap']][(string) $projectVersion] ?? $projectVersion;
}
$url = $rootPath . '/blob/' . $this->buildProjectPath($projectVersion, $pathParts[2]);

Expand Down
25 changes: 25 additions & 0 deletions tests/SilverStripeRemoteRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,30 @@ public function testGetRepoUrl()
. 'silverstripe-graphql/blob/master/src/Extensions/IntrospectionProvider.php#L0',
$url
);

$url = $remoteRepo->getFileUrl(
'3',
'silverstripe/graphql/src/Extensions/IntrospectionProvider.php',
0
);

$this->assertSame(
'https://github.com/silverstripe/'
. 'silverstripe-graphql/blob/3/src/Extensions/IntrospectionProvider.php#L0',
$url
);

// A mysterious version did pop out, oh snap
$url = $remoteRepo->getFileUrl(
'foobar',
'silverstripe/graphql/src/Extensions/IntrospectionProvider.php',
0
);

$this->assertSame(
'https://github.com/silverstripe/'
. 'silverstripe-graphql/blob/foobar/src/Extensions/IntrospectionProvider.php#L0',
$url
);
}
}

0 comments on commit e6fb407

Please sign in to comment.