Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed obsolete code and moved classes. #82

Merged
merged 2 commits into from
Mar 30, 2024
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ root = true
[*]
end_of_line = LF
indent_style = space
indent_size = 4
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@

---

>[!NOTE]
> Version `0.7` will be a standalone CLI application and will no longer require Robo to run.

## What is it?

A tool to assemble a code artifact from your codebase, remove unnecessary files,
Expand Down
28 changes: 14 additions & 14 deletions src/Commands/ArtifactCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace DrevOps\GitArtifact\Commands;

use DrevOps\GitArtifact\FilesystemTrait;
use DrevOps\GitArtifact\GitArtifactGit;
use DrevOps\GitArtifact\GitArtifactGitRepository;
use DrevOps\GitArtifact\LogTrait;
use DrevOps\GitArtifact\TokenTrait;
use DrevOps\GitArtifact\Git\ArtifactGit;
use DrevOps\GitArtifact\Git\ArtifactGitRepository;
use DrevOps\GitArtifact\Traits\FilesystemTrait;
use DrevOps\GitArtifact\Traits\LogTrait;
use DrevOps\GitArtifact\Traits\TokenTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -36,7 +36,7 @@ class ArtifactCommand extends Command {
/**
* Represent to current repository.
*/
protected GitArtifactGitRepository $gitRepository;
protected ArtifactGitRepository $gitRepository;

/**
* Source path of git repository.
Expand Down Expand Up @@ -125,26 +125,26 @@ class ArtifactCommand extends Command {
/**
* Git wrapper.
*/
protected GitArtifactGit $git;
protected ArtifactGit $git;

/**
* Artifact constructor.
*
* @param \DrevOps\GitArtifact\GitArtifactGit $gitWrapper
* @param \DrevOps\GitArtifact\Git\ArtifactGit $gitWrapper
* Git wrapper.
* @param \Symfony\Component\Filesystem\Filesystem $fsFileSystem
* File system.
* @param string|null $name
* Command name.
*/
public function __construct(
GitArtifactGit $gitWrapper = NULL,
ArtifactGit $gitWrapper = NULL,
Filesystem $fsFileSystem = NULL,
?string $name = NULL
) {
parent::__construct($name);
$this->fsFileSystem = is_null($fsFileSystem) ? new Filesystem() : $fsFileSystem;
$this->git = is_null($gitWrapper) ? new GitArtifactGit() : $gitWrapper;
$this->git = is_null($gitWrapper) ? new ArtifactGit() : $gitWrapper;
}

/**
Expand Down Expand Up @@ -528,13 +528,13 @@ protected function resolveOptions(string $remote, array $options): void {
* @param string $sourcePath
* Source path.
*
* @return \DrevOps\GitArtifact\GitArtifactGitRepository
* @return \DrevOps\GitArtifact\Git\ArtifactGitRepository
* Current git repository.
*
* @throws \CzProject\GitPhp\GitException
* @throws \Exception
*/
protected function initGitRepository(string $sourcePath): GitArtifactGitRepository {
protected function initGitRepository(string $sourcePath): ArtifactGitRepository {
$this->gitRepository = $this->git->open($sourcePath);

return $this->gitRepository;
Expand Down Expand Up @@ -666,7 +666,7 @@ protected function resolveOriginalBranch(): string {
protected function setDstBranch(string $branch): void {
$branch = (string) $this->tokenProcess($branch);

if (!GitArtifactGitRepository::isValidBranchName($branch)) {
if (!ArtifactGitRepository::isValidBranchName($branch)) {
throw new \RuntimeException(sprintf('Incorrect value "%s" specified for git remote branch', $branch));
}
$this->destinationBranch = $branch;
Expand Down Expand Up @@ -970,7 +970,7 @@ protected function writeln(string $text): void {
protected function setupRemoteForRepository(): void {
$remoteName = $this->remoteName;
$remoteUrl = $this->remoteUrl;
if (!GitArtifactGitRepository::isValidRemoteUrl($remoteUrl)) {
if (!ArtifactGitRepository::isValidRemoteUrl($remoteUrl)) {
throw new \Exception(sprintf('Invalid remote URL: %s', $remoteUrl));
}

Expand Down
23 changes: 23 additions & 0 deletions src/Git/ArtifactGit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace DrevOps\GitArtifact\Git;

use CzProject\GitPhp\Git;

/**
* Artifact git class.
*/
class ArtifactGit extends Git {

/**
* Open directory.
*
* @throws \CzProject\GitPhp\GitException
*/
public function open($directory): ArtifactGitRepository {
return new ArtifactGitRepository($directory, $this->runner);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace DrevOps\GitArtifact;
namespace DrevOps\GitArtifact\Git;

use CzProject\GitPhp\GitRepository;
use CzProject\GitPhp\RunnerResult;
Expand All @@ -14,7 +14,7 @@
*
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class GitArtifactGitRepository extends GitRepository {
class ArtifactGitRepository extends GitRepository {

/**
* Filesystem.
Expand All @@ -34,12 +34,12 @@ class GitArtifactGitRepository extends GitRepository {
* @param string $refSpec
* Specify what destination ref to update with what source object.
*
* @return GitArtifactGitRepository
* @return ArtifactGitRepository
* Git repo.
*
* @throws \CzProject\GitPhp\GitException
*/
public function pushForce(string $remote, string $refSpec): GitArtifactGitRepository {
public function pushForce(string $remote, string $refSpec): ArtifactGitRepository {
return parent::push([$remote, $refSpec], ['--force']);
}

Expand Down Expand Up @@ -110,7 +110,7 @@ public function getCommits(string $format = '%s'): array {
*
* @throws \CzProject\GitPhp\GitException
*/
public function resetHard(): GitArtifactGitRepository {
public function resetHard(): ArtifactGitRepository {
$this->run('reset', ['--hard']);

return $this;
Expand All @@ -124,7 +124,7 @@ public function resetHard(): GitArtifactGitRepository {
*
* @throws \CzProject\GitPhp\GitException
*/
public function cleanForce(): GitArtifactGitRepository {
public function cleanForce(): ArtifactGitRepository {
$this->run('clean', ['-dfx']);

return $this;
Expand All @@ -138,12 +138,12 @@ public function cleanForce(): GitArtifactGitRepository {
* @param bool $createNew
* Optional flag to also create a branch before switching. Default false.
*
* @return GitArtifactGitRepository
* @return ArtifactGitRepository
* The git repository.
*
* @throws \CzProject\GitPhp\GitException
*/
public function switchToBranch(string $branchName, bool $createNew = FALSE): GitArtifactGitRepository {
public function switchToBranch(string $branchName, bool $createNew = FALSE): ArtifactGitRepository {
if (!$createNew) {
return $this->checkout($branchName);
}
Expand All @@ -159,12 +159,12 @@ public function switchToBranch(string $branchName, bool $createNew = FALSE): Git
* @param bool $force
* Force remove or not.
*
* @return GitArtifactGitRepository
* @return ArtifactGitRepository
* Git repository
*
* @throws \CzProject\GitPhp\GitException
*/
public function removeBranch($name, bool $force = FALSE): GitArtifactGitRepository {
public function removeBranch($name, bool $force = FALSE): ArtifactGitRepository {
if (empty($name)) {
return $this;
}
Expand Down Expand Up @@ -231,7 +231,7 @@ public function listCommittedFiles(): array {
*
* @throws \CzProject\GitPhp\GitException
*/
public function setConfigReceiveDenyCurrentBranchIgnore(): GitArtifactGitRepository {
public function setConfigReceiveDenyCurrentBranchIgnore(): ArtifactGitRepository {
$this->extractFromCommand(['config', ['receive.denyCurrentBranch', 'ignore']]);

return $this;
Expand All @@ -250,7 +250,7 @@ public function setConfigReceiveDenyCurrentBranchIgnore(): GitArtifactGitReposit
*
* @throws \CzProject\GitPhp\GitException
*/
public function createAnnotatedTag(string $name, string $message): GitArtifactGitRepository {
public function createAnnotatedTag(string $name, string $message): ArtifactGitRepository {
$this->createTag($name, [
'--message=' . $message,
'-a',
Expand All @@ -270,7 +270,7 @@ public function createAnnotatedTag(string $name, string $message): GitArtifactGi
*
* @throws \CzProject\GitPhp\GitException
*/
public function createLightweightTag(string $name): GitArtifactGitRepository {
public function createLightweightTag(string $name): ArtifactGitRepository {
$this->createTag($name);

return $this;
Expand All @@ -284,12 +284,12 @@ public function createLightweightTag(string $name): GitArtifactGitRepository {
* @param string $name
* Remote name.
*
* @return GitArtifactGitRepository
* @return ArtifactGitRepository
* Git repo.
*
* @throws \CzProject\GitPhp\GitException
*/
public function removeRemote($name): GitArtifactGitRepository {
public function removeRemote($name): ArtifactGitRepository {
if ($this->isRemoteExists($name)) {
$this->run('remote', 'remove', $name);
}
Expand Down
23 changes: 0 additions & 23 deletions src/GitArtifactGit.php

This file was deleted.

Loading