Skip to content

Commit

Permalink
up: update some git commands and auto proxy env logic
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Nov 3, 2022
1 parent 489a8e9 commit 5f6d3ba
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
8 changes: 6 additions & 2 deletions app/Console/Component/AutoSetProxyEnv.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,20 @@ class AutoSetProxyEnv extends AbstractObj
/**
* @param string $realCName
* @param string $realGName
* @param string $cmdId
*
* @return bool
*/
public function applyProxyEnv(string $realCName, string $realGName = ''): bool
public function applyProxyEnv(string $realCName, string $realGName = '', string $cmdId = ''): bool
{
if (!$this->envSettings) {
return false;
}

$cmdId = $realGName ? $realGName . ':' . $realCName : $realCName;
if (!$cmdId) {
$cmdId = $realGName ? $realGName . ':' . $realCName : $realCName;
}

if ($cmdId === $this->applyed) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Listener/BeforeCommandRunListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public function __invoke(AbstractHandler $handler)
// auto set proxy
$realCName = $handler->getRealCName();
$groupName = $handler->getRealGName();
Kite::autoProxy()->applyProxyEnv($realCName, $groupName);
Kite::autoProxy()->applyProxyEnv($realCName, $groupName, $handler->getCommandId());
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php declare(strict_types=1);

namespace Inhere\Kite\Console\SubCmd;
namespace Inhere\Kite\Console\SubCmd\GitxCmd;

use Inhere\Console\Command;
use Inhere\Console\IO\Input;
use Inhere\Console\IO\Output;
use Inhere\Kite\Console\SubCmd\GitxCmd\GitTagListCmd;
use Throwable;

/**
Expand All @@ -23,6 +22,16 @@ protected function subCommands(): array
{
return [
GitTagListCmd::class,
GitTagDelCmd::class,
GitTagCreateCmd::class,
];
}

protected function getOptions(): array
{
return [
'--try,--dry-run' => 'bool;Dry-run the workflow, dont real execute',
'-y, --yes' => 'bool;Direct execution without confirmation',
];
}

Expand Down
9 changes: 8 additions & 1 deletion app/Console/SubCmd/GitxCmd/GitTagListCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@ public static function aliases(): array
return ['ls'];
}

protected function getArguments(): array
{
return [
'keywords' => 'match special tag by keywords',
];
}

protected function execute(Input $input, Output $output)
{
$fs = $this->flags;

// git tag --sort=-creatordate 倒序排列
$cmd = 'git tag -l -n2';
$kw = $fs->getArg(0);
$kw = $fs->getArg('keywords');
if ($kw) {
$cmd .= " | grep $kw";
}
Expand Down

0 comments on commit 5f6d3ba

Please sign in to comment.