Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for pinging an URL after sending commit messages

  • Loading branch information...
commit 04e3910f7157f32872554fb4d82fc7fae95c428d 1 parent c44fb21
@mhagander authored
Showing with 18 additions and 0 deletions.
  1. +5 −0 README.rst
  2. +13 −0 commitmsg.py
View
5 README.rst
@@ -42,6 +42,7 @@ configuration for the script. It should contain something like: ::
commitmsg = 1
tagmsg = 1
branchmsg = 1
+ pingurl = 1
Expansion variables are available for the following fields:
@@ -66,6 +67,10 @@ debug
commitmsg, tagmsg, branchmsg
set to 0 to disable generating this type of message. If unspecified or
set to anything other than 0, the mail will be sent.
+pingurl
+ set to an URL to make the script send an empty HTTP post to this URL
+ whenever something is received. This is useful for example to trigger
+ a redmine installation to pull the repository.
git policy enforcement script
View
13 commitmsg.py
@@ -26,6 +26,7 @@
# commitmsg = 1
# tagmsg = 1
# branchmsg = 1
+# pingurl = http://somewhere.com/git_repo_updated
#
# Expansion variables are available for the following fields:
# subject - shortmsg
@@ -40,6 +41,10 @@
# commitmsg set to 0 to disable generation of commit mails
# tagmsg set to 0 to disable generation of tag creation mails
# branchmsg set to 0 to disable generation of branch creation mails
+# pingurl when set to something, a http POST will be made to the
+# specified URL whenever run. Note that unlike some more
+# advanced git hooks, we just make an empty POST, we don't
+# (currently) include any information about what's in the pack.
#
@@ -48,6 +53,7 @@
from subprocess import Popen, PIPE
from email.mime.text import MIMEText
from ConfigParser import ConfigParser
+import urllib
cfgname = "%s/commitmsg.ini" % os.path.dirname(sys.argv[0])
if not os.path.isfile(cfgname):
@@ -333,3 +339,10 @@ def parse_annotated_tag(lines):
pass
flush_mail()
+
+ # Send of a http POST ping if there is something changed
+ if c.has_option('commitmsg', 'pingurl'):
+ pingurl = c.get('commitmsg', 'pingurl'))
+ # Make a http POST (the empty content makes it a POST)
+ ret = urllib.urlopen(pingurl, '').read()
+ # We ignore what the result is...

0 comments on commit 04e3910

Please sign in to comment.
Something went wrong with that request. Please try again.