Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Github/GithubProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public function getDefaultBranch(): ?string
return $this->rawMetadata['default_branch'];
}

public function isArchived(): bool
{
return $this->rawMetadata['archived'];
}

public function getHttpUrl(): string
{
return $this->rawMetadata['clone_url'];
Expand Down
5 changes: 5 additions & 0 deletions src/Gitlab/GitlabProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public function getHttpUrl(): string
return $this->rawMetadata['http_url_to_repo'];
}

public function isArchived(): bool
{
return $this->rawMetadata['archived'];
}

public function getRawMetadata(): array
{
return $this->rawMetadata;
Expand Down
5 changes: 5 additions & 0 deletions src/Gogs/GogsProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public function getHttpUrl(): string
return $this->rawMetadata['clone_url'];
}

public function isArchived(): bool
{
return $this->rawMetadata['archived'];
}

public function getRawMetadata(): array
{
return $this->rawMetadata;
Expand Down
5 changes: 5 additions & 0 deletions src/Local/LocalProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public function getHttpUrl(): string
return $this->rawMetadata['full_path'];
}

public function isArchived(): bool
{
return false; // Always returns false for LocalClient
}

public function getRawMetadata(): array
{
return $this->rawMetadata;
Expand Down
7 changes: 7 additions & 0 deletions src/ProjectInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ public function getDefaultBranch(): ?string;
*/
public function getHttpUrl(): string;

/**
* True if the project is archived.
*
* @warning This method will always return false for LocalClient.
*/
public function isArchived(): bool;

/**
* Get hosting service specific properties.
*
Expand Down
7 changes: 7 additions & 0 deletions tests/GithubClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public function testUserAndOrgsRepositories(): void

$project = $projectsByName['mborne/satis-gitlab'];
$defaultBranch = $project->getDefaultBranch();

/* test getDefaultBranch */
$this->assertNotNull($defaultBranch);

/* test getRawFile */
$composer = $client->getRawFile(
$project,
'composer.json',
Expand All @@ -88,6 +92,9 @@ public function testUserAndOrgsRepositories(): void

/* test getRawFile not found */
$this->ensureThatRawFileNotFoundThrowsException($client, $project);

/* test isArchived */
$this->assertFalse($project->isArchived());
}

/**
Expand Down
12 changes: 11 additions & 1 deletion tests/GitlabClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ public function testGitlabDotComByUser(): void
);

$project = $projectsByName['mborne/sample-composer'];
/* test getDefaultBranch */
$defaultBranch = $project->getDefaultBranch();
$this->assertNotNull($defaultBranch);
/* test getRawFile */
$composer = $client->getRawFile(
$project,
'composer.json',
$defaultBranch
);
$this->assertStringContainsString('mborne@users.noreply.github.com', $composer);
/* test isArchived */
$this->assertFalse($project->isArchived());
}

public function testGitlabDotComOrgs(): void
Expand Down Expand Up @@ -117,10 +121,13 @@ public function testGitlabDotComSearch(): void
$projectsByName
);

/* test getRawFile */
$project = $projectsByName['mborne/sample-composer'];

/* test getDefaultBranch */
$defaultBranch = $project->getDefaultBranch();
$this->assertNotNull($defaultBranch);

/* test getRawFile */
$composer = $client->getRawFile(
$project,
'composer.json',
Expand All @@ -130,5 +137,8 @@ public function testGitlabDotComSearch(): void

/* test getRawFile not found */
$this->ensureThatRawFileNotFoundThrowsException($client, $project);

/* test isArchived */
$this->assertFalse($project->isArchived());
}
}
5 changes: 5 additions & 0 deletions tests/GogsClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public function testFindByUserAndOrgs(): void
'docker/docker-php-sury',
$projectsByName
);

/* test getRawFile */
$project = $projectsByName['docker/docker-php-sury'];
$this->assertStringContainsString(
'FROM ',
Expand All @@ -120,5 +122,8 @@ public function testFindByUserAndOrgs(): void
'ServerTokens Prod',
$client->getRawFile($project, 'conf/apache-security.conf', 'master')
);

/* test isArchived */
$this->assertFalse($project->isArchived());
}
}
11 changes: 11 additions & 0 deletions tests/LocalClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ public function testFindAll(): void
);
}

/**
* Ensure that isArchived returns false.
*/
public function testIsArchived(): void
{
$projects = $this->findAllProjects();
foreach ($projects as $project) {
$this->assertFalse($project->isArchived());
}
}

/**
* Check that raw file content can be retreived from non bare repository.
*/
Expand Down