Ticket #1310: trac-post-commit-hook.0.10-stable.2.diff
| File trac-post-commit-hook.0.10-stable.2.diff, 2.0 KB (added by markus, 2 years ago) |
|---|
-
trac-post-commit-hook
32 32 # 33 33 # REPOS="$1" 34 34 # REV="$2" 35 # LOG=`/usr/bin/svnlook log -r $REV $REPOS`36 # AUTHOR=`/usr/bin/svnlook author -r $REV $REPOS`37 35 # TRAC_ENV='/somewhere/trac/project/' 38 36 # TRAC_URL='http://trac.mysite.com/project/' 39 37 # 40 38 # /usr/bin/python /usr/local/src/trac/contrib/trac-post-commit-hook \ 41 39 # -p "$TRAC_ENV" \ 42 40 # -r "$REV" \ 43 # -u "$AUTHOR" \44 # -m "$LOG" \45 41 # -s "$TRAC_URL" 46 42 # 47 43 # It searches commit messages for text in the form of: … … 80 76 # TODO: move grouped_changelog_entries to model.py 81 77 from trac.util.text import to_unicode 82 78 from trac.web.href import Href 79 from trac.versioncontrol.svn_fs import SubversionRepository, SubversionChangeset 83 80 84 81 try: 85 82 from optparse import OptionParser … … 137 134 def __init__(self, project=options.project, author=options.user, 138 135 rev=options.rev, msg=options.msg, url=options.url, 139 136 encoding=options.encoding): 137 self.env = open_environment(project) 138 repos_dir = self.env.config.get('trac', 'repository_dir') 139 self.env.get_repository() # will do a `sync` if needed 140 repos = SubversionRepository(repos_dir, '', '') 141 change = repos.get_changeset(rev) 142 msg = change.message 140 143 msg = to_unicode(msg, encoding) 141 self.author = author144 self.author = change.author 142 145 self.rev = rev 143 146 self.msg = "(In [%s]) %s" % (rev, msg) 144 147 self.now = int(time.time()) 145 self.env = open_environment(project)146 self.env.get_repository() # will do a `sync` if needed147 148 if url is None: 148 149 url = self.env.config.get('project', 'url') 149 150 self.env.href = Href(url) … … 195 196 196 197 197 198 if __name__ == "__main__": 198 if len(sys.argv) < 5:199 if len(sys.argv) < 3: 199 200 print "For usage: %s --help" % (sys.argv[0]) 200 201 else: 201 202 CommitHook()
