3 $WEB_ROOT_FS = realpath(dirname(__FILE__));
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
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;
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");
17 echo "ARGS: ".print_r($argv,true);
18 echo "CWD: ".getcwd()."\n";
20 if(isset($argv["3"])) {
23 gwvpcmdtool_UpdateHook();
26 gwvpcmdtool_PreReceive();
28 case "backgroundclone":
29 gwvpcmdtool_BackGroundClone();
34 } else gwvpcmdtool_Usage();
41 remote: [0] => /nfs/export/src/local/eclipse-workspace/gwvp-mini/bin/gwvpminicmdtool.php
44 remote: [3] => pre-receive
45 remote: [4] => fc781c4ef5bfeae8ec01bb527db1b6ce6f65d03c
46 remote: [5] => 7d45d43f04276fc9addb77ba8bf753329eab018d
47 remote: [6] => refs/heads/master
51 remote: [0] => /nfs/export/src/local/eclipse-workspace/gwvp-mini/bin/gwvpminicmdtool.php
54 remote: [3] => pre-receive
55 remote: [4] => /nfs/export/src/local/eclipse-workspace/gwvp-mini/bin/gwvpminicmdtool.php
59 remote: [8] => refs/heads/master
60 remote: [9] => fc781c4ef5bfeae8ec01bb527db1b6ce6f65d03c
61 remote: [10] => 7d45d43f04276fc9addb77ba8bf753329eab018d
66 function gwvpcmdtool_Usage()
70 echo "Usage: ".$argv[0]." this tool should not be called directly by user\n";
74 function gwvpcmdtool_BackGroundClone()
76 // here we parse arguments and have stuff with things and its 6am why am i doing this right now?
79 // update will log things like branch and tag creations
80 function gwvpcmdtool_UpdateHook()
83 //echo "got ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";
84 if(preg_match("/^000000+$/", $argv[5])) {
85 // createion of tag or branch
86 $vals = explode("/", $argv[4]);
87 $type = "unknowncreate";
88 if($vals[1] == "heads") $type = "branchcreate";
89 if($vals[1] == "tags") $type = "tagcreate";
91 //gwvpmini_AddRefActivityForRepo();
92 gwvpmini_AddRefActivityForRepo($argv[1], $argv[2], $vals[2], $type);
93 echo "REFSUP: ".$vals[2].", $type\n";
\r
96 //gwvpmini_AddActivityLog($type, $userid, $repoid, $commitid, $commitlog)
97 //gwvpmini_AddRefActivityForRepo($reponame, $byusername, $branchname, $acttype="branch")
100 // pre-receive logs all commit info
101 function gwvpcmdtool_PreReceive()
105 //echo "got from prereceive ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";
\r
110 $regspl = explode("/", $ref);
111 $branch = $regspl[2];
113 $fp = popen("git rev-list --reverse ".$argv[5]." --not --all ", "r");
114 if($fp) while(!feof($fp)) {
115 $line = trim(fgets($fp));
117 $cdd[$lns] = gwvpcmdtool_getCommitIdDetails($line);
118 echo "FORCID $line we get \n".print_r($cdd[$lns], true);
119 gwvpmini_AddCommitActivityForRepo($argv[1], $argv[2], $line, $cdd[$lns]["log"], $branch);
125 //echo "Called git rev-list --reverse ".$argv[5]." --not --all\n\n";
126 //gwvpmini_AddCommitActivityForRepo($reponame, $byusername, $commitid, $desc)
129 function gwvpcmdtool_getCommitIdDetails($commitid)
131 $rs = popen("git log --pretty=format:\"%at%n%ce%n%an%n%s\" $commitid -1 2> /dev/null", "r");
134 $ret["date"] = trim(fgets($rs));
\r
135 $ret["email"] = trim(fgets($rs));
\r
136 $ret["fullname"] = trim(fgets($rs));
138 while(!feof($rs)) {
\r
139 $ret["log"] .= fread($rs, 8192);
\r