Skip to content

Commit bd69154

Browse files
committed
Remove duplicated isGitHubUrl helper and dead BASE_URI constant
The GitHub class had its own private isGitHubUrl() that was identical to RepositoryUtils::is_github_url(). This consolidates to the single utility method and make it public.
1 parent 7993410 commit bd69154

2 files changed

Lines changed: 3 additions & 17 deletions

File tree

app/Utils/RepositoryUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class RepositoryUtils
1616
{
17-
private static function is_github_url(string $url): bool
17+
public static function is_github_url(string $url): bool
1818
{
1919
if (str_contains($url, 'github.com')) {
2020
return true;

app/cdash/app/Lib/Repository/GitHub.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
use App\Models\BuildUpdateFile;
2121
use App\Models\PendingSubmissions;
22+
use App\Utils\RepositoryUtils;
2223
use CDash\Database;
2324
use CDash\Model\Build;
2425
use CDash\Model\BuildUpdate;
@@ -44,8 +45,6 @@
4445
*/
4546
class GitHub implements RepositoryInterface
4647
{
47-
public const BASE_URI = 'https://api.github.com';
48-
4948
private string $installationId = '';
5049
private string $owner = '';
5150
private string $repo = '';
@@ -76,7 +75,7 @@ public function __construct(Project $project)
7675

7776
$repositories = $this->project->GetRepositories();
7877
foreach ($repositories as $repo) {
79-
if ($this->isGitHubUrl($repo['url'])) {
78+
if (RepositoryUtils::is_github_url($repo['url'])) {
8079
$this->installationId = $repo['username'];
8180
break;
8281
}
@@ -663,19 +662,6 @@ public function getRepository(): string
663662
return $this->repo;
664663
}
665664

666-
private function isGitHubUrl(string $url): bool
667-
{
668-
if (str_contains($url, 'github.com')) {
669-
return true;
670-
}
671-
$enterpriseUrl = config('cdash.github_enterprise_url');
672-
if ($enterpriseUrl !== null) {
673-
$host = parse_url($enterpriseUrl, PHP_URL_HOST);
674-
return is_string($host) && str_contains($url, $host);
675-
}
676-
return false;
677-
}
678-
679665
protected function getRepositoryInformation(): void
680666
{
681667
$url = str_replace('//', '', $this->project->CvsUrl ?? '');

0 commit comments

Comments
 (0)