Github ã®ã³ãããã«Hookãã¦Tracã®ãã±ãããã¯ãã¼ãºããã
æè¿Githubããããã使ãå§ããsotarokã§ãã
æ®æ®µã¯ãSubversionã使ã£ã¦ããããnequalã®éçºã主ã«Subversionã使ã£ã¦ãã¦ãBTSã¨ãããTODO管çã¨ãããã«Tracã使ã£ã¦ããã§ãTracã®ä¾¿å©ãªã¨ããã¯Subversionã¨é£æºãã¦ããããããã³ããããã°ã«ãfixed #123ãã¨ãæ¸ãã°ãã±ããã®#123ãã¯ãã¼ãºãã¦ããããããã¨ãããªãã ãã©ãGithubã«ã½ã¼ã¹ã移è¡ãã¦ç¸å¤ããããã±ãã管çãTracã«ä»»ãã¦ããã¨ãã®Hookã使ããªãã¦ä¸ä¾¿ã
ãããªããã§Githubã®ã³ãããï¼pushï¼ã«Hookãã¦Tracã®ãã±ããæ´æ°ã§ããããã«ããã
GithubPluginãã¤ã³ã¹ãã¼ã«
ã³ã¬ã
gitãããã£ã¦ãã¦setup.pyã
% git clone git://github.com/davglass/github-trac.git % cd github-trac
simplejsonãå ¥ã£ã¦ãªãå ´åã¯ãeasy_installã§å ¥ãã¦ãããå ¥ã£ã¦ããªããããªããã©ã
% easy_install simplejson % sudo python setup.py install
trac.ini ããã
[components] github.* = enabled [github] apitoken = tekitounamojiretsu
apitoken ã®ã¨ãã¯é©å½ãªæååå ¥ããã
ã§ãApacheåèµ·åãªã©ãããã¨ï¼mod_pythonã§åããã¦ãå ´åï¼ã管çã³ã³ã½ã¼ã«ã®ãã©ã°ã¤ã³ã£ã¦ã¨ãã«ã
ãªæãã®è¡¨ç¤ºãã
Service Hooks ã« URLãè¨å®
ããã¯Githubå´ã®è¨å®ããªãã¸ããªã®ãAdmin->Service Hooksã«è²ã
ããã
ã§ãæåã¯Tracã®ã»ãã«å
¥ããã®ãã¨ããã£ã¦è©¦ãã¦ããã©ãã¾ããããªãããï¼å¾è¿°ï¼ãdavglass/github-trac · GitHub ã®èª¬æã«æ¸ãã¦ããéããä¸çªä¸ã® Post-Receive URLs ã«ã
http://trac.nequal.jp/github/tekitounamojiretsu
ã¿ãããªã«ã³ã¸ã§ãtracã®URLï¼ /github/ + apitokenã«è¨å®ããæååããå
¥åã
å®éã«ã³ããããã
git commit -a -m "fixed #123" ã¨ããã¦ã git push origin master ãªã©ãã¦githubã«pushããã¿ã¤ãã³ã°ã§ãHookãåãã¾ããã§ãããã§ããã
pullã¨ãã¯è©¦ãã¦ãªããªãããã£ã¨ãªãããããªãããªï¼ã¦ãã¨
Service Hooksã®Tracãã¨ãã«å ¥åããã¨ãã¯ãã¼ã¿ãæ¥ã¦ãªãã½ã
ä¸å¿èª¿ã¹ã¦ã¿ããã§ãããGithubPlugin-0.4-py2.4.egg ã® github/github.py ã«
def processCommitHook(self, req): self.env.log.debug("processCommitHook") status = self.closestatus if not status: status = 'closed' data = req.args.get('payload') self.env.log.debug("data: %s" % data) # ãã足ãã if data: jsondata = simplejson.loads(data) for i in jsondata['commits']: self.env.log.debug("status: %s" % status) self.hook.process(i, status) if self.autofetch: repo = Git(self.repo) try: repo.execute(['git', 'fetch']) except: self.env.log.debug("git fetch failed!")
ã§ãTracã®ãã°ãdebugã«è¨å®ãã¦åããã¦ã¿ã¦ãããPost-Receive URLsã«å
¥ããã»ãã§Hookãåããã¨ãã¯ãJSONã§è²ã
æ
å ±ã渡ããã¦ããã©ãTracã®ã»ãã«URLã¨Tokenãå
¥åãã¦ããããã¯ã©ããããã¦ãªãã£ããã ããå½ç¶Hookã¯åããªããã ãã©ãã§ãã¡ãã㨠tracurl/github/tokenæåå ã£ã¦URLã«ã¢ã¯ã»ã¹ã¯ãã¦ããã ãã©ãã
ãªãã§ã ãï¼ãã®Tracã£ã¦ä½ã«ä½¿ããã ããï¼ github å´ã®å¯¾å¿ãã¹ã¨ãï¼ã©ãªããç¥ã£ã¦ããæãã¦ãã ããã
ã¾ããããã¨ããããPost-Receive URLsã§éç¨ãã¡ããã
ã¨ãããããã§ããã