From 0a0b03b67435c01c1059f4b084dd6b07aeae81e3 Mon Sep 17 00:00:00 2001 From: paulr Date: Sat, 5 Nov 2011 05:09:51 +1100 Subject: [PATCH] added the ability to clone a repo via a bundle... tonnes of fun that one, but still should work. cloning from a repo that has been created this way actually works, so im reasonably happy with it atm --- gwvplib/gwvpgitcontrol.php | 17 ++++++++++++++--- gwvplib/gwvplib.php | 2 +- gwvplib/gwvprepoadmin.php | 15 +++++++-------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/gwvplib/gwvpgitcontrol.php b/gwvplib/gwvpgitcontrol.php index 2755859..68935a2 100644 --- a/gwvplib/gwvpgitcontrol.php +++ b/gwvplib/gwvpgitcontrol.php @@ -22,7 +22,7 @@ function gwvp_gitControlCallMe() } -function gwvp_repoPermissionCheck() +function gwvp_repoPermissionCheck($repo, $user) { return true; } @@ -127,11 +127,22 @@ function gwvp_repoExists($name) else return false; } -function gwvp_createGitRepo($name) +function gwvp_createGitRepo($name, $bundle=null) { global $repo_base; - error_log("would create $repo_base/$name.git"); + // phew, this works, but i tell you this - bundles arent quite as nice as they should be + if($bundle == null) { + error_log("would create $repo_base/$name.git"); + exec("/usr/bin/git init $repo_base/$name.git --bare > /tmp/gitlog 2>&1"); + chdir("$repo_base/$name.git"); + exec("/usr/bin/git update-server-info"); + } else { + error_log("create via mirror on $repo_base/$name.git"); + exec("/usr/bin/git clone --mirror $bundle $repo_base/$name.git > /tmp/gitlog 2>&1"); + chdir("$repo_base/$name.git"); + exec("/usr/bin/git update-server-info"); + } return true; } diff --git a/gwvplib/gwvplib.php b/gwvplib/gwvplib.php index 693486c..526c9cc 100644 --- a/gwvplib/gwvplib.php +++ b/gwvplib/gwvplib.php @@ -15,7 +15,7 @@ require_once("gwvpgitcontrol.php"); require_once("gwvppluginloader.php"); // only enable this if you need it: -require_once("gwvpdebug.php"); +// require_once("gwvpdebug.php"); ?> \ No newline at end of file diff --git a/gwvplib/gwvprepoadmin.php b/gwvplib/gwvprepoadmin.php index 1ecf30b..7a0b10c 100644 --- a/gwvplib/gwvprepoadmin.php +++ b/gwvplib/gwvprepoadmin.php @@ -53,19 +53,18 @@ function gwvp_DoCreateRepoPage() $reponame = $_REQUEST["reponame"]; $repodesc = $_REQUEST["repodesc"]; + // TODO: this code is bollocks, need to redo if(gwvp_repoExists($reponame)) { gwvp_SendMessage("error", "a repository with the name \"$reponame\" already exists"); //header("Location: $BASE_URL/admin/repos/create?reponameobv=$reponame&repodescobv=$repodesc"); + } else if($_FILES["bundlefile"]["size"] > 0) { // if(isset($_FILES["bundlefile"]["size"])) <--- this needs to happen here TODO + error_log("bundle file tmpname is ".$_FILES["bundlefile"]["tmp_name"]); + gwvp_createGitRepo($reponame, $_FILES["bundlefile"]["tmp_name"]); + gwvp_SendMessage("info", "Repo, $reponame, created"); } else if(gwvp_createGitRepo($reponame)) { - if(isset($_FILES["bundlefile"]["size"])) { - //error_log("bundle file name is ".$_FILES["bundlefile"]["size"]); - if($_FILES["bundlefile"]["size"] > 0) { - error_log("bundle file tmpname is ".$_FILES["bundlefile"]["tmp_name"]); - } - } gwvp_SendMessage("info", "Repo, $reponame, created"); - //header("Location: $BASE_URL/admin/repos"); } + header("Location: $BASE_URL/admin/repos"); } @@ -85,7 +84,7 @@ function gwvp_CreateRepoPageBody() echo ""; echo ""; echo ""; - echo ""; + echo ""; echo "
Repository Name
Repository Description
Repository BundleCreate a bundle for pro-creating the git repository
Repository BundleCreate a bundle for pro-creating the git repository (export your git bundle with \"git bundle create /tmp/filename --branches\")
"; echo "
"; echo ""; -- 1.7.0.4