Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gitlab to "setup-ci" command (#5497)
* [dx] Add gitlab command support to setup-ci * cs * add gitlab check
- Loading branch information
1 parent
7584d25
commit 955a5de
Showing
5 changed files
with
142 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Git; | ||
|
||
use Nette\Utils\Strings; | ||
use Symfony\Component\Process\Process; | ||
|
||
final class RepositoryHelper | ||
{ | ||
/** | ||
* @var string | ||
* @see https://regex101.com/r/etcmog/2 | ||
*/ | ||
private const GITHUB_REPOSITORY_REGEX = '#github\.com[:\/](?<repository_name>.*?)\.git#'; | ||
|
||
public static function resolveGithubRepositoryName(string $currentDirectory): ?string | ||
{ | ||
// resolve current repository name | ||
$process = new Process(['git', 'remote', 'get-url', 'origin'], $currentDirectory, null, null, null); | ||
$process->run(); | ||
|
||
$output = $process->getOutput(); | ||
|
||
$match = Strings::match($output, self::GITHUB_REPOSITORY_REGEX); | ||
return $match['repository_name'] ?? null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
stages: | ||
- setup | ||
- rector | ||
- commit_changes | ||
|
||
setup: | ||
stage: setup | ||
# see https://github.com/thecodingmachine/docker-images-php | ||
image: thecodingmachine/php:8.2-v4-slim-cli | ||
|
||
rector: | ||
stage: rector | ||
script: | ||
- vendor/bin/rector --ansi | ||
# @todo apply coding standard if used | ||
|
||
commit_changes: | ||
stage: commit_changes | ||
script: | ||
- git config --global user.email "ci@gitlab.com" | ||
- git config --global user.name "GitLab CI | ||
# - git checkout $CI_COMMIT_REF_NAME | ||
- git add . | ||
- git commit -m "[rector] Rector fixes" | ||
- git push origin $CI_COMMIT_REF_NAME | ||
only: | ||
- merge_requests |