Skip to content

Commit

Permalink
up: update some for git gitlab commands
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed May 31, 2022
1 parent 8ee9039 commit a71cc40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
23 changes: 9 additions & 14 deletions app/Console/Controller/Gitx/GitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
use Toolkit\Sys\Proc\ProcTasks;
use function abs;
use function array_keys;
use function chdir;
use function implode;
use function realpath;
use function sprintf;
Expand Down Expand Up @@ -127,7 +126,7 @@ protected function beforeRun(): void
if ($workdir = $this->flags->getOpt('workdir')) {
$workdir = realpath($workdir);
$this->output->info('Change workdir to: ' . $workdir);
chdir($workdir);
$this->input->chWorkDir($workdir);
} else {
$workdir = $this->input->getWorkDir();
}
Expand Down Expand Up @@ -160,9 +159,6 @@ protected function onNotFound(string $command, array $args): bool
/**
* update codes from origin by git pull
*
* @options
* --dir The want updated git repo dir. default is workdir
*
* @arguments
* gitArgs Input more args or opts for run git
*
Expand All @@ -178,11 +174,11 @@ protected function onNotFound(string $command, array $args): bool
public function updateCommand(FlagsParser $fs, Input $input, Output $output): void
{
$args = $fs->getRawArgs();
$dir = $fs->getOpt('dir') ?: $this->getWorkDir();
Assert::isDir($dir . '/.git', "$dir is not a git dir");
$dir = $this->getFlags()->getOpt('workdir', $this->getWorkDir());
Assert::isDir('.git', "$dir is not a git dir");

$c = Cmd::git('pull');
$c->setWorkDir($dir);
// $c->setWorkDir($dir);
$c->setDryRun($this->flags->getOpt('dry-run'));
$c->addArgs(...$args);
$c->run(true);
Expand All @@ -193,9 +189,6 @@ public function updateCommand(FlagsParser $fs, Input $input, Output $output): vo
/**
* push codes to origin by `git push`
*
* @options
* --dir The git repo dir. default is workdir
*
* @arguments
* gitArgs Input more args or opts for run git
*
Expand All @@ -208,11 +201,11 @@ public function updateCommand(FlagsParser $fs, Input $input, Output $output): vo
public function pushCommand(FlagsParser $fs, Output $output): void
{
$args = $fs->getRawArgs();
$dir = $fs->getOpt('dir') ?: $this->getWorkDir();
Assert::isDir($dir . '/.git', "$dir is not a git dir");
$dir = $this->getFlags()->getOpt('workdir', $this->getWorkDir());
Assert::isDir('.git', "$dir is not a git dir");

$c = Cmd::git('push')
->setWorkDir($dir)
// ->setWorkDir($dir)
->setDryRun($this->flags->getOpt('dry-run'))
->addArgs(...$args);
$c->run(true);
Expand Down Expand Up @@ -246,6 +239,7 @@ public function statusCommand(Output $output): void
*/
public function infoCommand(FlagsParser $fs, Output $output): void
{
// $dir = $this->getFlags()->getOpt('workdir');
$repo = Repo::new();
$repo->setPrintCmd($fs->getOpt('show-commands'));

Expand All @@ -271,6 +265,7 @@ public function infoCommand(FlagsParser $fs, Output $output): void
public function branchCommand(FlagsParser $fs, Output $output): void
{
$opts = [];
// $dir = $this->getFlags()->getOpt('workdir');
$repo = Repo::new();

$remote = '';
Expand Down
4 changes: 4 additions & 0 deletions app/Console/Controller/Gitx/GitLabController.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ protected function onNotFound(string $command, array $args): bool
return false;
}

if (in_array($command, ['ac', 'acp'], true)) {
// deny commit message.
}

$h = RedirectToGitGroup::new([
'cmdList' => $this->settings['redirectGit'] ?? [],
]);
Expand Down

0 comments on commit a71cc40

Please sign in to comment.