From 2b0f8dc3f363e2d7f960def6adb772a78625d42d Mon Sep 17 00:00:00 2001 From: inhere Date: Mon, 11 Jan 2021 10:51:58 +0800 Subject: [PATCH] update some for git, gitlab command --- app/Console/Controller/GitLabController.php | 12 +++++++----- app/Console/Controller/GitUseController.php | 9 ++++++++- composer.json | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/Console/Controller/GitLabController.php b/app/Console/Controller/GitLabController.php index aeffbc9..389efdc 100644 --- a/app/Console/Controller/GitLabController.php +++ b/app/Console/Controller/GitLabController.php @@ -53,6 +53,7 @@ public static function aliases(): array protected function groupOptions(): array { return [ + '--dry-run' => 'Dry-run the workflow, dont real execute', '-y, --yes' => 'Direct execution without confirmation', '-i, --interactive' => 'Run in an interactive environment[TODO]', ]; @@ -181,6 +182,7 @@ public function configCommand(Input $input, Output $output): void * * @options * -m, --message The commit message + * --not-push Dont execute git push * * @arguments * files... Only add special files @@ -194,6 +196,8 @@ public function acpCommand(Input $input, Output $output): void { $binName = $input->getBinName(); + $output->notice("will redirect to command: git:acp"); + Console::app()->dispatch('git:acp'); $output->info("TIPS:\n $binName gl:pr -o -t BRANCH"); @@ -203,7 +207,6 @@ public function acpCommand(Input $input, Output $output): void * checkout an new branch for development * * @options - * --dry-run Dry-run the workflow * --not-main Dont push new branch to the main remote * * @arguments @@ -230,7 +233,6 @@ public function newBranchCommand(Input $input, Output $output): void * * @options * -f, --force Force execute delete command, ignore error - * --dry-run Dry-run the workflow * --not-main Dont delete branch on the main remote * * @arguments @@ -465,7 +467,6 @@ public function pullRequestCommand(Input $input, Output $output): void $curBranch = GitUtil::getCurrentBranchName(); $srcBranch = $input->getSameStringOpt(['s', 'source']); $tgtBranch = $input->getSameStringOpt('t,target'); - $tgtBranch = $gitlab->getRealBranchName($tgtBranch); if ($fullSBranch = $input->getStringOpt('full-source')) { $srcBranch = $fullSBranch; @@ -487,6 +488,9 @@ public function pullRequestCommand(Input $input, Output $output): void $tgtBranch = $curBranch; } + $srcBranch = $gitlab->getRealBranchName($srcBranch); + $tgtBranch = $gitlab->getRealBranchName($tgtBranch); + // deny as an source branch if ($denyBrs && $srcBranch !== $tgtBranch && in_array($srcBranch, $denyBrs, true)) { throw new PromptException("the branch '{$srcBranch}' dont allow as source-branch for PR to other branch"); @@ -625,7 +629,6 @@ protected function createConfigure(Input $input): void * -g, --group The new project main group in gitlab. if not set, will use base project group * -o, --fork-group The new project origin group in gitlab. if not set, will dont update * -r, --remote The base skeleton project repo name with group. - * --dry-run Dry run the workflow * * @arguments * name The new project name. @@ -732,7 +735,6 @@ public function updatePushCommand(Input $input, Output $output): void * * @options * -p, --push Push to origin remote after update - * --dry-run Dry run workflow * * @param Input $input * @param Output $output diff --git a/app/Console/Controller/GitUseController.php b/app/Console/Controller/GitUseController.php index 86b8850..6e6d742 100644 --- a/app/Console/Controller/GitUseController.php +++ b/app/Console/Controller/GitUseController.php @@ -297,6 +297,7 @@ public function acCommand(Input $input, Output $output): void * @options * -m, --message The commit message * --not-push Dont execute git push + * --dry-run Dont real execute command * * @arguments * files... Only add special files @@ -319,7 +320,12 @@ public function acpCommand(Input $input, Output $output): void $added = implode(' ', $args); } - $run = CmdRunner::new("git status")->do(true); + $dryRun = $input->getBoolOpt('dry-run'); + + $run = CmdRunner::new("git status"); + $run->setDryRun($dryRun); + + $run->do(true); $run->afterOkDo("git add $added"); $run->afterOkDo(sprintf('git commit -m "%s"', $message)); @@ -327,6 +333,7 @@ public function acpCommand(Input $input, Output $output): void $run->afterOkDo('git push'); } + $output->success('Complete'); } diff --git a/composer.json b/composer.json index ab4e115..247cf61 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": ">7.1.0", + "php": ">7.3.0", "ext-json": "*", "ext-mbstring": "*", "inhere/console": "dev-master",