From 64781bdbf8cbe789d349418253ce34efa43ad884 Mon Sep 17 00:00:00 2001 From: Paul J R Date: Fri, 19 Oct 2012 05:45:59 +1100 Subject: [PATCH] adding the ability to clone from an existing repo and maintain some form of heirachy between them --- gwvpmini/gwvpmini_chat.php | 2 +- gwvpmini/gwvpmini_gitbackend.php | 17 +++++++++++------ gwvpmini/gwvpmini_gitrepo.php | 30 +++++++++++++++++++++++++----- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/gwvpmini/gwvpmini_chat.php b/gwvpmini/gwvpmini_chat.php index 38e7250..ea775e4 100644 --- a/gwvpmini/gwvpmini_chat.php +++ b/gwvpmini/gwvpmini_chat.php @@ -2,7 +2,7 @@ function gwvpmini_DisplayChat() { - echo "
Blah!
"; + echo "
Chat box!
"; } ?> \ No newline at end of file diff --git a/gwvpmini/gwvpmini_gitbackend.php b/gwvpmini/gwvpmini_gitbackend.php index f55038c..e95ce1e 100644 --- a/gwvpmini/gwvpmini_gitbackend.php +++ b/gwvpmini/gwvpmini_gitbackend.php @@ -417,14 +417,19 @@ function gwvpmini_createGitRepo($name, $ownerid, $desc, $clonefrom) { $repo_base = gwvpmini_getConfigVal("repodir"); + if($clonefrom !== false) { + + } else { + // 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"); - chdir("$repo_base/$name.git"); - exec("/usr/bin/git update-server-info"); - - // gwvpmini_AddRepo($reponame, $repodesc, $repoowner, $defaultperms = 0) - gwvpmini_AddRepo($name, $desc, $ownerid, $clonefrom); + 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"); + + // gwvpmini_AddRepo($reponame, $repodesc, $repoowner, $defaultperms = 0) + gwvpmini_AddRepo($name, $desc, $ownerid, $clonefrom); + } return true; } diff --git a/gwvpmini/gwvpmini_gitrepo.php b/gwvpmini/gwvpmini_gitrepo.php index 6584109..d642c92 100644 --- a/gwvpmini/gwvpmini_gitrepo.php +++ b/gwvpmini/gwvpmini_gitrepo.php @@ -63,6 +63,9 @@ function gwvpmini_RepoMainPageBody() foreach($repos as $repo) { $name = $repo["name"]; $desc = $repo["desc"]; + + if($desc == "") $desc = "none"; + $repo_base = gwvpmini_getConfigVal("repodir"); $cmd = "git --git-dir=\"$repo_base/$name.git\" log --all -1 2> /dev/null"; echo "$name$desc"; @@ -148,6 +151,8 @@ function gwvpmini_GitLogProvider() foreach($repos as $repo) { $name = $repo["name"]; $desc = $repo["desc"]; + + if($desc == "") $desc = "-"; echo "$name$desc"; echo ""; $repo_base = gwvpmini_getConfigVal("repodir"); @@ -178,16 +183,15 @@ function gwvpmini_GitCreateRepoForm() echo "
"; echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; - echo ""; + echo ""; + echo ""; echo ""; echo "
Create Repo
Repo Name
Repo Description
Repo NameName of your repo - letters, numbers _ and - only
Repo DescriptionDescription of your repo
Read Permissions"; echo ""; - echo "
Clone From
The basic permissions for the initial repo creation
Clone FromEither a repo name (existing on this site) or a git url to clone from (blank for none)
"; echo "
"; @@ -201,6 +205,7 @@ function gwvpmini_RepoCreate() // TODO: check the stuff out // first reponame $inputcheck = true; + // remove a .git at the end if it was input $_REQUEST["reponame"] = preg_replace("/\.git$/", "", $_REQUEST["reponame"]); @@ -213,9 +218,24 @@ function gwvpmini_RepoCreate() } $clonefrom = false; + $fromremote = false; if(isset($_REQUEST["clonefrom"])) { if($_REQUEST["clonefrom"] != "") { $clonefrom = $_REQUEST["clonefrom"]; + if(preg_match("/git.*:\/\/.*/", $clonefrom)>0) { + $fromremote = true; + } + if(preg_match("/http.*\:\/\//", $clonefrom)>0) $fromremote = true; + } + } + + if($clonefrom !== false && $fromremote == false) { + // check the local repo exists + $rn = gwvpmini_getRepo(null, $clonefrom, null); + if($rn == false) { + gwvpmini_SendMessage("error", "local repo $clonefrom given as upstream clone, however $clonefrom doesnt exist on this site"); + header("Location: $BASE_URL/repos"); + return; } } -- 1.7.0.4