Giocando con SubversionPlaying with Subversion

On yesterday evening i played a little with Subversion, I was looking for a way to do a post in my blog after a commit.
I knew that there’s post-commit hooks, but only email-related. So i’ve taken my Python, and i wrote this script that connects to XML-RPC service built-in in WordPress (using xmlrpclib), and provide to create a new post that contains the commit’s message, and a list of affected files (by a call to svnlook).
The script is very easy and customizable, I hope it will be a launch for everyone.

Ah, i talked about it also in Google Project hosting user group, I hope that someone listen to me…

Here’s the code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 #!/usr/bin/python

import sys
import xmlrpclib
import os

xmlrpc_url = "http://localhost/wp/xmlrpc.php"
xmlrpc_username = "admin"
xmlrpc_password = "admin"
post_title = "Commit log"

repos = sys.argv[1]
rev = sys.argv[2]

log_message = os.popen('svnlook log ' + repos).read()
affected_files = os.popen('svnlook changed ' + repos).read()

server = xmlrpclib.Server(xmlrpc_url)
server.metaWeblog.newPost(1,xmlrpc_username,xmlrpc_password,{"title":post_title,                                      "description":"Message: " + log_message + "Affetcted files: \n" + affected_files},bool(1))

Stay tuned

Technorati Tags: , , , ,



Probabilmente correlato...

Tags: , ,

Leave a comment