com web/rmtools: improve git cmd check and take spaces in path into account: include/Git.php
| From: | Anatol Belski | Date: | Thu, 17 Nov 2016 00:16:48 +0000 |
| Subject: | com web/rmtools: improve git cmd check and take spaces in path into account: include/Git.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-25906@lists.php.net to get a copy of this message | ||
Commit: 2258819ac5ba6d4e25506db1d74a9a769a47146b
Author: Anatol Belski <ab@php.net> Thu, 17 Nov 2016 01:16:48 +0100
Parents: c7dde9fdfe2af790d42fea736807231b01a93e6d
Branches: master
Link: http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=2258819ac5ba6d4e25506db1d74a9a769a47146b
Log:
improve git cmd check and take spaces in path into account
Changed paths:
M include/Git.php
Diff:
diff --git a/include/Git.php b/include/Git.php
index d585c85..652882f 100644
--- a/include/Git.php
+++ b/include/Git.php
@@ -11,6 +11,22 @@ class Git {
public function __construct($repo_url)
{
$this->repo_url = $repo_url;
+
+ if (!file_exists($this->git_cmd)) {
+ $git_cmd = trim(shell_exec("where git.exe"));
+ if (!$git_cmd) {
+ throw new \Exception("Git binary not available");
+ }
+ $this->git_cmd = $git_cmd;
+ }
+
+ if (!file_exists($this->tar_cmd)) {
+ $tar_cmd = trim(shell_exec("where tar.exe"));
+ if (!$tar_cmd) {
+ throw new \Exception("Tar binary not available");
+ }
+ $this->tar_cmd = $tar_cmd;
+ }
}
function setModule($module) {
@@ -37,7 +53,7 @@ class Git {
public function getLastCommitId()
{
$try = 3;
- $cmd = $this->git_cmd . ' ls-remote ' . $this->repo_url . '/' .
$this->module . ' ' . $this->branch;
+ $cmd = '"' . $this->git_cmd . '" ls-remote ' .
$this->repo_url . '/' . $this->module . ' ' . $this->branch;
while ( $try > 0 ) {
$res = exec_sep_log($cmd);
if ($res && !empty($res['log_stdout'])) {