/** * Test args json serialization. */ public function testJsonSerialize() { $arg = new Args(); $arg->setCommand('cmd')->setOpt('opt1', 123)->setOpt('opt2', 456)->setMeta('met', 'a')->setArgs([1, 2, 3]); $json = json_encode($arg); $this->assertEquals(['command' => 'cmd', 'opts' => ['opt1' => 123, 'opt2' => 456], 'args' => [1, 2, 3], 'meta' => ['met' => 'a']], json_decode($json, true)); }
protected function mergeFromCommand(Args $args) { $target = $args->getArg('target'); if (!static::git_branch_exists($target)) { throw new \RuntimeException("Target branch {$target} does not exist", -1); } $dirty = null; $branch = static::git_current_branch($dirty); static::write_ln("Current branch: {$branch}"); $text = ''; if ($dirty) { static::write_ln("You have uncommitted work !"); static::write($dirty); static::write_ln('---'); $text = static::read_text('Enter a commit description', ''); } $texts = ['commit' => $text, 'mergeback' => "Merge {$target}"]; foreach ($texts as &$text) { $text = "-m \"{$text}\""; } static::write_ln(); if ($dirty) { static::write_ln("# You should commit your work :"); static::write_ln("git add -A"); static::write_ln("git commit -a {$texts['commit']}"); } if ($target == $this->config['develop_branch'] || $target == $this->config['master_branch']) { static::write_ln("# We will pull {$target} before all"); static::write_ln("git checkout {$target}"); static::write_ln("git pull"); static::write_ln("git checkout {$branch}"); } static::write_ln("git merge --no-ff {$target} {$texts['mergeback']}"); $this->disclaimer(); }