- Removed unused exception GitCloneException
in \ncc\Exceptions
in favor of GitException
- Removed unused exception `GitCheckoutException` in `\ncc\Exceptions` in favor of `GitException` - Removed unused exception `GithubServiceException` in `\ncc\Exceptions` in favor of `GitException` - Updated `\ncc\Classes > GitClient > cloneRepository()` to throw `GitException` instead of `GitCloneException` - Updated `\ncc\Classes > GitClient > checkout()` to throw `GitException` instead of `GitCheckoutException` - Added new exception `GitException` in `\ncc\Exceptions` to replace all git related exceptions
This commit is contained in:
parent
c3406ca13f
commit
00dcc7e004
7 changed files with 78 additions and 128 deletions
|
@ -15,6 +15,7 @@ features.
|
|||
- Added new exception `PathNotFoundException` and implemented it in replacement for `DirectoryNotFoundException` and
|
||||
`FileNotFoundException` in `\ncc\Exceptions`
|
||||
- Added a new interface class `BytecodeObjectInterface` which will be used to implement object types for compiled assets
|
||||
- Added new exception `GitException` in `\ncc\Exceptions` to replace all git related exceptions
|
||||
|
||||
### Fixed
|
||||
- Fixed MITM attack vector in `\ncc\Classes > HttpClient > prepareCurl()`
|
||||
|
@ -107,6 +108,8 @@ features.
|
|||
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\ExecutionPolicy > ExitHandle`
|
||||
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\ExecutionPolicy > ExitHandlers`
|
||||
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration\Build > BuildConfiguration`
|
||||
- Updated `\ncc\Classes > GitClient > cloneRepository()` to throw `GitException` instead of `GitCloneException`
|
||||
- Updated `\ncc\Classes > GitClient > checkout()` to throw `GitException` instead of `GitCheckoutException`
|
||||
|
||||
### Removed
|
||||
- Removed `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions`
|
||||
|
@ -114,6 +117,9 @@ features.
|
|||
- Removed references of Win32 from the project as Windows is not going supported
|
||||
- Removed unused exception `FileNotFoundException` in `\ncc\CLI > HelpMenu`
|
||||
- Removed unused class `\ncc\Objects > SymlinkDictionary`
|
||||
- Removed unused exception `GitCloneException` in `\ncc\Exceptions` in favor of `GitException`
|
||||
- Removed unused exception `GitCheckoutException` in `\ncc\Exceptions` in favor of `GitException`
|
||||
- Removed unused exception `GithubServiceException` in `\ncc\Exceptions` in favor of `GitException`
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ ResourceNotFoundException
|
|||
PACKAGE_NOT_FOUND
|
||||
VERSION_NOT_FOUND
|
||||
NO_AVAILABLE_UNITS
|
||||
PATH_NOT_FOUND
|
||||
|
||||
PackageException
|
||||
UNSUPPORTED_PACKAGE
|
||||
|
@ -53,8 +52,9 @@ ComposerException
|
|||
COMPOSER_EXCEPTION
|
||||
|
||||
GitException
|
||||
GIT_CLONE_EXCEPTION
|
||||
GIT_CHECKOUT_EXCEPTION
|
||||
* GIT_CLONE_EXCEPTION
|
||||
* GIT_CHECKOUT_EXCEPTION
|
||||
* GITHUB_SERVICE_EXCEPTION
|
||||
GITLAB_SERVICE_EXCEPTION
|
||||
GIT_TAGS_EXCEPTION
|
||||
|
||||
|
|
|
@ -1,31 +1,29 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Classes;
|
||||
namespace ncc\Classes;
|
||||
|
||||
use ncc\Exceptions\GitCheckoutException;
|
||||
use ncc\Exceptions\GitCloneException;
|
||||
use ncc\Exceptions\GitException;
|
||||
use ncc\Exceptions\GitTagsException;
|
||||
use ncc\Exceptions\InvalidScopeException;
|
||||
use ncc\ThirdParty\Symfony\Process\Process;
|
||||
use ncc\Utilities\Console;
|
||||
use ncc\Utilities\Functions;
|
||||
|
@ -37,8 +35,7 @@ namespace ncc\Classes;
|
|||
*
|
||||
* @param string $url
|
||||
* @return string
|
||||
* @throws GitCloneException
|
||||
* @throws InvalidScopeException
|
||||
* @throws GitException
|
||||
*/
|
||||
public static function cloneRepository(string $url): string
|
||||
{
|
||||
|
@ -59,7 +56,7 @@ namespace ncc\Classes;
|
|||
|
||||
if (!$process->isSuccessful())
|
||||
{
|
||||
throw new GitCloneException($process->getErrorOutput());
|
||||
throw new GitException(sprintf('Failed to clone repository %s: %s', $url, $process->getErrorOutput()));
|
||||
}
|
||||
|
||||
Console::outVerbose('Repository cloned to: ' . $path);
|
||||
|
@ -72,7 +69,7 @@ namespace ncc\Classes;
|
|||
*
|
||||
* @param string $path
|
||||
* @param string $branch
|
||||
* @throws GitCheckoutException
|
||||
* @throws GitException
|
||||
*/
|
||||
public static function checkout(string $path, string $branch): void
|
||||
{
|
||||
|
@ -93,7 +90,7 @@ namespace ncc\Classes;
|
|||
|
||||
if (!$process->isSuccessful())
|
||||
{
|
||||
throw new GitCheckoutException($process->getErrorOutput());
|
||||
throw new GitException(sprintf('Failed to checkout branch %s in repository %s: %s', $branch, $path, $process->getErrorOutput()));
|
||||
}
|
||||
|
||||
Console::outVerbose('Checked out branch: ' . $branch);
|
||||
|
@ -115,7 +112,7 @@ namespace ncc\Classes;
|
|||
|
||||
if (!$process->isSuccessful())
|
||||
{
|
||||
throw new GitCheckoutException($process->getErrorOutput());
|
||||
throw new GitException(sprintf('Failed to update submodules in repository %s: %s', $path, $process->getErrorOutput()));
|
||||
}
|
||||
|
||||
Console::outVerbose('Submodules updated');
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Classes\GithubExtension;
|
||||
namespace ncc\Classes\GithubExtension;
|
||||
|
||||
use ncc\Enums\HttpRequestType;
|
||||
use ncc\Enums\Versions;
|
||||
use ncc\Classes\HttpClient;
|
||||
use ncc\Exceptions\AuthenticationException;
|
||||
use ncc\Exceptions\GithubServiceException;
|
||||
use ncc\Exceptions\GitException;
|
||||
use ncc\Exceptions\GitlabServiceException;
|
||||
use ncc\Exceptions\HttpException;
|
||||
use ncc\Exceptions\MalformedJsonException;
|
||||
|
@ -50,7 +50,7 @@ namespace ncc\Classes\GithubExtension;
|
|||
* @param Entry|null $entry
|
||||
* @return RepositoryQueryResults
|
||||
* @throws AuthenticationException
|
||||
* @throws GithubServiceException
|
||||
* @throws GitException
|
||||
* @throws GitlabServiceException
|
||||
* @throws HttpException
|
||||
* @throws MalformedJsonException
|
||||
|
@ -83,7 +83,7 @@ namespace ncc\Classes\GithubExtension;
|
|||
* @param Entry|null $entry
|
||||
* @return RepositoryQueryResults
|
||||
* @throws AuthenticationException
|
||||
* @throws GithubServiceException
|
||||
* @throws GitException
|
||||
* @throws GitlabServiceException
|
||||
* @throws HttpException
|
||||
* @throws MalformedJsonException
|
||||
|
@ -100,7 +100,7 @@ namespace ncc\Classes\GithubExtension;
|
|||
* @param Entry|null $entry
|
||||
* @return RepositoryQueryResults
|
||||
* @throws AuthenticationException
|
||||
* @throws GithubServiceException
|
||||
* @throws GitException
|
||||
* @throws GitlabServiceException
|
||||
* @throws HttpException
|
||||
* @throws MalformedJsonException
|
||||
|
@ -119,7 +119,7 @@ namespace ncc\Classes\GithubExtension;
|
|||
* @param Entry|null $entry
|
||||
* @return array
|
||||
* @throws AuthenticationException
|
||||
* @throws GithubServiceException
|
||||
* @throws GitException
|
||||
* @throws GitlabServiceException
|
||||
* @throws HttpException
|
||||
* @throws MalformedJsonException
|
||||
|
@ -192,10 +192,10 @@ namespace ncc\Classes\GithubExtension;
|
|||
* @param Entry|null $entry
|
||||
* @return array
|
||||
* @throws AuthenticationException
|
||||
* @throws GithubServiceException
|
||||
* @throws GitlabServiceException
|
||||
* @throws GitException
|
||||
* @throws HttpException
|
||||
* @throws MalformedJsonException
|
||||
* @throws GitlabServiceException
|
||||
*/
|
||||
private static function getJsonResponse(HttpRequest $httpRequest, ?Entry $entry): array
|
||||
{
|
||||
|
@ -208,7 +208,7 @@ namespace ncc\Classes\GithubExtension;
|
|||
|
||||
if ($response->StatusCode !== 200)
|
||||
{
|
||||
throw new GithubServiceException(sprintf('Failed to fetch releases for the given repository. Status code: %s', $response->StatusCode));
|
||||
throw new GitException(sprintf('Github returned an error (%s): %s', $response->StatusCode, $response->Body));
|
||||
}
|
||||
|
||||
return Functions::loadJson($response->Body, Functions::FORCE_ARRAY);
|
||||
|
@ -220,7 +220,7 @@ namespace ncc\Classes\GithubExtension;
|
|||
* @param Entry|null $entry
|
||||
* @return mixed
|
||||
* @throws AuthenticationException
|
||||
* @throws GithubServiceException
|
||||
* @throws GitException
|
||||
* @throws GitlabServiceException
|
||||
* @throws HttpException
|
||||
* @throws MalformedJsonException
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
namespace ncc\Enums;
|
||||
|
||||
use ncc\Exceptions\GitException;
|
||||
use ncc\Exceptions\InvalidDependencyConfiguration;
|
||||
use ncc\Exceptions\PathNotFoundException;
|
||||
use ncc\Exceptions\SymlinkException;
|
||||
|
@ -283,16 +284,6 @@ namespace ncc\Enums;
|
|||
*/
|
||||
public const UNSUPPORTED_REMOTE_SOURCE_TYPE = -1753;
|
||||
|
||||
/**
|
||||
* @see GitCloneException
|
||||
*/
|
||||
public const GIT_CLONE_EXCEPTION = -1754;
|
||||
|
||||
/**
|
||||
* @see GitCheckoutException
|
||||
*/
|
||||
public const GIT_CHECKOUT_EXCEPTION = -1755;
|
||||
|
||||
/**
|
||||
* @see GitlabServiceException
|
||||
*/
|
||||
|
@ -308,11 +299,6 @@ namespace ncc\Enums;
|
|||
*/
|
||||
public const GIT_TAGS_EXCEPTION = -1758;
|
||||
|
||||
/**
|
||||
* @see GithubServiceException
|
||||
*/
|
||||
public const GITHUB_SERVICE_EXCEPTION = -1759;
|
||||
|
||||
/**
|
||||
* @see AuthenticationException
|
||||
*/
|
||||
|
@ -363,6 +349,11 @@ namespace ncc\Enums;
|
|||
*/
|
||||
public const PATH_NOT_FOUND = -1769;
|
||||
|
||||
/**
|
||||
* @see GitException
|
||||
*/
|
||||
public const GIT_EXCEPTION = -1770;
|
||||
|
||||
/**
|
||||
* All the exception codes from NCC
|
||||
*/
|
||||
|
@ -416,8 +407,6 @@ namespace ncc\Enums;
|
|||
self::MISSING_DEPENDENCY,
|
||||
self::HTTP_EXCEPTION,
|
||||
self::UNSUPPORTED_REMOTE_SOURCE_TYPE,
|
||||
self::GIT_CLONE_EXCEPTION,
|
||||
self::GIT_CHECKOUT_EXCEPTION,
|
||||
self::GITLAB_SERVICE_EXCEPTION,
|
||||
self::GIT_TAGS_EXCEPTION,
|
||||
self::AUTHENTICATION_EXCEPTION,
|
||||
|
@ -429,6 +418,7 @@ namespace ncc\Enums;
|
|||
self::INVALID_BUILD_CONFIGURATION,
|
||||
self::INVALID_DEPENDENCY_CONFIGURATION,
|
||||
self::SYMLINK_EXCEPTION,
|
||||
self::PATH_NOT_FOUND
|
||||
self::PATH_NOT_FOUND,
|
||||
self::GIT_EXCEPTION
|
||||
];
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use ncc\Enums\ExceptionCodes;
|
||||
use Throwable;
|
||||
|
||||
class GitCheckoutException extends Exception
|
||||
{
|
||||
/**
|
||||
* @param string $message
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, ExceptionCodes::GIT_CHECKOUT_EXCEPTION, $previous);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
|
@ -20,20 +20,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Exceptions;
|
||||
namespace ncc\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use ncc\Enums\ExceptionCodes;
|
||||
use Throwable;
|
||||
|
||||
class GitCloneException extends Exception
|
||||
class GitException extends Exception
|
||||
{
|
||||
/**
|
||||
* @param string $message
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct(string $message = "", ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, ExceptionCodes::GIT_CLONE_EXCEPTION, $previous);
|
||||
parent::__construct($message, ExceptionCodes::GIT_EXCEPTION, $previous);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue