|
@@ -1,7 +1,68 @@
|
|
|
+#!/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)
|
|
|
+# 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'))]
|
|
|
+# [patch.new_file_path for patch in repo.diff('HEAD', 'HEAD~1'))]
|
|
|
+
|
|
|
+
|
|
|
+SUBMIT_HOST = '192.168.1.100'
|
|
|
+SUBMIT_PORT = 5000
|
|
|
+GIT_URL = "git@yourhost.domain:oz123/frank.git"
|
|
|
+
|
|
|
+"""
|
|
|
+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"
|
|
|
+ }
|
|
|
+
|
|
|
+"""
|
|
|
+
|
|
|
+from pygit2 import Repository
|
|
|
+
|
|
|
+repo = Repository('..')
|
|
|
+head = repo.head
|
|
|
+commit = head.get_object()
|
|
|
+
|
|
|
+json_to_submit = {}
|
|
|
+
|
|
|
+json_to_submit['commit'] = head.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_sumbit['url'] = GIT_URL
|
|
|
+json_to_submit['time'] = datetime.datetime.now()
|