コード例 #1
0
 /**
  * Determine if the current branch should be changed
  *
  * @param string $currentBranch Note, this can be empty
  * @param Version $version
  * @return bool Whether the branch should be changed
  */
 protected function canCheckout($currentBranch, Version $version)
 {
     // Get expected major and minor branches
     $minorBranch = $version->getMajor() . "." . $version->getMinor();
     // Already on ideal branch
     if ($currentBranch === $minorBranch) {
         return false;
     }
     // Branch if doing beta / rc / stable release
     if ($version->isStable() || in_array($version->getStability(), ['beta', 'rc'])) {
         return true;
     }
     return false;
 }
コード例 #2
0
ファイル: Version.php プロジェクト: silverstripe/cow
 /**
  * Compare versions.
  *
  *  (4.0.0 > 4.0.0-alpha1, 4.0.0 < 4.0.1)
  *
  * @param Version $other
  * @return int negative for smaller version, 0 for equal, positive for later version
  */
 public function compareTo(Version $other)
 {
     $diff = $this->getMajor() - $other->getMajor();
     if ($diff) {
         return $diff;
     }
     $diff = $this->getMinor() - $other->getMinor();
     if ($diff) {
         return $diff;
     }
     $diff = $this->getPatch() - $other->getPatch();
     if ($diff) {
         return $diff;
     }
     // Compare stability
     $diff = $this->compareStabliity($this->getStability(), $other->getStability());
     if ($diff) {
         return $diff;
     }
     // Fall back to stability type (e.g. alpha1 vs alpha2)
     $diff = $this->getStabilityVersion() - $other->getStabilityVersion();
     return $diff;
 }
コード例 #3
0
ファイル: Library.php プロジェクト: silverstripe/cow
 /**
  * Get changelog path
  *
  * @param Version $version
  * @return string
  */
 public function getChangelogPath(Version $version)
 {
     $cowData = $this->getCowData();
     // If generating via markdown committed to source control
     if (empty($cowData['changelog-path'])) {
         return null;
     }
     $path = Format::formatString($cowData['changelog-path'], ['stability' => $version->getStability(), 'stabilityVersion' => $version->getStabilityVersion(), 'major' => $version->getMajor(), 'minor' => $version->getMinor(), 'patch' => $version->getPatch(), 'version' => $version->getValue(), 'versionStable' => $version->getValueStable()]);
     // Collapse duplicate //
     return str_replace('//', '/', $path);
 }