Skip to content

Commit

Permalink
Merge pull request #4 from Jeroeny/update
Browse files Browse the repository at this point in the history
remove deprecations
  • Loading branch information
Jeroeny authored Nov 2, 2019
2 parents 8ae8dea + c7bff70 commit 8ae3117
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 116 deletions.
23 changes: 0 additions & 23 deletions src/Api/MergeRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException;
use Symfony\Component\OptionsResolver\Options;
use const E_USER_DEPRECATED;
use function array_filter;
use function count;
use function is_array;
use function sprintf;
use function trigger_error;

final class MergeRequests extends ApiBase
{
Expand Down Expand Up @@ -167,26 +164,6 @@ public function removeNote(int $projectId, int $mrId, int $noteId)
return $this->delete($this->getProjectPath($projectId, 'merge_requests/' . $this->encodePath((string)$mrId) . '/notes/' . $this->encodePath((string)$noteId)));
}

/**
* @return mixed
*/
public function showComments(int $project_id, int $mr_id)
{
@trigger_error(sprintf('The %s() method is deprecated since version 9.1 and will be removed in 10.0. Use the showNotes() method instead.', __METHOD__), E_USER_DEPRECATED);

return $this->showNotes($project_id, $mr_id);
}

/**
* @return mixed
*/
public function addComment(int $project_id, int $mr_id, string $note)
{
@trigger_error(sprintf('The %s() method is deprecated since version 9.1 and will be removed in 10.0. Use the addNote() method instead.', __METHOD__), E_USER_DEPRECATED);

return $this->addNote($project_id, $mr_id, $note);
}

/**
* @return mixed
*/
Expand Down
75 changes: 0 additions & 75 deletions src/Api/Repositories.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
use DateTimeInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use const E_USER_DEPRECATED;
use function array_map;
use function sprintf;
use function trigger_error;

final class Repositories extends ApiBase
{
Expand Down Expand Up @@ -326,78 +323,6 @@ public function tree(int $project_id, array $params = [])
return $this->get($this->getProjectPath($project_id, 'repository/tree'), $params);
}

/**
* @return mixed
*/
public function blob(int $project_id, string $sha, string $filepath)
{
@trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::getRawFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED);

return $this->client->repositoryFiles()->getRawFile($project_id, $filepath, $sha);
}

/**
* @return mixed
*/
public function getFile(int $project_id, string $file_path, string $ref)
{
@trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::getFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED);

return $this->client->repositoryFiles()->getFile($project_id, $file_path, $ref);
}

/**
* @return mixed
*/
public function createFile(int $project_id, string $file_path, string $content, string $branch, string $commit_message, ?string $encoding = null, ?string $author_email = null, ?string $author_name = null)
{
@trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::createFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED);

return $this->client->repositoryFiles()->createFile($project_id, [
'file_path' => $file_path,
'branch' => $branch,
'content' => $content,
'commit_message' => $commit_message,
'encoding' => $encoding,
'author_email' => $author_email,
'author_name' => $author_name,
]);
}

/**
* @return mixed
*/
public function updateFile(int $project_id, string $file_path, string $content, string $branch, string $commit_message, ?string $encoding = null, ?string $author_email = null, ?string $author_name = null)
{
@trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::updateFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED);

return $this->client->repositoryFiles()->updateFile($project_id, [
'file_path' => $file_path,
'branch' => $branch,
'content' => $content,
'commit_message' => $commit_message,
'encoding' => $encoding,
'author_email' => $author_email,
'author_name' => $author_name,
]);
}

/**
* @return mixed
*/
public function deleteFile(int $project_id, string $file_path, string $branch, string $commit_message, ?string $author_email = null, ?string $author_name = null)
{
@trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::deleteFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED);

return $this->client->repositoryFiles()->deleteFile($project_id, [
'file_path' => $file_path,
'branch' => $branch,
'commit_message' => $commit_message,
'author_email' => $author_email,
'author_name' => $author_name,
]);
}

/**
* @return mixed
*/
Expand Down
37 changes: 31 additions & 6 deletions src/Model/Branch.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use Gitlab\Client;

