static function &create_new($repo_path, $gitdir = null, $source = null, $remote_source = false, $reference = null) { if ($gitdir && is_dir($gitdir) || is_dir($repo_path) && is_dir($repo_path . "/.git")) { throw new \Exception('"' . $repo_path . '" is already a git repository'); } else { $repo = new self($repo_path, $gitdir, true, false); if (is_string($source)) { if ($remote_source) { if (!is_dir($reference) || !is_dir($reference . '/.git')) { throw new \Exception('"' . $reference . '" is not a git repository. Cannot use as reference.', 1); } else { if (strlen($reference)) { $reference = realpath($reference); $reference = "--reference {$reference}"; } } $repo->clone_remote($source, $reference); } else { $repo->clone_from($source); } } else { $repo->run('init'); } return $repo; } }
/** * Create a new git repository * * Accepts a creation path, and, optionally, a source path * * @access public * @param string repository path * @param string directory to source * @return GitRepo */ public static function &create_new($repo_path, $source = null) { if (is_dir($repo_path) && file_exists($repo_path . "/.git") && is_dir($repo_path . "/.git")) { throw new Exception('"' . $repo_path . '" is already a git repository'); } else { $repo = new self($repo_path, true, false); if (is_string($source)) { $repo->clone_from($source); } else { $repo->run('init'); } return $repo; } }