From: Paul J R Date: Tue, 2 Oct 2012 03:51:59 +0000 (+1000) Subject: adding the ability to clone from an existing source to create a new repo X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=c06a72c606faf4936f044c3d42372989ad3851ec;p=gwvp-mini.git adding the ability to clone from an existing source to create a new repo --- diff --git a/gwvpmini/gwvpmini_db.php b/gwvpmini/gwvpmini_db.php index 82abfda..d3d1057 100644 --- a/gwvpmini/gwvpmini_db.php +++ b/gwvpmini/gwvpmini_db.php @@ -532,6 +532,7 @@ function gwvpmini_dbCreateSQLiteStructure($dbloc) "repos_owner" INTEGER, "repos_perms" TEXT, "repos_status" TEXT, + "repos_origin" TEXT, UNIQUE(repos_name) )'; @@ -752,7 +753,7 @@ function gwvpmini_setConfigVal($confname, $confval) return $conn->query($sql); } -function gwvpmini_AddRepo($name, $desc, $ownerid) +function gwvpmini_AddRepo($name, $desc, $ownerid, $clonefrom) { // error_log("addrepo in db for $name, $desc, $ownerid"); @@ -761,8 +762,10 @@ function gwvpmini_AddRepo($name, $desc, $ownerid) $perms["b"] = "a"; $encperms = base64_encode(serialize($perms)); + + if($clonefrom === false) $clonefrom = ""; - $sql = "insert into repos values (null, '$name', '$desc', '$ownerid', '$encperms', 0)"; + $sql = "insert into repos values (null, '$name', '$desc', '$ownerid', '$encperms', 0, '$clonefrom')"; $conn->query($sql); } diff --git a/gwvpmini/gwvpmini_gitbackend.php b/gwvpmini/gwvpmini_gitbackend.php index 8e4dc5f..f55038c 100644 --- a/gwvpmini/gwvpmini_gitbackend.php +++ b/gwvpmini/gwvpmini_gitbackend.php @@ -413,7 +413,7 @@ function gwvpmini_repoExists($name) // 0 - anyone can clone/read, only owner can write // 1 - noone can clone/read, repo is visible (i.e. name), only owner can read/write repo // 2 - only owner can see anything -function gwvpmini_createGitRepo($name, $ownerid, $desc) +function gwvpmini_createGitRepo($name, $ownerid, $desc, $clonefrom) { $repo_base = gwvpmini_getConfigVal("repodir"); @@ -424,7 +424,7 @@ function gwvpmini_createGitRepo($name, $ownerid, $desc) exec("/usr/bin/git update-server-info"); // gwvpmini_AddRepo($reponame, $repodesc, $repoowner, $defaultperms = 0) - gwvpmini_AddRepo($name, $desc, $ownerid); + gwvpmini_AddRepo($name, $desc, $ownerid, $clonefrom); return true; } diff --git a/gwvpmini/gwvpmini_gitrepo.php b/gwvpmini/gwvpmini_gitrepo.php index 46c4f95..6584109 100644 --- a/gwvpmini/gwvpmini_gitrepo.php +++ b/gwvpmini/gwvpmini_gitrepo.php @@ -186,6 +186,7 @@ function gwvpmini_GitCreateRepoForm() echo ""; echo ""; echo ""; + echo "Clone From"; echo ""; echo ""; echo ""; @@ -211,6 +212,13 @@ function gwvpmini_RepoCreate() $inputcheckerror = "Repo name contains invalid characters, repos can only contain a-z, A-Z, 0-9, _, - and ."; } + $clonefrom = false; + if(isset($_REQUEST["clonefrom"])) { + if($_REQUEST["clonefrom"] != "") { + $clonefrom = $_REQUEST["clonefrom"]; + } + } + if(!$inputcheck) { gwvpmini_SendMessage("error", "$inputcheckerror"); header("Location: $BASE_URL/repos"); @@ -220,7 +228,7 @@ function gwvpmini_RepoCreate() gwvpmini_SendMessage("error", "Repo ".$_REQUEST["reponame"]." already exists"); header("Location: $BASE_URL/repos"); } else { - gwvpmini_createGitRepo($_REQUEST["reponame"], $_SESSION["id"], $_REQUEST["repodesc"], $_REQUEST["perms"]); + gwvpmini_createGitRepo($_REQUEST["reponame"], $_SESSION["id"], $_REQUEST["repodesc"], $_REQUEST["perms"], $clonefrom); gwvpmini_SendMessage("info", "Repo ".$_REQUEST["reponame"]." has been created"); header("Location: $BASE_URL/repos"); }