1b532650b9c2ae4f0697389712e51aec96ec704f
[gwvp-mini.git] / bin / gwvpminicmdtool.php
1 <?php
2
3 $WEB_ROOT_FS = realpath(dirname(__FILE__));
4 $BASE_URL = "/";\r
5
6 global $WEB_ROOT_FS, $BASE_URL, $IS_WEB_REQUEST, $data_directory, $db_type, $db_name, $db_username, $db_password, $IS_WEB_REQUEST, $cmd_line_tool;
7 $IS_WEB_REQUEST = false;\r
8
9 if(file_exists("$WEB_ROOT_FS/../www/config.php")) require_once("$WEB_ROOT_FS/../www/config.php");
10 else if(file_exists("/etc/gwvpmini/config.php")) require_once("/etc/gwvpmini/config.php");
11 else $noconfig = true;
12
13 if(file_exists("$WEB_ROOT_FS/../gwvpmini/gwvpmini.php")) require_once("$WEB_ROOT_FS/../gwvpmini/gwvpmini.php");
14 else if(file_exists("/usr/share/gwvpmini/lib/gwvpmini/gwvpmini.php")) require_once("/usr/share/gwvpmini/lib/gwvpmini/gwvpmini.php");
15
16 if(isset($argv["1"])) {
17         switch($argv["1"]) {
18                 case "update":
19                         gwvpcmdtool_UpdateHook();
20                         break;
21                 case "pre-receive":
22                         gwvpcmdtool_PreReceive();
23                         break;
24                 default:
25                         gwvpcmdtool_Usage();
26         }
27 } else gwvpcmdtool_Usage();
28 return;
29
30
31
32 function gwvpcmdtool_Usage()
33 {
34         global $argv;
35         
36         echo "Usage: ".$argv[0]."\n";
37         echo "\tupdatehook <user> <ref> <firstupdate> <lastupdate>\n";
38 }
39
40
41 // update will log things like branch and tag creations
42 function gwvpcmdtool_UpdateHook()
43 {
44         global $argv;
45         //echo "got ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";
46         if(preg_match("/^000000+$/", $argv[3])) {
47                 // createion of tag or branch
48                 $vals = explode("/", $argv[2]);
49                 $type = "unknowncreate";
50                 if($vals == "heads") $type = "branchcreate";
51                 if($vals == "tags") $type = "tagcreate";
52                 gwvpmini_AddActivityLog("$type", "1", "1", $argv[4], "somelogs");
53         }
54         //gwvpmini_AddActivityLog($type, $userid, $repoid, $commitid, $commitlog)
55 }
56
57 // pre-receive logs all commit info
58 function gwvpcmdtool_PreReceive()
59 {
60         global $argv;
61
62         //echo "got from prereceive ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";\r
63         
64         //passthru("git rev-list --reverse ".$argv[3]." --not --all ");
65 }
66 ?>