| 1 | #!/usr/local/bin/perl |
| 2 | use URI::Escape; |
| 3 | use JSON; |
| 4 | |
| 5 | # Read in the POST data and URL-decode it. |
| 6 | $data=""; |
| 7 | while (<>) { |
| 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. |
| 14 | open (MYFILE, '>./postdata.txt'); |
| 15 | print MYFILE $data; |
| 16 | close (MYFILE); |
| 17 | |
| 18 | # Parse the JSON |
| 19 | $perl_scalar = decode_json $data; |
| 20 | $id=$perl_scalar->{'after'}; |
| 21 | die unless $id =~ /^[0-9][a-f]*$/; |
| 22 | print "Id: $id\n"; |
| 23 | |
| 24 | # Run the actual commit hook. |
| 25 | system("./commit.sh $id"); |