fixed missing features
This commit is contained in:
@@ -30,20 +30,16 @@ interface GitProviderClient
|
||||
* @return array<int, GitBranch>
|
||||
*/
|
||||
public function listBranches(
|
||||
string $baseUrl,
|
||||
string $token,
|
||||
string $owner,
|
||||
string $repository,
|
||||
GitRepository $repository,
|
||||
): array;
|
||||
|
||||
/**
|
||||
* @return array<int, GitPullRequest>
|
||||
*/
|
||||
public function listPullRequests(
|
||||
string $baseUrl,
|
||||
string $token,
|
||||
string $owner,
|
||||
string $repository,
|
||||
GitRepository $repository,
|
||||
): array;
|
||||
|
||||
public function createBranch(
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace App\Actions\Git\Data;
|
||||
final readonly class GitRepository
|
||||
{
|
||||
public function __construct(
|
||||
public string $baseUrl,
|
||||
public string $providerRepositoryId,
|
||||
public string $owner,
|
||||
public string $name,
|
||||
|
||||
@@ -55,7 +55,7 @@ class GiteaProviderClient implements GitProviderClient
|
||||
->throw()
|
||||
->json();
|
||||
|
||||
return $this->mapRepository($payload);
|
||||
return $this->mapRepository($payload, $baseUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +85,7 @@ class GiteaProviderClient implements GitProviderClient
|
||||
->json();
|
||||
|
||||
foreach ($payload as $repository) {
|
||||
$repositories[] = $this->mapRepository($repository);
|
||||
$repositories[] = $this->mapRepository($repository, $baseUrl);
|
||||
}
|
||||
|
||||
$page++;
|
||||
@@ -98,19 +98,17 @@ class GiteaProviderClient implements GitProviderClient
|
||||
* @return array<int, GitBranch>
|
||||
*/
|
||||
public function listBranches(
|
||||
string $baseUrl,
|
||||
string $token,
|
||||
string $owner,
|
||||
string $repository,
|
||||
GitRepository $repository,
|
||||
): array {
|
||||
$page = 1;
|
||||
$branches = [];
|
||||
|
||||
do {
|
||||
/** @var array<int, array{name: string}> $payload */
|
||||
$payload = $this->request($baseUrl, $token)
|
||||
$payload = $this->request($repository->baseUrl, $token)
|
||||
->get(
|
||||
'/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/branches',
|
||||
'/repos/'.rawurlencode($repository->owner).'/'.rawurlencode($repository->name).'/branches',
|
||||
[
|
||||
'limit' => 100,
|
||||
'page' => $page,
|
||||
@@ -135,10 +133,8 @@ class GiteaProviderClient implements GitProviderClient
|
||||
* @return array<int, GitPullRequest>
|
||||
*/
|
||||
public function listPullRequests(
|
||||
string $baseUrl,
|
||||
string $token,
|
||||
string $owner,
|
||||
string $repository,
|
||||
GitRepository $repository,
|
||||
): array {
|
||||
$page = 1;
|
||||
$pullRequests = [];
|
||||
@@ -153,9 +149,9 @@ class GiteaProviderClient implements GitProviderClient
|
||||
* head: array{ref: string}
|
||||
* }> $payload
|
||||
*/
|
||||
$payload = $this->request($baseUrl, $token)
|
||||
$payload = $this->request($repository->baseUrl, $token)
|
||||
->get(
|
||||
'/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/pulls',
|
||||
'/repos/'.rawurlencode($repository->owner).'/'.rawurlencode($repository->name).'/pulls',
|
||||
[
|
||||
'limit' => 100,
|
||||
'page' => $page,
|
||||
@@ -248,9 +244,10 @@ class GiteaProviderClient implements GitProviderClient
|
||||
* private: bool
|
||||
* } $repository
|
||||
*/
|
||||
private function mapRepository(array $repository): GitRepository
|
||||
private function mapRepository(array $repository, string $baseUrl): GitRepository
|
||||
{
|
||||
return new GitRepository(
|
||||
baseUrl: $baseUrl,
|
||||
providerRepositoryId: (string) $repository['id'],
|
||||
owner: $repository['owner']['login'],
|
||||
name: $repository['name'],
|
||||
|
||||
@@ -66,10 +66,8 @@ class ResolveTicketBranchMatches
|
||||
$this->gitProviderManager
|
||||
->client($userGitConnection->provider)
|
||||
->listBranches(
|
||||
$userGitConnection->base_url,
|
||||
$userGitConnection->api_token,
|
||||
$repositoryConnection->owner_name,
|
||||
$repositoryConnection->repository_name,
|
||||
$repositoryConnection->toGitRepository(),
|
||||
),
|
||||
)
|
||||
->filter(fn (GitBranch $branch): bool => $this->ticketKeyReferenceMatcher->matches(
|
||||
@@ -85,7 +83,7 @@ class ResolveTicketBranchMatches
|
||||
$error = null;
|
||||
} catch (Throwable) {
|
||||
$branches = [];
|
||||
$error = 'KanbanGit could not load branches from this repository right now.';
|
||||
$error = ((string) config('app.name')).' could not load branches from this repository right now.';
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
@@ -72,10 +72,8 @@ class ResolveTicketPullRequestMatches
|
||||
$this->gitProviderManager
|
||||
->client($userGitConnection->provider)
|
||||
->listPullRequests(
|
||||
$userGitConnection->base_url,
|
||||
$userGitConnection->api_token,
|
||||
$repositoryConnection->owner_name,
|
||||
$repositoryConnection->repository_name,
|
||||
$repositoryConnection->toGitRepository(),
|
||||
),
|
||||
)
|
||||
->filter(fn (GitPullRequest $pullRequest): bool => $this->ticketKeyReferenceMatcher->matches(
|
||||
@@ -94,7 +92,7 @@ class ResolveTicketPullRequestMatches
|
||||
|
||||
$error = null;
|
||||
} catch (Throwable) {
|
||||
$error = 'KanbanGit could not load pull requests from this repository right now.';
|
||||
$error = ((string) config('app.name')).' could not load pull requests from this repository right now.';
|
||||
$pullRequests = [];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user