From: Paul J R Date: Wed, 24 Oct 2012 19:54:21 +0000 (+1100) Subject: ok, remote clones are working... i think... need some data validation X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=485cfe9bf50839aef6cd00b766ecda8b82fb3fa3;p=gwvp-mini.git ok, remote clones are working... i think... need some data validation tho and a way of reporting a clone failure... hmmm --- diff --git a/bin/gwvpminicmdtool.php b/bin/gwvpminicmdtool.php index e4f6fe1..9781a8e 100644 --- a/bin/gwvpminicmdtool.php +++ b/bin/gwvpminicmdtool.php @@ -74,6 +74,20 @@ function gwvpcmdtool_Usage() 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 diff --git a/gwvpmini/gwvpmini_db.php b/gwvpmini/gwvpmini_db.php index dbe294f..88c7ee2 100644 --- a/gwvpmini/gwvpmini_db.php +++ b/gwvpmini/gwvpmini_db.php @@ -95,7 +95,7 @@ function gwvpmini_GetActivityLog($nentries = 20, $forid=-1) else return $ret; } - +// TODO: deal with multiple repos from one ownerid function gwvpmini_getRepo($ownerid=null, $name=null, $id=null) { $conn = gwvpmini_ConnectDB(); @@ -371,6 +371,17 @@ function gwvpmini_EnableUser($uid) return $conn->query($sql); } + +function gwvpmini_SetRepoCloning($rid) +{ + $conn = gwvpmini_ConnectDB(); + + if($rid < 0) return; + + $sql = "update repos set repos_status=2 where repos_id='$rid'"; + + return $conn->query($sql); +} function gwvpmini_DisableRepo($rid) { diff --git a/gwvpmini/gwvpmini_gitbackend.php b/gwvpmini/gwvpmini_gitbackend.php index 344d291..66aabb4 100644 --- a/gwvpmini/gwvpmini_gitbackend.php +++ b/gwvpmini/gwvpmini_gitbackend.php @@ -416,6 +416,8 @@ function gwvpmini_repoExists($name) // 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) { @@ -425,7 +427,14 @@ function gwvpmini_createGitRepo($name, $ownerid, $desc, $defperms, $clonefrom, $ 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 {