Hi
When I commit a file, I need google code to then send a copy to my
server, so the source and live version are identical. I've been
looking at Post Commit Web Hooks and I just dont get it. How do I
actually send a php file to my server once I have committed it? Or do
I have to manually commit a file, then go to filezilla and manually
upload it to my server?
I have seen scripts like the one below, but all they seem to so i
register on the server that there is a new revision...
<?php
include('joshlib/index.php');
$key = ''; //your secret key
$data = file_get_contents('php://input'); //raw POST data
$digest = hash_hmac('md5', $data, $key); //hash created with data +
key
$hook = @$_SERVER['HTTP_GOOGLE_CODE_PROJECT_HOSTING_HOOK_HMAC']; //
the special header google sends
if ($hook && ($hook == $digest)) { //valid request
//extract the JSON and store the variables in a relational db
$data = json_decode($data, true);
if (!$project_id = db_grab('SELECT id FROM svn_projects WHERE
name = "' . $data['project_name'] . '"')) {
$project_id = db_query('INSERT INTO svn_projects
( name ) VALUES ( "' . $data['project_name'] . '" )');
}
//read the dictionary on the postCommitWebHooks page to create
your db structure
foreach ($data['revisions'] as $d) {
db_query('INSERT INTO svn_revisions ( project_id,
revision, url, author, timestamp, message, path_count ) VALUES (
' . $project_id . ',
"' . $d['revision'] . '",
"' . $d['url'] . '",
"' . $d['author'] . '",
"' . format_date($d['timestamp'], '', 'sql') .
'",
"' . $d['message'] . '",
' . $d['path_count'] . '
)');
}
} else { //invalid request
echo 'skipping, no special google header, or it was invalid';
}
?>
--
You received this message because you are subscribed to the Google Groups
"Project Hosting on Google Code" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-code-hosting?hl=en.