diff --git a/src/IDF/Plugin/SyncGit/Serve.php b/src/IDF/Plugin/SyncGit/Serve.php index 67f2d8e..42ba320 100644 --- a/src/IDF/Plugin/SyncGit/Serve.php +++ b/src/IDF/Plugin/SyncGit/Serve.php @@ -191,7 +191,8 @@ class IDF_Plugin_SyncGit_Serve public function initRepository($fullpath) { mkdir($fullpath, 0750, true); - exec(sprintf('git --git-dir=%s init', escapeshellarg($fullpath)), + exec(sprintf(Pluf::f('idf_exec_cmd_prefix', ''). + 'git --git-dir=%s init', escapeshellarg($fullpath)), $out, $res); if ($res != 0) { throw new Exception(sprintf('Init repository error, exit status %d.', $res)); diff --git a/src/IDF/Plugin/SyncMercurial.php b/src/IDF/Plugin/SyncMercurial.php index 7ebf9f5..2bd8a5a 100644 --- a/src/IDF/Plugin/SyncMercurial.php +++ b/src/IDF/Plugin/SyncMercurial.php @@ -79,6 +79,7 @@ class IDF_Plugin_SyncMercurial $output = array(); $cmd = sprintf('hg init %s', escapeshellarg($mercurial_path.'/'.$shortname)); + $cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd; $ll = exec($cmd, $output, $return); return ($return == 0); } diff --git a/src/IDF/Plugin/SyncSvn.php b/src/IDF/Plugin/SyncSvn.php index b3e39d3..aa30bd5 100644 --- a/src/IDF/Plugin/SyncSvn.php +++ b/src/IDF/Plugin/SyncSvn.php @@ -79,6 +79,7 @@ class IDF_Plugin_SyncSvn $output = array(); $cmd = sprintf('svnadmin create %s', escapeshellarg($svn_path.'/'.$shortname)); + $cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd; $ll = exec($cmd, $output, $return); return ($return == 0); } diff --git a/src/IDF/Scm.php b/src/IDF/Scm.php index b03cc07..fcd60c9 100644 --- a/src/IDF/Scm.php +++ b/src/IDF/Scm.php @@ -52,6 +52,7 @@ class IDF_Scm */ public static function exec($command, &$output=array(), &$return=0) { + $command = Pluf::f('idf_exec_cmd_prefix', '').$command; $key = md5($command); $cache = Pluf_Cache::factory(); if (null === ($res=$cache->get($key))) { @@ -74,6 +75,7 @@ class IDF_Scm */ public static function shell_exec($command) { + $command = Pluf::f('idf_exec_cmd_prefix', '').$command; $key = md5($command); $cache = Pluf_Cache::factory(); if (null === ($res=$cache->get($key))) { diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index 4ea1184..ab1f3c4 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -235,7 +235,8 @@ class IDF_Scm_Git */ public function getBlob($request_file_info, $dummy=null) { - return shell_exec(sprintf('GIT_DIR=%s git cat-file blob %s', + return shell_exec(sprintf(Pluf::f('idf_exec_cmd_prefix', ''). + 'GIT_DIR=%s git cat-file blob %s', escapeshellarg($this->repo), escapeshellarg($request_file_info->hash))); } @@ -410,7 +411,8 @@ class IDF_Scm_Git */ public function getArchiveCommand($commit, $prefix='git-repo-dump/') { - return sprintf('GIT_DIR=%s git archive --format=zip --prefix=%s %s', + return sprintf(Pluf::f('idf_exec_cmd_prefix', ''). + 'GIT_DIR=%s git archive --format=zip --prefix=%s %s', escapeshellarg($this->repo), escapeshellarg($prefix), escapeshellarg($commit)); diff --git a/src/IDF/Scm/Mercurial.php b/src/IDF/Scm/Mercurial.php index c059899..5d79a5d 100644 --- a/src/IDF/Scm/Mercurial.php +++ b/src/IDF/Scm/Mercurial.php @@ -398,7 +398,8 @@ class IDF_Scm_Mercurial */ public function getArchiveCommand($commit, $prefix='') { - return sprintf('hg archive --type=zip -R %s -r %s -', + return sprintf(Pluf::f('idf_exec_cmd_prefix', ''). + 'hg archive --type=zip -R %s -r %s -', escapeshellarg($this->repo), escapeshellarg($commit)); } diff --git a/src/IDF/Scm/Svn.php b/src/IDF/Scm/Svn.php index ecdb073..e2f7a61 100644 --- a/src/IDF/Scm/Svn.php +++ b/src/IDF/Scm/Svn.php @@ -369,7 +369,7 @@ class IDF_Scm_Svn */ public function getArchiveCommand($commit, $prefix='git-repo-dump/') { - throw new Exception(('Unsupported feature.')); + throw new Exception('Unsupported feature.'); } diff --git a/src/IDF/conf/idf.php-dist b/src/IDF/conf/idf.php-dist index c9b3288..8aca31f 100644 --- a/src/IDF/conf/idf.php-dist +++ b/src/IDF/conf/idf.php-dist @@ -201,4 +201,11 @@ $cfg['allowed_scm'] = array('git' => 'IDF_Scm_Git', # Extra text files when displaying source # $cfg['idf_extra_text_ext'] = 'ext1 ext2 ext3'; + +# If you can execute the shell commands executed to get info +# from the scm with the user of your PHP process but it is +# not working from within PHP, this can be due to the environment +# variables not being set correctly. Note the trailing space. +# $cfg['idf_exec_cmd_prefix'] = '/usr/bin/env -i '; + return $cfg;