Skip to content

Commit

Permalink
Simple hack that adds a hook to Post-receive that resyncs git reposit…
Browse files Browse the repository at this point in the history
…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
mpeterson committed Feb 1, 2009
1 parent 395026c commit b437625
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions github/github.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@


import simplejson import simplejson


from git import Git

class GithubPlugin(Component): class GithubPlugin(Component):
implements(IRequestHandler, IRequestFilter) implements(IRequestHandler, IRequestFilter)




key = Option('github', 'apitoken', '', doc="""Your GitHub API Token found here: https://github.com/account, """) 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.""") 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.""") 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): def __init__(self):
self.hook = CommitHook(self.env) self.hook = CommitHook(self.env)
Expand Down Expand Up @@ -106,4 +109,11 @@ def processCommitHook(self, req):
for i in jsondata['commits']: for i in jsondata['commits']:
self.hook.process(i, status) self.hook.process(i, status)


repo = Git(self.repo)

try:
repo.execute(['git', 'fetch'])
except:
self.env.log.debug("git fetch failed!")



1 change: 1 addition & 0 deletions setup.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


install_requires = [ install_requires = [
'simplejson>=2.0.5', 'simplejson>=2.0.5',
'GitPython>=0.1.6',
], ],
entry_points = { entry_points = {
'trac.plugins': [ 'trac.plugins': [
Expand Down

0 comments on commit b437625

Please sign in to comment.