Skip to content

Commit

Permalink
feat: bin path option closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
hdodov committed Jul 20, 2020
1 parent 0c20a6c commit d187bd7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ return [
];
```

### bin

What executable to use. You might need to specify this option if there are multiple versions of Git on the machine.

**Default:** `git`

### repo

Path to a folder containing a Git repo (a `.git` folder).
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

App::plugin('oblik/git', [
'options' => [
'bin' => 'git',
'repo' => kirby()->root('index'),
'remote' => 'origin',
'merge' => 'master',
Expand Down
8 changes: 7 additions & 1 deletion lib/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ class Git
{
protected $config;

/**
* Executable to run.
*/
protected $bin;

/**
* Absolute path to a Git repo.
*/
Expand Down Expand Up @@ -36,6 +41,7 @@ class Git
public function __construct(array $config = [])
{
$this->config = $config;
$this->bin = $this->option('bin');
$this->repo = realpath($this->option('repo'));

if ($this->repo === false) {
Expand All @@ -62,7 +68,7 @@ public function exec(string $command)
{
$code = null;
$output = [];
$cmd = "git -C {$this->repo} {$command} 2>&1";
$cmd = "{$this->bin} -C {$this->repo} {$command} 2>&1";

if ($this->logfile) {
file_put_contents($this->logfile, $cmd . PHP_EOL, FILE_APPEND);
Expand Down

0 comments on commit d187bd7

Please sign in to comment.