Skip to content

Commit

Permalink
update: update the gh,gl command redirect to git group logic
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed May 18, 2022
1 parent b89a8a4 commit b3bc65c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
11 changes: 5 additions & 6 deletions app/Console/Component/RedirectToGitGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class RedirectToGitGroup extends AbstractObj

/**
* @param Controller $ctrl
* @param string $action
* @param string $command
* @param array $args
*
* @return bool
* @throws Throwable
*/
public function handle(Controller $ctrl, string $action, array $args): bool
public function handle(Controller $ctrl, string $command, array $args): bool
{
if (!$this->cmdList) {
return false;
Expand All @@ -39,8 +39,7 @@ public function handle(Controller $ctrl, string $action, array $args): bool

// resolve alias
$gitCtrl = $app->getController(GitController::getName());

$action = $gitCtrl->resolveAlias($action);
$action = $gitCtrl->resolveAlias($command);
$group = $ctrl->getRealGName();

// if $first = *, will redirect all command.
Expand All @@ -49,8 +48,8 @@ public function handle(Controller $ctrl, string $action, array $args): bool
// auto proxy env
Kite::autoProxy()->applyProxyEnv($action, $group);

Cli::info("NOTICE: will redirect to git group for run subcommand: $action");
$ctrl->debugf('command %s not found on %s, will redirect to the git group', $action, $group);
Cli::info("[NOTE] will redirect to git group and run subcommand: $action");
$ctrl->debugf('group: %s - command "%s" not found, will redirect to the git group', $group, $command);

$newArgs = [];
if ($ctrl->getFlags()->getOpt('dry-run')) {
Expand Down
8 changes: 4 additions & 4 deletions app/Console/Controller/Gitx/GitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ protected function beforeRun(): void
}

/**
* @param string $action
* @param string $command
* @param array $args
*
* @return bool
*/
protected function onNotFound(string $action, array $args): bool
protected function onNotFound(string $command, array $args): bool
{
$this->output->info("input command '$action' is not found, will exec git command: `git $action`");
$this->output->info("git: input command '$command' is not found, will exec git command: `git $command`");

$c = Cmd::git($action);
$c = Cmd::git($command);
$c->withIf(fn() => $c->addArgs(...$args), $args);

// if ($args) {
Expand Down
6 changes: 3 additions & 3 deletions app/Console/Controller/Gitx/GitHubController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ protected function beforeRun(): void
}

/**
* @param string $action
* @param string $command
* @param array $args
*
* @return bool
* @throws Throwable
*/
protected function onNotFound(string $action, array $args): bool
protected function onNotFound(string $command, array $args): bool
{
if (!$this->app) {
return false;
Expand All @@ -104,7 +104,7 @@ protected function onNotFound(string $action, array $args): bool
'cmdList' => $this->settings['redirectGit'] ?? [],
]);

return $h->handle($this, $action, $args);
return $h->handle($this, $command, $args);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions app/Console/Controller/Gitx/GitLabController.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ protected function beforeRun(): void
}

/**
* @param string $action
* @param string $command
* @param array $args
*
* @return bool
* @throws Throwable
*/
protected function onNotFound(string $action, array $args): bool
protected function onNotFound(string $command, array $args): bool
{
if (!$this->app) {
return false;
Expand All @@ -154,7 +154,7 @@ protected function onNotFound(string $action, array $args): bool
'cmdList' => $this->settings['redirectGit'] ?? [],
]);

return $h->handle($this, $action, $args);
return $h->handle($this, $command, $args);
}

/**
Expand Down

0 comments on commit b3bc65c

Please sign in to comment.