/**
* @property-read string $name
* @property-read bool $protected
* @property-read Commit $commit
* @property-read string $name
* @property-read bool $protected
* @property-read Commit $commit
* @property-read Project $project
*/
final class Branch extends Model
Expand Down Expand Up @@ -86,21 +86,46 @@ public function commits(array $parameters = []): array

public function createFile(string $file_path, string $content, string $commit_message): File
{
$data = $this->client->repositories()->createFile($this->project->id, $file_path, $content, $this->name, $commit_message);
$data = $this->client->repositoryFiles()->createFile(
$this->project->id,
[
'branch' => $this->name,
'file_path' => $file_path,
'content' => $content,
'commit_message' => $commit_message,
]
);

return File::fromArray($this->getClient(), $this->project, $data);
}

public function updateFile(string $file_path, string $content, string $commit_message): File
{
$data = $this->client->repositories()->updateFile($this->project->id, $file_path, $content, $this->name, $commit_message);
$data = $this->client->repositoryFiles()->updateFile(
$this->project->id,
[

'branch' => $this->name,
'file_path' => $file_path,
'content' => $content,
'commit_message' => $commit_message,
]
);

return File::fromArray($this->getClient(), $this->project, $data);
}

public function deleteFile(string $file_path, string $commit_message): bool
{
$this->client->repositories()->deleteFile($this->project->id, $file_path, $this->name, $commit_message);
$this->client->repositoryFiles()->deleteFile(
$this->project->id,
[

'branch' => $this->name,
'file_path' => $file_path,
'commit_message' => $commit_message,
]
);

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Model/Issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function move(Project $toProject): Issue
public function close(?string $comment = null): Issue
{
if ($comment) {
$this->addComment($comment);
$this->addNote($comment);
}

return $this->update(['state_event' => 'close']);
Expand All @@ -113,7 +113,7 @@ public function reopen(): Issue
return $this->open();
}

public function addComment(string $comment): Note
public function addNote(string $comment): Note
{
$data = $this->client->issues()->addComment($this->project->id, $this->iid, ['body' => $comment]);

Expand All @@ -123,7 +123,7 @@ public function addComment(string $comment): Note
/**
* @return Note[]
*/
public function showComments(): array
public function showNotes(): array
{
$notes = [];
$data = $this->client->issues()->showComments($this->project->id, $this->iid);
Expand Down
10 changes: 5 additions & 5 deletions src/Model/MergeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function update(array $params): MergeRequest
public function close(?string $comment = null): MergeRequest
{
if ($comment) {
$this->addComment($comment);
$this->addNote($comment);
}

return $this->update(['state_event' => 'close']);
Expand Down Expand Up @@ -141,20 +141,20 @@ public function merged(): MergeRequest
return $this->update(['state_event' => 'merge']);
}

public function addComment(string $comment): Note
public function addNote(string $note): Note
{
$data = $this->client->mergeRequests()->addComment($this->project->id, $this->iid, $comment);
$data = $this->client->mergeRequests()->addNote($this->project->id, $this->iid, $note);

return Note::fromArray($this->getClient(), $this, $data);
}

/**
* @return Note[]
*/
public function showComments(): array
public function showNotes(): array
{
$notes = [];
$data = $this->client->mergeRequests()->showComments($this->project->id, $this->iid);
$data = $this->client->mergeRequests()->showNotes($this->project->id, $this->iid);

foreach ($data as $note) {
$notes[] = Note::fromArray($this->getClient(), $this, $note);
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Noteable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

interface Noteable
{
public function addComment(string $comment): Note;
public function addNote(string $comment): Note;

/**
* @return Note[]
*/
public function showComments(): array;
public function showNotes(): array;

/**
* @return static
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,15 @@ public function tree(array $params = []): array

public function blob(string $sha, string $filepath): string
{
return $this->client->repositories()->blob($this->id, $sha, $filepath);
return $this->client->repositoryFiles()->getRawFile($this->id, $filepath, $sha);
}

/**
* @return mixed[]
*/
public function getFile(string $sha, string $filepath): array
{
return $this->client->repositories()->getFile($this->id, $filepath, $sha);
return $this->client->repositoryFiles()->getFile($this->id, $filepath, $sha);
}

public function createFile(
Expand Down

0 comments on commit 8ae3117

Please sign in to comment.