}
-function gwvp_repoPermissionCheck()
+function gwvp_repoPermissionCheck($repo, $user)
{
return true;
}
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;
}
$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 <b>\"$reponame\"</b> 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");
}
echo "<table>";
echo "<tr><td>Repository Name</td><td><input type=\"text\" name=\"reponame\" value=\"$reponameobv\"></td></tr>";
echo "<tr><td>Repository Description</td><td><input type=\"text\" name=\"repodesc\" value=\"$repodescobv\"></td></tr>";
- echo "<tr><td>Repository Bundle</td><td><input type=\"file\" name=\"bundlefile\"></td><td><i>Create a bundle for pro-creating the git repository</i></td></tr>";
+ echo "<tr><td>Repository Bundle</td><td><input type=\"file\" name=\"bundlefile\"></td><td><i>Create a bundle for pro-creating the git repository (export your git bundle with \"git bundle create /tmp/filename --branches\")</i></td></tr>";
echo "</table>";
echo "<input type=\"submit\" name=\"create\" value=\"Create\"><br>";
echo "</form>";