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;
+
+ $repo_base = gwvpmini_getConfigVal("repodir");
+
+ $from = $argv[1];
+ $to = $argv[2];
+ echo "Would actually clone $from to $to in $data_directory\n";
+ //sleep(20);
+
+ $cmd = "git clone --bare $from $repo_base/$to.git";
+ exec($cmd);
+ $rid = gwvpmini_GetRepoId($to);
+ gwvpmini_EnableRepo($rid);
+ echo "update $to ($rid) and enabled it\n";
}
// update will log things like branch and tag creations
else return $ret;
}
-
+// TODO: deal with multiple repos from one ownerid
function gwvpmini_getRepo($ownerid=null, $name=null, $id=null)\r
{\r
$conn = gwvpmini_ConnectDB();
\r
return $conn->query($sql);\r
}\r
+
+function gwvpmini_SetRepoCloning($rid)\r
+{\r
+ $conn = gwvpmini_ConnectDB();\r
+\r
+ if($rid < 0) return;\r
+\r
+ $sql = "update repos set repos_status=2 where repos_id='$rid'";\r
+\r
+ return $conn->query($sql);\r
+}\r
\r
function gwvpmini_DisableRepo($rid)
{
// 2 - only owner can see anything
function gwvpmini_createGitRepo($name, $ownerid, $desc, $defperms, $clonefrom, $isremoteclone)
{
+ global $cmd_line_tool;
+
$repo_base = gwvpmini_getConfigVal("repodir");
if($clonefrom !== false) {
gwvpmini_AddRepo($name, $desc, $ownerid, $defperms, $clonefrom);
} else {
// we do this from an outside call in the background
- gwvpmini_SendMessage("error", "Cant clone from remote repos yet");
+ $cmd = "/usr/bin/php $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);
+ $rn = gwvpmini_getRepo(null, $name, null);
+ $rid = $rn["id"];
+ gwvpmini_SetRepoCloning($rid);
+ gwvpmini_SendMessage("info", "Background clone initiated for $name ($rid) from $clonefrom... your repo will be available once the background clone is finished");
return false;
}
} else {