Skip to content

Commit

Permalink
✨ feat(gitlab): add new command gl:checkout
Browse files Browse the repository at this point in the history
checkout to new branch and update code to latest
  • Loading branch information
inhere committed Dec 23, 2021
1 parent 34e298a commit aec48b2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/Console/Controller/GitLabController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ protected static function commandAliases(): array
'up' => 'update',
'updatePush' => ['upp', 'up-push'],
'project' => ['pj', 'info'],
'checkout' => ['co'],
];
}

Expand Down Expand Up @@ -330,6 +331,32 @@ public function cloneCommand(FlagsParser $fs, Output $output): void
$output->info('recommend run: `kite gl init` for init some information');
}

/**
* checkout to new branch and update code to latest
*
* @arguments
* branch string;target branch name;true
*
* @options
* --np, --no-push bool;dont push to origin remote after update
*
* @param FlagsParser $fs
* @param Output $output
*/
public function checkoutCommand(FlagsParser $fs, Output $output): void
{
$co = Cmd::git('checkout')
->addArgs($fs->getArg('branch'))
->runAndPrint();

if ($co->isFail()) {
return;
}

$output->notice('update branch code to latest');
$this->runUpdateByGit(!$fs->getOpt('no-push'), $output);
}

/**
* show gitlab config information
*
Expand Down

0 comments on commit aec48b2

Please sign in to comment.