gitMatchesMinimumRequiredVersion() 공개 정적인 메소드

Returns true if git version matches the minimum required version. If minimum required version is not given, RequirementsChecker::GIT_MINIMUM_REQUIRED_VERSION is used by default.
public static gitMatchesMinimumRequiredVersion ( string $gitVersion, string $minimumRequiredVersion = null ) : boolean
$gitVersion string
$minimumRequiredVersion string
리턴 boolean
예제 #1
0
 /**
  * Returns Git info
  *
  * @return array
  */
 public static function getGitInfo()
 {
     $gitBinary = VP_GIT_BINARY;
     $info = [];
     $process = new Process(ProcessUtils::escapeshellarg($gitBinary) . " --version");
     $process->run();
     $info['git-binary-as-configured'] = $gitBinary;
     $info['git-available'] = $process->getErrorOutput() === null || !strlen($process->getErrorOutput());
     if ($info['git-available'] === false) {
         $info['output'] = ['stdout' => trim($process->getOutput()), 'stderr' => trim($process->getErrorOutput())];
         $info['env-path'] = getenv('PATH');
         return $info;
     }
     $output = trim($process->getOutput());
     $match = Strings::match($output, "~git version (\\d[\\d\\.]+\\d).*~");
     $version = $match[1];
     $gitPath = "unknown";
     if ($gitBinary == "git") {
         $osSpecificWhereCommand = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? "where" : "which";
         $process = new Process("{$osSpecificWhereCommand} git");
         $process->run();
         if ($process->isSuccessful()) {
             $gitPath = $process->getOutput();
         }
     } else {
         $gitPath = $gitBinary;
     }
     $info['git-version'] = $version;
     $info['git-binary-as-called-by-vp'] = $gitBinary;
     $info['git-full-path'] = $gitPath;
     $info['versionpress-min-required-version'] = RequirementsChecker::GIT_MINIMUM_REQUIRED_VERSION;
     $info['matches-min-required-version'] = RequirementsChecker::gitMatchesMinimumRequiredVersion($version);
     return $info;
 }
 /**
  * @test
  */
 public function gitCheckPassesForGit220()
 {
     $this->assertTrue(RequirementsChecker::gitMatchesMinimumRequiredVersion("2.2.0", "1.9"));
 }