From e5447b1fce8c6afe107c6cecbacb8ee34f46a74d Mon Sep 17 00:00:00 2001 From: Paul J R Date: Mon, 24 Sep 2012 07:13:12 +1000 Subject: [PATCH] cmdline tool for hooking into update githook --- bin/gwvpminicmdtool.php | 19 +++++++++++++++++++ gwvpmini/gwvpmini_gitbackend.php | 23 +++++++++++++++++++++-- gwvpmini/gwvpmini_view.php | 2 +- www/index.php | 5 +++-- 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 bin/gwvpminicmdtool.php diff --git a/bin/gwvpminicmdtool.php b/bin/gwvpminicmdtool.php new file mode 100644 index 0000000..7fb27d4 --- /dev/null +++ b/bin/gwvpminicmdtool.php @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/gwvpmini/gwvpmini_gitbackend.php b/gwvpmini/gwvpmini_gitbackend.php index 23b198b..6c8b8b5 100644 --- a/gwvpmini/gwvpmini_gitbackend.php +++ b/gwvpmini/gwvpmini_gitbackend.php @@ -26,6 +26,16 @@ function gwvpmini_gitControlCallMe() } +function gwvpmini_CreateUpdateHookInRepo($repopath) +{ + $fp = fopen("$repopath/hooks/$repopath", "w"); + + if(!$fp) error_log("could not create update hook"); + + // TODO: think about this one + +} + function gwvpmini_gitBackendInterface() { // and this is where i re-code the git backend interface from scratch @@ -82,6 +92,8 @@ function gwvpmini_gitBackendInterface() // so now we have the repo // next we determine if this is a read or a write + + // TODO: WE NEED TO FIX THIS, IT DOESNT ALWAYS DETECT a "WRITE" $write = false; if(isset($_REQUEST["service"])) { if($_REQUEST["service"] == "git-receive-pack") { @@ -141,7 +153,15 @@ function gwvpmini_gitBackendInterface() if(!$person) { $person = "anonymous"; } + + // if its a write, we check (before and after) the branch/tag info to see if they were updated + //if($write) { + //} + gwvpmini_callGitBackend($person, $repo); + + //if($write) { + //} return; //} @@ -199,8 +219,7 @@ function gwvpmini_callGitBackend($username, $repo) } //sleep(2); - - + // this is where the fun, it ends. $myoutput = ""; diff --git a/gwvpmini/gwvpmini_view.php b/gwvpmini/gwvpmini_view.php index d9721a7..165a3c1 100644 --- a/gwvpmini/gwvpmini_view.php +++ b/gwvpmini/gwvpmini_view.php @@ -112,7 +112,7 @@ function gwvpmini_RepoViewPageBody() else $owner_extra = ""; echo "

".gwvpmini_HtmlGravatar($owner["email"], 30)."$repo_view_call - $owner_name$owner_extra

"; - if(!$owner_view) echo "$desc
"; + if(!$owner_view) echo "$desc
"; if($owner_view) { echo "
"; diff --git a/www/index.php b/www/index.php index 3765aca..1482ceb 100644 --- a/www/index.php +++ b/www/index.php @@ -3,7 +3,9 @@ error_log("INCALLSTART ".print_r($_COOKIE, true)." -------------------- ".print_ $WEB_ROOT_FS = realpath(dirname(__FILE__)); $BASE_URL = dirname($_SERVER["PHP_SELF"]); -global $WEB_ROOT_FS, $BASE_URL, $data_directory, $db_type, $db_name, $db_username, $db_password; +global $WEB_ROOT_FS, $BASE_URL, $data_directory, $db_type, $db_name, $db_username, $db_password, $IS_WEB_REQUEST; + +$IS_WEB_REQUEST = false; if(file_exists("./config.php")) require_once("./config.php"); else if(file_exists("/etc/gwvpmini/config.php")) require_once("/etc/gwvpmini/config.php"); @@ -13,7 +15,6 @@ if(file_exists("../gwvpmini/gwvpmini.php")) require_once("../gwvpmini/gwvpmini.p else if(file_exists("/usr/share/gwvpmini/lib/gwvpmini/gwvpmini.php")) require_once("/usr/share/gwvpmini/lib/gwvpmini/gwvpmini.php"); - if(isset($noconfig)) { gwvpmini_goSetup(); return; -- 1.7.0.4