Пример #1
0
 /**
  * Get MASTER branch
  *
  * @return string|bool
  */
 protected function getMasterBranch()
 {
     $this->wc = new WorkingCopy($this->path);
     $url = $this->wc->getURL();
     // Find the current branch name
     $current_branch = "trunk";
     $matches = array();
     if (preg_match("@/branches/(.*)@", $url, $matches)) {
         $current_branch = $matches[1];
     }
     $this->master_branch = $current_branch;
     $this->out($this->output, "Current MASTER branch: '<b>{$this->master_branch}</b>'");
     if (!$this->allow_trunk && $this->master_branch == "trunk") {
         $this->out($this->output, "<error>Cannot perform operation: MASTER branch is TRUNK.</error>");
         return false;
     }
     return $this->master_branch;
 }
 /**
  * @see parent::execute()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $branch = $input->getArgument('branch');
     $path = $input->getOption('path');
     if (!is_dir($path)) {
         throw new InvalidArgumentException("'{$path}' is not a valid directory");
     }
     $wc = new WorkingCopy($path);
     $url = $wc->getURL();
     // Find the current branch name
     $current_branch = "trunk";
     $matches = array();
     if (preg_match("@/branches/(.*)@", $url, $matches)) {
         $current_branch = $matches[1];
     }
     $this->out($output, "Current branch: '<b>{$current_branch}</b>'");
     if (!$branch) {
         $branch = $this->getBranch($current_branch, $wc, $output);
     }
     if ($branch != "trunk") {
         $branch = "branches/{$branch}";
     }
     // Switch externals
     $paths = array(".", "modules");
     foreach ($paths as $_path) {
         $this->switchExternal($wc, $branch, $_path, $output);
     }
     $this->out($output, "Externals switched successfuly");
     // Switch working copy ...
     $new_url = $wc->getRepository()->getURL() . "/" . $branch;
     $this->out($output, "Switching working copy to '<b>{$branch}</b>' ...");
     try {
         $wc->sw($new_url);
     } catch (\SVNClient\Exception $e) {
         $output->writeln("<error>" . $e->getMessage() . "</error>");
         return;
     }
     $this->out($output, "Working copy successfuly switched to '<b>{$branch}</b>'");
 }
 /**
  * @see parent::execute()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getOption('path');
     if (!is_dir($path)) {
         throw new InvalidArgumentException("'{$path}' is not a valid directory");
     }
     $wc = new WorkingCopy($path);
     $url = $wc->getURL();
     // Find the current branch name
     $current_branch = "trunk";
     $matches = array();
     if (preg_match("@/branches/(.*)@", $url, $matches)) {
         $current_branch = $matches[1];
     }
     $this->out($output, "Current branch: '<b>{$current_branch}</b>'");
     // Make GPL release.xml
     $dom_release = $this->getReleaseXML($wc, $path, $current_branch);
     file_put_contents("{$path}/release.xml", $dom_release->saveXML());
     $this->out($output, "release.xml file written in: '<b>{$path}/release.xml</b>'");
     $wc->add(array("{$path}/release.xml"));
     $this->out($output, "'<b>{$path}/release.xml</b>' added to version control");
     $other = $input->getOption("other");
     if ($other) {
         $base_path = dirname($other);
         $add_files = array();
         $other_wc = new WorkingCopy($base_path);
         $other_url = $other_wc->getURL();
         // Find the current branch name
         $other_branch = "trunk";
         $matches = array();
         if (preg_match("@/branches/(.*)/@", $other_url, $matches)) {
             $other_branch = $matches[1];
         }
         if ($other_branch != $current_branch) {
             $this->out($output, "<error>WARNING: current branch ({$current_branch}) is not the same as other branch ({$other_branch})</error>");
             return;
         }
         $list = glob($other);
         foreach ($list as $_path) {
             $_dom_release = $this->getReleaseXML($other_wc, $_path, $other_branch);
             file_put_contents("{$_path}/release.xml", $_dom_release->saveXML());
             $add_files[] = "{$_path}/release.xml";
             $this->out($output, "release.xml file written in: '<b>{$_path}/release.xml</b>'");
         }
         $other_wc->add($add_files);
         $this->out($output, count($add_files) . " files added to version control, <b>ready to commit</b> !");
     }
 }