From a47ec0df0a27946132d04e1c027f598c124d2adf Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Sun, 21 Aug 2011 23:54:42 +0200 Subject: [PATCH] If necessary, create git repository on first http access --- src/IDF/Scm/Git.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index 2b75151..c3bd0a0 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -952,6 +952,19 @@ class IDF_Scm_Git extends IDF_Scm $path = $match[2]; + if (!file_exists($this->repo)) { + mkdir($this->repo, 0750, true); + $out = array(); + $res = 0; + exec(sprintf(Pluf::f('idf_exec_cmd_prefix', ''). + Pluf::f('git_path', 'git').' --git-dir=%s init', escapeshellarg($this->repo)), + $out, $res); + if ($res != 0) { + Pluf_Log::error(array('IDF_Scm_Git::repository', $res, $this->repo)); + throw new Exception(sprintf('Init repository error, exit status %d.', $res)); + } + } + // update files before delivering them if (($path == 'objects/info/pack') || ($path == 'info/refs')) { $cmd = sprintf(Pluf::f('idf_exec_cmd_prefix', '').