/** * 1. Checkout to new branch modvert/test based on origin/test * or movert/develop based on origin/develop * 2. Load remote resources * 3. Show message: * 1. Check changes `git diff --name-only -- storage` * 2. Commit if has changes * 3. Checkout to the main branch (test/develop/feature/QUES-*) * 4. Merge `git merge movert/test` or `git merge movert/develop` * * Если */ public function loadRemote($stage) { /** @var $resource IResource **/ $repository = new Repository(); $driver = new RemoteDriver($stage); $repository->setDriver($driver); if ($repository->isLocked()) { // If remote stage is Locked return $this->output->writeln('<error>Remote stage is locked. Please try again!</error>'); } $storage = new Storage($this->getConnection()); $git = new Git(); $git->setRepository(Application::getInstance()->getAppPath()); $status = $git->status(); $current_branch = $status['branch']; // do not checkout if has unstaged changes if (count($status['changes'])) { return $this->output->writeln('<error>Please commit changes before!</error>'); } $temp_branch = 'modvert/develop'; $parent_branch = 'origin/develop'; try { $git->branch->delete($temp_branch, ['force' => true]); } catch (\Exception $ex) { /** the branch not found */ } $git->checkout->create($temp_branch, $parent_branch); $storage->loadRemote($stage); $storage_changes = ArrayHelper::matchValue($git->status()['changes'], 'file', '/^storage/'); if (count($storage_changes)) { $this->output->writeln('<info>You have unstaged remote changes! Commit them and merge with main branch!</info>'); } else { $git->checkout($current_branch); } }
public function tryToMatchValue(UnitTester $I) { $array = [0 => ["file" => "bin/modvert.web.php", "index" => " ", "work_tree" => "M"], 1 => ["file" => "src/Modvert/Application.php", "index" => " ", "work_tree" => "M"], 2 => ["file" => "tests/unit/ApplicationCest.php", "index" => " ", "work_tree" => "M"], 3 => ["file" => "src/Modvert/Helper/Git.php", "index" => " ", "work_tree" => "M"]]; $expected = ['src/Modvert/Application.php', 'src/Modvert/Helper/Git.php']; $I->assertEquals($expected, ArrayHelper::matchValue($array, 'file', '/^src/')); }