Skip to content

Commit e12f8eb

Browse files
committed
There is a method to set git binary statically.
1 parent b1d8c94 commit e12f8eb

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

Git.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@
2727
*/
2828
class Git {
2929

30+
/**
31+
* Git executable location
32+
* @var string
33+
*/
34+
protected static $bin = '/usr/bin/git';
35+
36+
/**
37+
* Sets git executable path
38+
*
39+
* @param string $path executable location
40+
*/
41+
public static function set_bin($path)
42+
{
43+
self::$bin = $path;
44+
}
45+
46+
/**
47+
* Gets git executable path
48+
*/
49+
public static function get_bin()
50+
{
51+
return self::$bin;
52+
}
53+
3054
/**
3155
* Create a new git repository
3256
*
@@ -83,8 +107,6 @@ class GitRepo {
83107

84108
protected $repo_path = null;
85109

86-
public $git_path = '/usr/bin/git';
87-
88110
/**
89111
* Create a new git repository
90112
*
@@ -178,7 +200,7 @@ public function test_git() {
178200
2 => array('pipe', 'w'),
179201
);
180202
$pipes = array();
181-
$resource = proc_open($this->git_path, $descriptorspec, $pipes);
203+
$resource = proc_open(Git::get_bin(), $descriptorspec, $pipes);
182204

183205
$stdout = stream_get_contents($pipes[1]);
184206
$stderr = stream_get_contents($pipes[2]);
@@ -229,7 +251,7 @@ protected function run_command($command) {
229251
* @return string
230252
*/
231253
public function run($command) {
232-
return $this->run_command($this->git_path." ".$command);
254+
return $this->run_command(Git::get_bin()." ".$command);
233255
}
234256

235257
/**

0 commit comments

Comments
 (0)