1 | <?php |
||
30 | class GitBinary |
||
31 | { |
||
32 | /** |
||
33 | * the path to the repository |
||
34 | * |
||
35 | * @var string $path |
||
36 | */ |
||
37 | private $path; |
||
38 | |||
39 | /** |
||
40 | * Class constructor |
||
41 | * |
||
42 | * @param null $path the physical path to the git binary |
||
43 | */ |
||
44 | 103 | public function __construct($path = null) |
|
45 | { |
||
46 | 103 | if (is_null($path)) { |
|
47 | 102 | $cmd = (Utilities::isWindows() ? "where" : "which") . " git"; |
|
48 | 102 | $path = exec($cmd); |
|
49 | |||
50 | // Escape spaces in the binary path for windows |
||
51 | 102 | if(Utilities::isWindows()) { |
|
|
|||
52 | $path = '"'.$path.'"'; |
||
53 | } |
||
54 | 102 | } |
|
55 | 103 | $this->setPath($path); |
|
56 | 103 | } |
|
57 | |||
58 | /** |
||
59 | * path getter |
||
60 | * returns the path of the binary |
||
61 | * |
||
62 | * @return mixed |
||
63 | */ |
||
64 | 99 | public function getPath() |
|
68 | |||
69 | /** |
||
70 | * path setter |
||
71 | * |
||
72 | * @param string $path the path to the system git binary |
||
73 | */ |
||
74 | 103 | public function setPath($path) |
|
78 | } |
||
79 |