]> git.droids-corp.org - git-central.git/commitdiff
Move to the server directory.
authorStephen Haberman <stephen@exigencecorp.com>
Sun, 22 Jun 2008 00:39:31 +0000 (19:39 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Sun, 22 Jun 2008 00:42:13 +0000 (19:42 -0500)
server/post-receive-trac
server/post-receive-trac.py [new file with mode: 0644]
server/pre-receive-trac.py [new file with mode: 0644]
trac-post-commit-hook.py [deleted file]
trac-pre-commit-hook.py [deleted file]

index ab9362c3e9d3f7b2dc78a391bc7200b93dc9215b..208cdb3b417486568f3772daf563c44b523497aa 100644 (file)
@@ -10,7 +10,7 @@ while read oldrev newrev refname ; do
        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
 
diff --git a/server/post-receive-trac.py b/server/post-receive-trac.py
new file mode 100644 (file)
index 0000000..074c4ba
--- /dev/null
@@ -0,0 +1,70 @@
+#!/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)
+
diff --git a/server/pre-receive-trac.py b/server/pre-receive-trac.py
new file mode 100644 (file)
index 0000000..3d5a79d
--- /dev/null
@@ -0,0 +1,63 @@
+#!/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()
+
+
+
diff --git a/trac-post-commit-hook.py b/trac-post-commit-hook.py
deleted file mode 100644 (file)
index 074c4ba..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/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)
-
diff --git a/trac-pre-commit-hook.py b/trac-pre-commit-hook.py
deleted file mode 100644 (file)
index 3d5a79d..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/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()
-
-
-