diff --git a/app/Common/GitLocal/AbstractGitLocal.php b/app/Common/GitLocal/AbstractGitLocal.php index 24cafa2..64026a4 100644 --- a/app/Common/GitLocal/AbstractGitLocal.php +++ b/app/Common/GitLocal/AbstractGitLocal.php @@ -24,9 +24,9 @@ abstract class AbstractGitLocal public const GITHUB_HOST = 'https://github.com'; /** - * @var Repo + * @var Repo|null */ - protected Repo $repo; + protected ?Repo $repo = null; /** * @var string diff --git a/app/Console/Controller/GitLabController.php b/app/Console/Controller/GitLabController.php index 12d94f0..fd11e62 100644 --- a/app/Console/Controller/GitLabController.php +++ b/app/Console/Controller/GitLabController.php @@ -63,7 +63,7 @@ public static function aliases(): array protected static function commandAliases(): array { return [ - 'pullRequest' => ['pr', 'mr'], + 'pullRequest' => ['pr', 'mr', 'merge-request'], 'deleteBranch' => ['del-br', 'delbr', 'dbr', 'db'], 'newBranch' => ['new-br', 'newbr', 'nbr', 'nb'], 'li' => 'linkInfo', @@ -582,6 +582,11 @@ public function resolveCommand(FlagsParser $fs, Output $output): void * * @param FlagsParser $fs * @param Output $output + * @help + * Special: + * `@`, HEAD - Current branch. + * `@s` - Source branch. + * `@t` - Target branch. * * @example * {binWithCmd} Will generate PR link for fork 'HEAD_BRANCH' to main 'HEAD_BRANCH' @@ -622,8 +627,14 @@ public function pullRequestCommand(FlagsParser $fs, Output $output): void $open = $fs->getOpt('open'); // if input '@', 'head', use current branch name. - if ($open && ($open === '@' || strtoupper($open) === 'HEAD')) { - $open = $curBranch; + if ($open) { + if ($open === '@' || strtoupper($open) === 'HEAD') { + $open = $curBranch; + } elseif ($open === '@s') { + $open = $srcBranch; + } elseif ($open === '@t') { + $open = $tgtBranch; + } } // if ($tgtBranch) { @@ -852,27 +863,21 @@ public function createCommand(FlagsParser $fs, Output $output): void } /** - * update codes from origin and main remote repositories, then push to remote + * update codes from origin and main remote repository, then push to remote * + * @param Output $output * @throws Throwable */ - public function updatePushCommand(): void + public function updatePushCommand(Output $output): void { - // $input->setSOpt('p', true); - // $this->updateCommand($input, $output); - - /* - args: - array(3) { - [0]=> string(2) "updatePush" - } - */ - $args = $this->flags->getRawArgs(); - // add option - do push - $args[] = '--push'; - - // run updateCommand(); - $this->runActionWithArgs('update', $args); + // $args = $this->flags->getRawArgs(); + // // add option - do push + // $args[] = '--push'; + // + // // run updateCommand(); + // $this->runActionWithArgs('update', $args); + + $this->runUpdateByGit(true, $output); } /** @@ -885,6 +890,17 @@ public function updatePushCommand(): void * @param Output $output */ public function updateCommand(FlagsParser $fs, Output $output): void + { + $this->runUpdateByGit($fs->getOpt('push'), $output); + } + + /** + * @param bool $doPush + * @param Output $output + * + * @return void + */ + protected function runUpdateByGit(bool $doPush, Output $output): void { $gitlab = $this->getGitlab(); @@ -900,8 +916,8 @@ public function updateCommand(FlagsParser $fs, Output $output): void $runner->addf('git pull %s master', $gitlab->getMainRemote()); } - if ($fs->getOpt('push')) { - $runner->add('git push'); + if ($doPush) { + $runner->add('git push origin'); } $runner->run(true); diff --git a/script/fnmatch.php b/script/phptests/fnmatch.php similarity index 100% rename from script/fnmatch.php rename to script/phptests/fnmatch.php diff --git a/script/preg_match.php b/script/phptests/preg_match.php similarity index 100% rename from script/preg_match.php rename to script/phptests/preg_match.php diff --git a/script/shtests/list-subdir.sh b/script/shtests/list-subdir.sh new file mode 100644 index 0000000..35af7e4 --- /dev/null +++ b/script/shtests/list-subdir.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +usrKiteDir=~/.kite + +#for dir in $(ls $usrKiteDir/vendor) ; do +for dir in $usrKiteDir/vendor ; do + if [ -d "$dir"]; then + continue + fi + echo $dir +done \ No newline at end of file diff --git a/script/update-kite-deps-by-cp.sh b/script/update-kite-deps-by-cp.sh new file mode 100644 index 0000000..5d046d6 --- /dev/null +++ b/script/update-kite-deps-by-cp.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env sh + +# run: sh script/update-kite-deps-by-cp.sh +set -ex + +tmpKiteDir=~/Workspace/my-github/inhere/kite +usrKiteDir=~/.kite + +cpDeps="cebe clue colinodell gitonomy guzzlehttp http-interop knplabs nette php-http monolog psr symfony" +for dir in $cpDeps ; do + rm -rf $usrKiteDir/vendor/$dir + cp -r $tmpKiteDir/vendor/$dir $usrKiteDir/vendor/ +done diff --git a/script/update-kite-deps.sh b/script/update-kite-deps.sh index a0d9525..1c23e17 100644 --- a/script/update-kite-deps.sh +++ b/script/update-kite-deps.sh @@ -12,4 +12,11 @@ cd $tmpKiteDir || exit 2 composer update cp $tmpKiteDir/composer.lock $usrKiteDir -cp -r $tmpKiteDir/vendor/composer $usrKiteDir/vendor/composer \ No newline at end of file +rm -rf $usrKiteDir/vendor/composer +cp -r $tmpKiteDir/vendor/composer $usrKiteDir/vendor + +cpDeps="cebe clue colinodell gitonomy guzzlehttp http-interop knplabs nette php-http monolog psr symfony" +for dir in $cpDeps ; do + rm -rf $usrKiteDir/vendor/$dir + cp -r $tmpKiteDir/vendor/$dir $usrKiteDir/vendor/ +done diff --git a/script/dev-update-kite.sh b/script/update-kite-dev.sh similarity index 100% rename from script/dev-update-kite.sh rename to script/update-kite-dev.sh