From 295cafbd90e580794a7fa3eb85feea0c481a5275 Mon Sep 17 00:00:00 2001 From: Paul J R Date: Sun, 23 Sep 2012 07:12:19 +1000 Subject: [PATCH] add list of repos a user can commit to --- gwvpmini/gwvpmini_db.php | 14 +++++++++++--- gwvpmini/gwvpmini_gitbackend.php | 7 +++++-- gwvpmini/gwvpmini_gitrepo.php | 37 ++++++++++++++++++++++++++++++++++++- gwvpmini/gwvpmini_view.php | 1 + 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/gwvpmini/gwvpmini_db.php b/gwvpmini/gwvpmini_db.php index b94b4ca..97437b5 100644 --- a/gwvpmini/gwvpmini_db.php +++ b/gwvpmini/gwvpmini_db.php @@ -717,7 +717,7 @@ function gwvpmini_GetContributedRepos($username) $uid = gwvpmini_GetUserId($username); - $sql = "select repos_id,repos_description,repos_perms,repos_owernid,repos_status from repos"; + $sql = "select repos_id,repos_description,repos_perms,repos_owner,repos_status,repos_name from repos"; $res = $conn->query($sql); if($username == "") return false; @@ -726,16 +726,24 @@ function gwvpmini_GetContributedRepos($username) $i = 0; foreach($res as $row) { $perms = unserialize(base64_decode($row["repos_perms"])); + error_log("CONTRIB: $uid for ".$row["repos_id"]." - ".print_r($perms,true)); if(isset($perms["$uid"])) if($perms["$uid"] > 1) { $rids[$i]["id"] = $row["repos_id"]; $rids[$i]["desc"] = $row["repos_description"]; - $rids[$i]["ownerid"] = $row["repos_ownerid"]; + $rids[$i]["owner"] = $row["repos_owner"]; $rids[$i]["status"] = $row["repos_status"]; + $rids[$i]["name"] = $row["repos_name"]; $i++; } + } + $retval = $rids; + + if($i == 0) { + error_log("CONTRIBREPOS: no repos found?"); + return false; } - error_log(print_r($retval, true)); + error_log("CONTRIBREPOS: ".print_r($retval, true)); return $retval; } diff --git a/gwvpmini/gwvpmini_gitbackend.php b/gwvpmini/gwvpmini_gitbackend.php index bea736d..c3975e6 100644 --- a/gwvpmini/gwvpmini_gitbackend.php +++ b/gwvpmini/gwvpmini_gitbackend.php @@ -138,8 +138,11 @@ function gwvpmini_gitBackendInterface() // if its a write, we push for authentication //if($write) { - gwvpmini_callGitBackend($person, $repo); - return; + if(!$person) { + $person = "anonymous"; + } + gwvpmini_callGitBackend($person, $repo); + return; //} // if we made it this far, we a read and we have permissions to do so, just search the file from the repo diff --git a/gwvpmini/gwvpmini_gitrepo.php b/gwvpmini/gwvpmini_gitrepo.php index 3ea498c..d8e0d32 100644 --- a/gwvpmini/gwvpmini_gitrepo.php +++ b/gwvpmini/gwvpmini_gitrepo.php @@ -54,7 +54,6 @@ function gwvpmini_RepoMainPageBody() global $BASE_URL; if(gwvpmini_isLoggedIn()) { - gwvpmini_GitCreateRepoForm(); $repos = gwvpmini_GetOwnedRepos($_SESSION["username"]); if(!$repos) { echo "You currently own no repos
"; @@ -64,6 +63,8 @@ function gwvpmini_RepoMainPageBody() foreach($repos as $repo) { $name = $repo["name"]; $desc = $repo["desc"]; + $repo_base = gwvpmini_getConfigVal("repodir"); + $cmd = "git --git-dir=\"$repo_base/$name.git\" log -1 2> /dev/null"; echo "$name$desc"; echo ""; error_log("CMD: $cmd"); @@ -82,6 +83,40 @@ function gwvpmini_RepoMainPageBody() } echo ""; } + gwvpmini_GitCreateRepoForm(); + + + $contreps = gwvpmini_GetContributedRepos($_SESSION["username"]); + + if($contreps !== false) { + echo "

Repos you contribute to

"; + echo ""; + foreach($contreps as $repo) { + $name = $repo["name"]; + $desc = $repo["desc"]; + $repo_base = gwvpmini_getConfigVal("repodir"); + $cmd = "git --git-dir=\"$repo_base/$name.git\" log -1 2> /dev/null"; + error_log("CMD: $cmd"); + //system("$cmd"); + $fls = popen($cmd, "r"); + $tks = ""; + if($fls !== false) while(!feof($fls)) { + $tks .= fread($fls,1024); + } + + if($tks == "") { + $lastlog = "No Log Info Yet"; + } else $lastlog = $tks; + + $owner = gwvpmini_getUser(null, null, $repo["owner"]); + $repname = "$name"; + $repown = get_gravatar($owner["email"], 30, 'mm', 'g', true)."
".$owner["username"].""; + + + echo ""; + } + echo "
Repo NameOwnerRepo DescriptionLast Log
$repname$repown$desc$lastlog
"; + } } return true; } diff --git a/gwvpmini/gwvpmini_view.php b/gwvpmini/gwvpmini_view.php index 942ce73..126f5e4 100644 --- a/gwvpmini/gwvpmini_view.php +++ b/gwvpmini/gwvpmini_view.php @@ -78,6 +78,7 @@ function gwvpmini_RepoViewPageBody() $desc = gwvpmini_GetRepoDescFromName($repo_view_call); $editdesc = preg_replace("/\/", "\n", $desc); + $rid = gwvpmini_GetRepoId($repo_view_call); $owner_name = $owner["username"]; -- 1.7.0.4