public function testGetArg() { $args = new Args(); $args->addArg('bar', 'foo'); $this->assertSame('bar', $args->getArg('foo')); $this->assertSame('bar', $args->getArg(0)); $this->assertSame('default', $args->getArg('baz', 'default')); }
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(); }