#!/bin/env python import datetime """ If you are using github.com frank works pretty much with github's own hooks, which will submit a JSON to your listening server. If you don't feel like working with github you can host your repository at the same place where you host frank, and then you can simply run this script directly after your push. If this not the case you will need to invoke the script with the correct parameters. See below. """ # List changed in the last commit # git diff-tree --no-commit-id --name-only -r $(git rev-list HEAD^..HEAD) # Python version # [patch.new_file_path for patch in repo.diff('HEAD', 'HEAD~1'))] """ This scripts submit a very simplified json record witht the following information:: { 'repository': full_path_on_file_system 'commit': 1481a2de7b2a7d02428ad93446ab166be7793fbb 'branch': branch_name "committer":{ "email":"lolwut@noway.biz", "name":"Garen Torikian", }, "author": { "email":"lolwut@noway.biz", "name":"Garen Torikian", }, "url": "host.domain.full_path" } """ SUBMIT_HOST = '192.168.1.100' SUBMIT_PORT = 5000 GITURL = "git@yourhost.domain:oz123/frank.git" from pygit2 import Repository repo = Repository('..') head = repo.head commit = head.get_object() json_to_submit = {} json_to_submit['commit'] = commit.id json_to_submit['branch'] = repo.head.shorthand json_to_submit['committer'] = {'email': commit.committer.email, 'name': commit.committer.name} json_to_submit['author'] = {'email': commit.author.email, 'name': commit.author.name} json_to_submit['url'] = GITURL json_to_submit['time'] = datetime.datetime.now() print json_to_submit