two different versions; tweak color logic
[dygraphs.git] / commit-hook / commit.cgi
CommitLineData
4e2670b0
DV
1#!/usr/local/bin/perl
2use URI::Escape;
3use JSON;
4
5# Read in the POST data and URL-decode it.
6$data="";
7while (<>) {
8 $data .= $_;
9}
10$data = uri_unescape($data);
11$data =~ s/.*?=//; # JSON::decode_json doesn't like the 'payload=' prefix.
12
13# Save for debugging.
14open (MYFILE, '>./postdata.txt');
15print MYFILE $data;
16close (MYFILE);
17
18# Parse the JSON
19$perl_scalar = decode_json $data;
20$id=$perl_scalar->{'after'};
21die unless $id =~ /^[0-9][a-f]*$/;
22print "Id: $id\n";
23
24# Run the actual commit hook.
25system("./commit.sh $id");