X-Git-Url: http://git.pjr.cc/?p=gwvp-mini.git;a=blobdiff_plain;f=gwvpmini%2Fgwvpmini_gitrepo.php;h=3c195073cf5a751f9501cc05bc32f1187f435a0f;hp=3ea498cba3a6f31899851ab88f50822816bf972e;hb=HEAD;hpb=5433c422794029259de4512640485aeb650e0c87
diff --git a/gwvpmini/gwvpmini_gitrepo.php b/gwvpmini/gwvpmini_gitrepo.php
index 3ea498c..3c19507 100644
--- a/gwvpmini/gwvpmini_gitrepo.php
+++ b/gwvpmini/gwvpmini_gitrepo.php
@@ -3,7 +3,7 @@ global $HOME_PAGE_PROVIDERS;
$CALL_ME_FUNCTIONS["repoadmin"] = "gwvpmini_RepoCallMe";
-$HOME_PAGE_PROVIDERS["gitlog"] = "gwvpmini_GitLogProvider";
+$HOME_PAGE_PROVIDERS["00gitlog"] = "gwvpmini_GitLogProvider";
// the home_page_provders bit is an array
@@ -15,15 +15,15 @@ $MENU_ITEMS["10repos"]["link"] = "$BASE_URL/repos";
function gwvpmini_RepoCallMe()
{
- error_log("in repoadmin callme - err?");
- error_log(print_r($_REQUEST, true));
+ // error_log("in repoadmin callme - err?");
+ // error_log(print_r($_REQUEST, true));
if(isset($_REQUEST["q"])) {
- error_log("in repoadmin callme, for Q");
+ // error_log("in repoadmin callme, for Q");
$query = $_REQUEST["q"];
$qspl = explode("/", $query);
if(isset($qspl[0])) {
if($qspl[0] == "repos") {
- error_log("in repos call");
+ // error_log("in repos call");
if(isset($qspl[1])) {
if($qspl[1] == "create") {
return "gwvpmini_RepoCreate";
@@ -31,7 +31,7 @@ function gwvpmini_RepoCallMe()
return "gwvpmini_RepoMainPage";
}
} else {
- error_log("i got here, where next?");
+ // error_log("i got here, where next?");
return "gwvpmini_RepoMainPage";
}
} else return false;
@@ -54,8 +54,8 @@ function gwvpmini_RepoMainPageBody()
global $BASE_URL;
if(gwvpmini_isLoggedIn()) {
- gwvpmini_GitCreateRepoForm();
$repos = gwvpmini_GetOwnedRepos($_SESSION["username"]);
+ error_log("repos, ".print_r($repos, true));
if(!$repos) {
echo "You currently own no repos
";
} else {
@@ -64,21 +64,83 @@ function gwvpmini_RepoMainPageBody()
foreach($repos as $repo) {
$name = $repo["name"];
$desc = $repo["desc"];
- echo "
$name | $desc | ";
echo "";
$repo_base = gwvpmini_getConfigVal("repodir");
- $cmd = "git --git-dir=\"$repo_base/$name.git\" log -1 2> /dev/null";
- error_log("CMD: $cmd");
+ $cmd = "$git_cli_cmd --git-dir=\"$repo_base/$name.git\" log --all -1 2> /dev/null";
+ // error_log("CMD: $cmd");
//system("$cmd");
$fls = popen($cmd, "r");
$tks = "";
@@ -143,15 +208,15 @@ function gwvpmini_GitCreateRepoForm()
echo "";
@@ -165,6 +230,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"]);
@@ -176,6 +242,47 @@ function gwvpmini_RepoCreate()
$inputcheckerror = "Repo name contains invalid characters, repos can only contain a-z, A-Z, 0-9, _, - and .";
}
+ $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);
+ $uid = $_SESSION["id"];
+
+ if($rn == false) {
+ gwvpmini_SendMessage("error", "local repo $clonefrom given as upstream clone, however $clonefrom doesnt exist on this site (or you cant read it unbake)");
+ header("Location: $BASE_URL/repos");
+ return;
+ }
+
+ // resolve repo permissions on the read/clone
+ if(gwvpmini_GetRepoPerm($rn["id"], $uid) < 1) {
+ gwvpmini_SendMessage("error", "local repo $clonefrom given as upstream clone, however $clonefrom doesnt exist on this site (or you cant read it bake)");
+ header("Location: $BASE_URL/repos");
+ return;
+ }
+ }
+
+ $defperms = "a";
+ switch($_REQUEST["perms"]) {
+ case "perms-registered":
+ $defperms = "r";
+ break;
+ case "perms-onlywrite":
+ $defperms = "x";
+ break;
+ }
+
if(!$inputcheck) {
gwvpmini_SendMessage("error", "$inputcheckerror");
header("Location: $BASE_URL/repos");
@@ -185,8 +292,9 @@ 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_SendMessage("info", "Repo ".$_REQUEST["reponame"]." has been created");
+ if(gwvpmini_createGitRepo($_REQUEST["reponame"], $_SESSION["id"], $_REQUEST["repodesc"], $defperms, $clonefrom, $fromremote)) {
+ gwvpmini_SendMessage("info", "Repo ".$_REQUEST["reponame"]." has been created");
+ }
header("Location: $BASE_URL/repos");
}
} else {
@@ -211,7 +319,7 @@ function gwvpmini_RemoveRepo($rid)
$rname = $repdet["name"];
- error_log("FROM PANTS:".print_r($repdet,true)." ----------- ".print_r($rname, true));
+ // error_log("FROM PANTS:".print_r($repdet,true)." ----------- ".print_r($rname, true));
if($repdet != false && $rname != "") {
if(file_exists("$repo_base/$rname.git")) {
@@ -225,7 +333,7 @@ function gwvpmini_RemoveRepo($rid)
function gwvpmini_RecursiveDelete($fpath)
{
- error_log("RECURSEDETELE: ".$fpath);
+ // error_log("RECURSEDETELE: ".$fpath);
if(is_file($fpath)){
return @unlink($fpath);
}
@@ -237,5 +345,58 @@ function gwvpmini_RecursiveDelete($fpath)
return @rmdir($fpath);
}
}
+
+function gwvpmini_CompressCommitId($cid)
+{
+ $compressedcid = substr($cid, 0, 5)."...".substr($cid, strlen($cid)-5, strlen($cid));
+
+ return $compressedcid;
+}
+
+function gwvpmini_GetCommitDetail($repo, $commitid)
+{
+ global $cmd_line_tool,$git_cli_cmd,$php_cli_cmd;
+
+ $repo_base = gwvpmini_getConfigVal("repodir");
+
+ $cmd = "$git_cli_cmd --git-dir=$repo_base/$repo.git log $commitid -1 --format='%an'";
+ exec($cmd, $commitername, $returnvar);
+
+ $cmd = "$git_cli_cmd --git-dir=$repo_base/$repo.git log $commitid -1 --format='%ae'";
+ exec($cmd, $commiteremail, $returnvar);
+
+ $cmd = "$git_cli_cmd --git-dir=$repo_base/$repo.git log $commitid -1 --format='%ct'";
+ exec($cmd, $commitertime, $returnvar);
+
+ $cmd = "$git_cli_cmd --git-dir=$repo_base/$repo.git log $commitid -1 --format='%s'";
+ exec($cmd, $commiterlog, $returnvar);
+
+ $cmd = "$git_cli_cmd --git-dir=$repo_base/$repo.git log $commitid -1 --format='%b'";
+ exec($cmd, $commiterbody, $returnvar);
+}
+
+function gwvpmini_GetCommitList($repo, $branch, $num=20)
+{
+ global $git_cli_cmd,$git_cli_cmd,$php_cli_cmd;
+
+ $repo_base = gwvpmini_getConfigVal("repodir");
+
+ $cmd = "$git_cli_cmd --git-dir=$repo_base/$repo.git log $commitid -1 --format='%an'";
+ exec($cmd, $commitername, $returnvar);
+
+}
+
+function gwvpmini_GetRefList($repo)
+{
+ global $cmd_line_tool,$git_cli_cmd,$php_cli_cmd;
+
+ $repo_base = gwvpmini_getConfigVal("repodir");
+
+ $cmd = "$git_cli_cmd --git-dir=$repo_base/$repo.git for-each-ref $commitid --format='%(objecttype):%(objectname):%(refname)'";
+ error_log("command was $cmd");
+ exec($cmd, $reflist, $returnvar);
+
+ return $reflist;
+}
?>
\ No newline at end of file
|