$BASE_URL = "/";\r
global $WEB_ROOT_FS, $BASE_URL, $IS_WEB_REQUEST, $data_directory, $db_type, $db_name, $db_username, $db_password, $IS_WEB_REQUEST, $cmd_line_tool;
+global $git_backend_cmd, $git_cli_cmd, $php_cli_cmd, $data_directory, $cmd_line_tool;\r
+
$IS_WEB_REQUEST = false;\r
if(file_exists("$WEB_ROOT_FS/../www/config.php")) require_once("$WEB_ROOT_FS/../www/config.php");
function gwvpcmdtool_BackGroundClone()
{
// here we parse arguments and have stuff with things and its 6am why am i doing this right now?
- global $data_directory, $argv;
+ global $data_directory, $argv, $git_backend_cmd, $git_cli_cmd, $php_cli_cmd, $data_directory, $cmd_line_tool;
$repo_base = gwvpmini_getConfigVal("repodir");
echo "Would actually clone $from to $to in $data_directory\n";
//sleep(20);
- $cmd = "git clone --bare $from $repo_base/$to.git";
+ $cmd = "$git_cli_cmd clone --bare $from $repo_base/$to.git";
exec($cmd);
$rn = gwvpmini_getRepo(null, $to, null);
$rid = $rn["id"];
// update will log things like branch and tag creations
function gwvpcmdtool_UpdateHook()
{
- global $argv;
+ global $argv, $git_backend_cmd, $git_cli_cmd, $php_cli_cmd, $data_directory, $cmd_line_tool;
//echo "got ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";
if(preg_match("/^000000+$/", $argv[5])) {
// createion of tag or branch
// pre-receive logs all commit info
function gwvpcmdtool_PreReceive()
{
- global $argv;
+ global $argv, $git_backend_cmd, $git_cli_cmd, $php_cli_cmd, $data_directory, $cmd_line_tool;
//echo "got from prereceive ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";\r
$regspl = explode("/", $ref);
$branch = $regspl[2];
- $fp = popen("git rev-list --reverse ".$argv[5]." --not --all ", "r");
+ $fp = popen("$git_cli_cmd rev-list --reverse ".$argv[5]." --not --all ", "r");
if($fp) while(!feof($fp)) {
$line = trim(fgets($fp));
if($line != "") {
function gwvpcmdtool_getCommitIdDetails($commitid)
{
- $rs = popen("git log --pretty=format:\"%at%n%ce%n%an%n%s\" $commitid -1 2> /dev/null", "r");
+ global $git_backend_cmd, $git_cli_cmd, $php_cli_cmd, $data_directory, $cmd_line_tool;
+
+ $rs = popen("$git_cli_cmd log --pretty=format:\"%at%n%ce%n%an%n%s\" $commitid -1 2> /dev/null", "r");
$ret = array();\r
if($rs) {\r
$ret["date"] = trim(fgets($rs));\r
function gwvpmini_gitBackendInterface()
{
// and this is where i re-code the git backend interface from scratch
- global $BASE_URL, $cmd_line_tool;
+ global $BASE_URL, $cmd_line_tool, $git_cli_cmd;
header_remove("Pragma");\r
header_remove("Cache-Control");\r
// TODO: this whole bit needs a re-write - seriously, like totally!
function gwvpmini_callGitBackend($username, $repo)
{
+
+ global $git_backend_cmd, $git_cli_cmd, $php_cli_cmd, $data_directory, $cmd_line_tool;\r
+
// this is where things become a nightmare
$fh = fopen('php://input', "r");
$pwd = "/$repo_base/";
- $proc = proc_open("/usr/lib/git-core/git-http-backend", array(array("pipe","rb"),array("pipe","wb"),array("file","/tmp/err", "a")), $pipes, $pwd, $procenv);
+ $proc = proc_open("$git_backend_cmd", array(array("pipe","rb"),array("pipe","wb"),array("file","/tmp/err", "a")), $pipes, $pwd, $procenv);
$untilblank = false;
while(!$untilblank&&!feof($pipes[1])) {
// 2 - only owner can see anything
function gwvpmini_createGitRepo($name, $ownerid, $desc, $defperms, $clonefrom, $isremoteclone)
{
- global $cmd_line_tool;
+ global $cmd_line_tool,$git_cli_cmd,$php_cli_cmd;
$repo_base = gwvpmini_getConfigVal("repodir");
if($clonefrom !== false) {
error_log("how did i end up in clonefrom? $clonefrom");
if(!$isremoteclone) {
- exec("/usr/bin/git clone --bare $repo_base/$clonefrom.git $repo_base/$name.git >> /tmp/gitlog 2>&1");
+ exec("$git_cli_cmd clone --bare $repo_base/$clonefrom.git $repo_base/$name.git >> /tmp/gitlog 2>&1");
gwvpmini_AddRepo($name, $desc, $ownerid, $defperms, $clonefrom);
} else {
// we do this from an outside call in the background
- $cmd = "/usr/bin/php $cmd_line_tool $clonefrom $name backgroundclone >> /tmp/gitlog 2>&1 &";
+ $cmd = "$php_cli_cmd $cmd_line_tool $clonefrom $name backgroundclone >> /tmp/gitlog 2>&1 &";
error_log("cmd called as $cmd");
exec($cmd);
gwvpmini_AddRepo($name, $desc, $ownerid, $defperms, $clonefrom);
// phew, this works, but i tell you this - bundles arent quite as nice as they should be
// error_log("would create $repo_base/$name.git");
- exec("/usr/bin/git init $repo_base/$name.git --bare >> /tmp/gitlog 2>&1");
+ exec("$git_cli_cmd init $repo_base/$name.git --bare >> /tmp/gitlog 2>&1");
chdir("$repo_base/$name.git");
- exec("/usr/bin/git update-server-info");
+ exec("$git_cli_cmd update-server-info");
// gwvpmini_AddRepo($reponame, $repodesc, $repoowner, $defaultperms = 0)
gwvpmini_AddRepo($name, $desc, $ownerid, $defperms, $clonefrom);
return $compressedcid;
}
+
+function gwvpmini_GetCommitDetail($repo, $commitid)
+{
+ global $cmd_line_tool,$git_cli_cmd,$php_cli_cmd;
+
+ $repo_base = gwvpmini_getConfigVal("repodir");
+
+ $cmd = "$cmd_line_tool --git-dir=$repo_base/$repo.git log $commitid -1 --format='%an'";
+ exec($cmd, $commitername, $returnvar);
+
+ $cmd = "$cmd_line_tool --git-dir=$repo_base/$repo.git log $commitid -1 --format='%ae'";
+ exec($cmd, $commiteremail, $returnvar);
+
+ $cmd = "$cmd_line_tool --git-dir=$repo_base/$repo.git log $commitid -1 --format='%ct'";
+ exec($cmd, $commitertime, $returnvar);
+
+ $cmd = "$cmd_line_tool --git-dir=$repo_base/$repo.git log $commitid -1 --format='%s'";
+ exec($cmd, $commiterlog, $returnvar);
+
+ $cmd = "$cmd_line_tool --git-dir=$repo_base/$repo.git log $commitid -1 --format='%b'";
+ exec($cmd, $commiterbody, $returnvar);
+}
+
+function gwvpmini_GetCommitList($repo, $branch, $num=20)
+{
+ global $cmd_line_tool,$git_cli_cmd,$php_cli_cmd;
+
+ $repo_base = gwvpmini_getConfigVal("repodir");
+
+ $cmd = "$cmd_line_tool --git-dir=$repo_base/$repo.git log $commitid -1 --format='%an'";\r
+ exec($cmd, $commitername, $returnvar);\r
+
+}
+
+function gwvpmini_GetRefList($repo)
+{
+ global $cmd_line_tool,$git_cli_cmd,$php_cli_cmd;
+
+ $repo_base = gwvpmini_getConfigVal("repodir");
+
+ $cmd = "$cmd_line_tool --git-dir=$repo_base/$repo.git for-each-ref $commitid --format='%(objecttype):%(objectname):%(refname)'";
+ exec($cmd, $reflist, $returnvar);
+}
?>
\ No newline at end of file
$cmd_line_tool = realpath("../bin/gwvpminicmdtool.php");
+$git_backend_cmd = "/usr/lib/git-core/git-http-backend";
+$git_cli_cmd = "/usr/bin/git";
+$php_cli_cmd = "/usr/bin/php";
+
//error_log("included config file");
?>
\ No newline at end of file
$BASE_URL = dirname($_SERVER["PHP_SELF"]);\r
\r
global $WEB_ROOT_FS, $BASE_URL, $data_directory, $db_type, $db_name, $db_username, $db_password, $IS_WEB_REQUEST, $cmd_line_tool;
+global $git_backend_cmd, $git_cli_cmd, $php_cli_cmd, $data_directory, $cmd_line_tool;\r
$IS_WEB_REQUEST = true;\r