Merge pull request #13476 from appwrite/fix-vcs-comment-urls

fix: honour console URL scheme in VCS commit statuses and authorize link
This commit is contained in:
Matej Bačo authored and GitHub committed 2026-09-07 15:23:54 +02:00
commit 1979c37d9d
2 files changed
+12 -5

No files matched your search

+6 -3
View File
@@ -50,10 +50,13 @@ final class GitAction
default => $status
};
$hostname = System::getEnv('_APP_CONSOLE_DOMAIN', System::getEnv('_APP_DOMAIN', ''));
$hostname = $platform['consoleHostname'] ?? '';
$region = $project->getAttribute('region', 'default');
$segment = $isSite ? "sites/site-{$resource->getId()}" : "functions/function-{$resource->getId()}";
$targetUrl = "{$protocol}://{$hostname}/console/project-{$region}-{$project->getId()}/{$segment}";
$collection = $isSite ? 'sites' : 'functions';
$type = $isSite ? 'site' : 'function';
$targetUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root'
? "{$protocol}://{$hostname}/console/project-{$region}-{$project->getId()}/{$collection}/{$type}-{$resource->getId()}"
: "{$protocol}://{$hostname}/projects/{$project->getId()}/{$collection}/{$resource->getId()}";
$name = $resource->getAttribute('name') . ' (' . $project->getAttribute('name') . ')';
$vcs->updateCommitStatus($repositoryName, $commitHash, $owner, $state, $message, $targetUrl, $name);
@@ -165,7 +165,9 @@ trait Deployment
$protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https';
$hostname = $platform['consoleHostname'] ?? '';
$authorizeUrl = $protocol . '://' . $hostname . "/console/git/authorize-contributor?projectId={$projectId}&installationId={$installationId}&repositoryId={$repositoryId}&providerPullRequestId={$providerPullRequestId}";
$authorizeUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root'
? $protocol . '://' . $hostname . "/console/git/authorize-contributor?projectId={$projectId}&installationId={$installationId}&repositoryId={$repositoryId}&providerPullRequestId={$providerPullRequestId}"
: $protocol . '://' . $hostname . "/git/authorize-contributor?projectId={$projectId}&installationId={$installationId}&repositoryId={$repositoryId}&providerPullRequestId={$providerPullRequestId}";
$action = $isAuthorized ? ['type' => 'logs'] : ['type' => 'authorize', 'url' => $authorizeUrl];
@@ -565,7 +567,9 @@ trait Deployment
}
$owner = $vcs->getOwnerName($providerInstallationId, (int) $providerRepositoryId);
$providerTargetUrl = $protocol . '://' . $hostname . "/console/project-$region-$projectId/$resourceCollection/$resourceType-$resourceId";
$providerTargetUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root'
? $protocol . '://' . $hostname . "/console/project-$region-$projectId/$resourceCollection/$resourceType-$resourceId"
: $protocol . '://' . $hostname . "/projects/$projectId/$resourceCollection/$resourceId";
$vcs->updateCommitStatus($repositoryName, $providerCommitHash, $owner, 'pending', $message, $providerTargetUrl, $name);
}