Skip to content

Commit

Permalink
update some for git, gitlab command
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jan 11, 2021
1 parent b3d8439 commit 2b0f8dc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
12 changes: 7 additions & 5 deletions app/Console/Controller/GitLabController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]',
];
Expand Down Expand Up @@ -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
Expand All @@ -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");
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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");
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion app/Console/Controller/GitUseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -319,14 +320,20 @@ 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));

if (false === $input->getBoolOpt('not-push')) {
$run->afterOkDo('git push');
}


$output->success('Complete');
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": ">7.1.0",
"php": ">7.3.0",
"ext-json": "*",
"ext-mbstring": "*",
"inhere/console": "dev-master",
Expand Down

0 comments on commit 2b0f8dc

Please sign in to comment.