else
git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --stdin $oldrev..$newrev
fi | while read commit ; do
- /home/BIPFS/shaberman/local/bin/python /srv/git/hooks/trac-post-commit-hook.py -p "$TRAC_ENV" -r "$commit"
+ /home/BIPFS/shaberman/local/bin/python /srv/git/hooks/server/post-receive-trac.py -p "$TRAC_ENV" -r "$commit"
done
done
--- /dev/null
+#!/usr/bin/env python
+
+# This should work:
+#
+# Changed blah and foo to do this or that. Re #10 and #12, and qa #12.
+#
+
+import re
+import sys
+from datetime import datetime
+
+from trac.env import open_environment
+from trac.ticket.notification import TicketNotifyEmail
+from trac.ticket import Ticket
+from trac.ticket.web_ui import TicketModule
+from trac.util.datefmt import utc
+from trac.versioncontrol.api import NoSuchChangeset
+
+project = sys.argv[1]
+rev = sys.argv[2]
+
+def refs(ticket):
+ pass
+
+def qa(ticket):
+ if ticket['phase'] == 'Final Fixing':
+ ticket['phase'] = 'Final QA'
+ else:
+ ticket['phase'] = 'Initial QA'
+ ticket['owner'] = ''
+ ticket['status'] = 'new'
+
+commands = { 're': refs, 'refs': refs, 'qa': qa }
+commandPattern = re.compile(r'(?P<action>[A-Za-z]*).?(?P<ticket>#[0-9]+(?:(?:[, &]*|[ ]?and[ ]?)#[0-9]+)*)')
+ticketPattern = re.compile(r'#([0-9]*)')
+tickets = {}
+
+env = open_environment(project)
+repos = env.get_repository()
+repos.sync()
+
+changeset = repos.get_changeset(rev)
+
+for command, tickets in commandPattern.findall(changeset.message):
+ if commands.has_key(command.lower()):
+ for ticketId in ticketPattern.findall(tickets):
+ tickets.setdefault(ticketId, []).append(commands[command.lower()])
+
+for ticketId, commands in tickets.iteritems():
+ db = env.get_db_cnx()
+
+ ticket = Ticket(env, int(ticketId), db)
+ for command in commands:
+ command(ticket)
+
+ # determine sequence number...
+ cnum = 0
+ tm = TicketModule(env)
+ for change in tm.grouped_changelog_entries(ticket, db):
+ if change['permanent']:
+ cnum += 1
+
+ now = datetime.now(utc)
+ message = "(In [%s]) %s" % (rev, changeset.message)
+ ticket.save_changes(changeset.author, message, now, db, cnum+1)
+ db.commit()
+
+ tn = TicketNotifyEmail(env)
+ tn.notify(ticket, newticket=0, modtime=now)
+
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: iso8859-1 -*-
+#
+# Author: Jonas Borgström <jonas@edgewall.com>
+#
+# This script will enforce the following policy:
+#
+# "A checkin must reference an open ticket."
+#
+# This script should be invoked from the subversion pre-commit hook like this:
+#
+# REPOS="$1"
+# TXN="$2"
+# TRAC_ENV="/somewhere/trac/project/"
+# LOG=`/usr/bin/svnlook log -t "$TXN" "$REPOS"`
+# /usr/bin/python /some/path/trac-pre-commit-hook "$TRAC_ENV" "$LOG" || exit 1
+#
+import os
+import re
+import sys
+
+from trac.env import open_environment
+
+def main():
+ if len(sys.argv) != 3:
+ print >> sys.stderr, 'Usage: %s <trac_project> <log_message>' % sys.argv[0]
+ sys.exit(1)
+
+ env_path = sys.argv[1]
+ log = sys.argv[2].lower()
+
+ # Stephen: exempt 'No ticket'
+ if re.search('no ticket', log) or re.search('initialized merge tracking', log):
+ sys.exit(0)
+
+ tickets = []
+ for tmp in re.findall('(?:refs|re|qa).?(#[0-9]+(?:(?:[, &]+| *and *)#[0-9]+)*)', log):
+ tickets += re.findall('#([0-9]+)', tmp)
+
+ # At least one ticket has to be mentioned in the log message
+ if tickets == []:
+ print >> sys.stderr, 'At least one open ticket must be mentioned in the log message.'
+ sys.exit(1)
+
+ env = open_environment(env_path)
+ db = env.get_db_cnx()
+
+ cursor = db.cursor()
+ # Stephen: let the tickets be closed for now
+ # cursor.execute("SELECT COUNT(id) FROM ticket WHERE status <> 'closed' AND id IN (%s)" % ','.join(tickets))
+ cursor.execute("SELECT COUNT(id) FROM ticket WHERE id IN (%s)" % ','.join(tickets))
+ row = cursor.fetchone()
+ if not row or row[0] < 1:
+ print >> sys.stderr, 'At least one open ticket must be mentioned in the log message.'
+ sys.exit(1)
+ else:
+ sys.exit(0)
+
+if __name__ == '__main__':
+ main()
+
+
+
+++ /dev/null
-#!/usr/bin/env python
-
-# This should work:
-#
-# Changed blah and foo to do this or that. Re #10 and #12, and qa #12.
-#
-
-import re
-import sys
-from datetime import datetime
-
-from trac.env import open_environment
-from trac.ticket.notification import TicketNotifyEmail
-from trac.ticket import Ticket
-from trac.ticket.web_ui import TicketModule
-from trac.util.datefmt import utc
-from trac.versioncontrol.api import NoSuchChangeset
-
-project = sys.argv[1]
-rev = sys.argv[2]
-
-def refs(ticket):
- pass
-
-def qa(ticket):
- if ticket['phase'] == 'Final Fixing':
- ticket['phase'] = 'Final QA'
- else:
- ticket['phase'] = 'Initial QA'
- ticket['owner'] = ''
- ticket['status'] = 'new'
-
-commands = { 're': refs, 'refs': refs, 'qa': qa }
-commandPattern = re.compile(r'(?P<action>[A-Za-z]*).?(?P<ticket>#[0-9]+(?:(?:[, &]*|[ ]?and[ ]?)#[0-9]+)*)')
-ticketPattern = re.compile(r'#([0-9]*)')
-tickets = {}
-
-env = open_environment(project)
-repos = env.get_repository()
-repos.sync()
-
-changeset = repos.get_changeset(rev)
-
-for command, tickets in commandPattern.findall(changeset.message):
- if commands.has_key(command.lower()):
- for ticketId in ticketPattern.findall(tickets):
- tickets.setdefault(ticketId, []).append(commands[command.lower()])
-
-for ticketId, commands in tickets.iteritems():
- db = env.get_db_cnx()
-
- ticket = Ticket(env, int(ticketId), db)
- for command in commands:
- command(ticket)
-
- # determine sequence number...
- cnum = 0
- tm = TicketModule(env)
- for change in tm.grouped_changelog_entries(ticket, db):
- if change['permanent']:
- cnum += 1
-
- now = datetime.now(utc)
- message = "(In [%s]) %s" % (rev, changeset.message)
- ticket.save_changes(changeset.author, message, now, db, cnum+1)
- db.commit()
-
- tn = TicketNotifyEmail(env)
- tn.notify(ticket, newticket=0, modtime=now)
-
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: iso8859-1 -*-
-#
-# Author: Jonas Borgström <jonas@edgewall.com>
-#
-# This script will enforce the following policy:
-#
-# "A checkin must reference an open ticket."
-#
-# This script should be invoked from the subversion pre-commit hook like this:
-#
-# REPOS="$1"
-# TXN="$2"
-# TRAC_ENV="/somewhere/trac/project/"
-# LOG=`/usr/bin/svnlook log -t "$TXN" "$REPOS"`
-# /usr/bin/python /some/path/trac-pre-commit-hook "$TRAC_ENV" "$LOG" || exit 1
-#
-import os
-import re
-import sys
-
-from trac.env import open_environment
-
-def main():
- if len(sys.argv) != 3:
- print >> sys.stderr, 'Usage: %s <trac_project> <log_message>' % sys.argv[0]
- sys.exit(1)
-
- env_path = sys.argv[1]
- log = sys.argv[2].lower()
-
- # Stephen: exempt 'No ticket'
- if re.search('no ticket', log) or re.search('initialized merge tracking', log):
- sys.exit(0)
-
- tickets = []
- for tmp in re.findall('(?:refs|re|qa).?(#[0-9]+(?:(?:[, &]+| *and *)#[0-9]+)*)', log):
- tickets += re.findall('#([0-9]+)', tmp)
-
- # At least one ticket has to be mentioned in the log message
- if tickets == []:
- print >> sys.stderr, 'At least one open ticket must be mentioned in the log message.'
- sys.exit(1)
-
- env = open_environment(env_path)
- db = env.get_db_cnx()
-
- cursor = db.cursor()
- # Stephen: let the tickets be closed for now
- # cursor.execute("SELECT COUNT(id) FROM ticket WHERE status <> 'closed' AND id IN (%s)" % ','.join(tickets))
- cursor.execute("SELECT COUNT(id) FROM ticket WHERE id IN (%s)" % ','.join(tickets))
- row = cursor.fetchone()
- if not row or row[0] < 1:
- print >> sys.stderr, 'At least one open ticket must be mentioned in the log message.'
- sys.exit(1)
- else:
- sys.exit(0)
-
-if __name__ == '__main__':
- main()
-
-
-