Permalink
Browse files

Simple hack that adds a hook to Post-receive that resyncs git reposit…

…ories with the github ones to avoid having to cron a git fetch.

As talked here: http://davglass.lighthouseapp.com/projects/21212/tickets/2-processcommithook-failing-because-payload-is-missing#ticket-2-12
  • Loading branch information...
1 parent 395026c commit b4376253c51ba54a3630e72ef93f1a4d36863bac @mpeterson mpeterson committed Feb 1, 2009
Showing with 11 additions and 0 deletions.
  1. +10 −0 github/github.py
  2. +1 −0 setup.py
View
10 github/github.py
@@ -6,13 +6,16 @@
import simplejson
+from git import Git
+
class GithubPlugin(Component):
implements(IRequestHandler, IRequestFilter)
key = Option('github', 'apitoken', '', doc="""Your GitHub API Token found here: https://github.com/account, """)
closestatus = Option('github', 'closestatus', '', doc="""This is the status used to close a ticket. It defaults to closed.""")
browser = Option('github', 'browser', '', doc="""Place your GitHub Source Browser URL here to have the /browser entry point redirect to GitHub.""")
+ repo = Option('trac', 'repository_dir' '', doc="""This is your repository dir""")
def __init__(self):
self.hook = CommitHook(self.env)
@@ -106,4 +109,11 @@ def processCommitHook(self, req):
for i in jsondata['commits']:
self.hook.process(i, status)
+ repo = Git(self.repo)
+
+ try:
+ repo.execute(['git', 'fetch'])
+ except:
+ self.env.log.debug("git fetch failed!")
+
View
1 setup.py
@@ -17,6 +17,7 @@
install_requires = [
'simplejson>=2.0.5',
+ 'GitPython>=0.1.6',
],
entry_points = {
'trac.plugins': [

0 comments on commit b437625

Please sign in to comment.