Exemple #1
0
 /**
  * loads properties from a property file.
  * 
  * @param BuildInterface $build
  * @param string $fileName
  */
 public function parsePropertyFile(BuildInterface $build, $fileName)
 {
     $activeProperty = false;
     $trimNextLine = false;
     $arr = array();
     $fh = fopen($fileName, 'r');
     if (is_resource($fh)) {
         while ($line = fgets($fh)) {
             if (preg_match('/^[!#].*/', $line)) {
                 // comment
             } elseif (preg_match("/^.*?([\\._-\\w]+?)\\s*[=:]+\\s*(.*)\$/", $line, $matches)) {
                 // we have a key definition
                 $activeProperty = true;
                 $key = $matches[1];
                 $valuePart = $matches[2];
                 $arr[$key] = trim($valuePart);
                 if ($arr[$key][strlen($arr[$key]) - 1] == '\\') {
                     $arr[$key] = substr($arr[$key], 0, -1);
                     $trimNextLine = true;
                 } else {
                     $trimNextLine = false;
                 }
             } elseif ($activeProperty) {
                 $trimmed = trim($line);
                 if (empty($trimmed)) {
                     $activeProperty = false;
                     continue;
                 } elseif ($trimNextLine) {
                     $line = $trimmed;
                 } else {
                     $line = rtrim($line);
                 }
                 $arr[$key] .= "\n" . $line;
                 if ($arr[$key][strlen($arr[$key]) - 1] == '\\') {
                     $arr[$key] = substr($arr[$key], 0, -1);
                     $trimNextLine = true;
                 } else {
                     $trimNextLine = false;
                 }
             }
         }
         foreach ($arr as $key => $value) {
             $build->debug('Setting property "${' . $key . '}" to "' . $value . '"');
             $build->setProperty($key, stripcslashes($value));
         }
     } else {
         $build->error('Cannot read from property file: ' . $fileName);
     }
 }
 /**
  * Check if this modification set has been modified
  *
  * @param BuildInterface $build The running build.
  * @return Xinc::Core::Plugin::ModificationSet::Result The result of the check.
  */
 public function checkModified(BuildInterface $build)
 {
     $result = new Result();
     $result->setSource(get_class($this));
     try {
         $this->initSvn();
         $strRemoteVersion = $this->getRemoteVersion();
         $strLocalVersion = $this->getLocalVersion();
     } catch (\VersionControl_SVN_Exception $e) {
         $build->error('Test of Subversion failed: ' . $e->getMessage());
         $build->setStatus(BuildInterface::FAILED);
         $result->setStatus(Result::ERROR);
         return $result;
     }
     $result->setRemoteRevision($strRemoteVersion);
     $result->setLocalRevision($strLocalVersion);
     if ($strRemoteVersion !== $strLocalVersion) {
         try {
             $this->getModifiedFiles($result);
             $this->getChangeLog($result);
             if ($this->doUpdate()) {
                 $this->update($result);
             }
             $result->setStatus(Result::CHANGED);
         } catch (Exception $e) {
             $build->error('Processing SVN failed: ' . $e->getMessage());
             $result->setStatus(Result::FAILED);
         }
     }
     return $result;
 }