allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject git commit: [#5076] Added conversions for canned SVN hooks
Date Wed, 17 Oct 2012 20:27:19 GMT
Updated Branches:
  refs/heads/cj/5076 [created] 57e7f73e0


[#5076] Added conversions for canned SVN hooks

Signed-off-by: Cory Johns <johnsca@geek.net>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/57e7f73e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/57e7f73e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/57e7f73e

Branch: refs/heads/cj/5076
Commit: 57e7f73e0320926229ee3115cb88252f33197634
Parents: 71eaa53
Author: Cory Johns <johnsca@geek.net>
Authored: Wed Oct 17 20:26:49 2012 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Wed Oct 17 20:26:49 2012 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/model/svn.py                     |   26 +++++++++++++--
 .../forgesvn/tests/data/testsvn/hooks/post-commit  |   10 +++++-
 ForgeSVN/forgesvn/tests/model/test_repository.py   |   19 ++++++++++-
 3 files changed, 50 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/57e7f73e/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 23d80eb..96bbc9b 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -433,6 +433,25 @@ class SVNImplementation(M.RepositoryImplementation):
 
         return size
 
+    def _process_classic_user_hooks(self, file_name):
+        target_file = os.path.join(self._repo.full_fs_path, 'hooks/post-commit-user')
+        with open(file_name) as classic:
+            with open(target_file, 'w') as allura:
+                allura.write('#!/bin/bash\n')
+                for line in classic:
+                    if not line.startswith('/var/local'):
+                        continue
+                    if re.search(r'sf-svn-stats-hook.py|keepsake', line):
+                        continue
+                    line = re.sub(r'/sfp-svn/', '/sfu-scm/', line)
+                    line = re.sub(r'--viewcvs-url "[^"]*"', '--viewcvs-url "%s%s%%s"' % (
+                        tg.config.get('base_url', ''), self._repo.url()), line)
+                    line = re.sub(r'--revisionURI="[^"]*"', '--revisionURI="%s%s%%(revision)s"'
% (
+                        tg.config.get('base_url', ''), self._repo.url()), line)
+                    line = re.sub(r'--repositoryURI=\S*', '--repositoryURI=%s' % self._repo.clone_url('https_anon'),
line)
+                    allura.write(line)
+        shutil.copymode(file_name, target_file)
+
     def _copy_hooks(self, source_path):
         '''Copy existing hooks if source path is given and exists.'''
         if source_path is not None and source_path.startswith('file://'):
@@ -443,9 +462,10 @@ class SVNImplementation(M.RepositoryImplementation):
             filename = os.path.basename(hook)
             target_filename = filename
             if filename == 'post-commit':
-                target_filename = 'post-commit-user'
-            target = os.path.join(self._repo.full_fs_path, 'hooks', target_filename)
-            shutil.copy2(hook, target)
+                self._process_classic_user_hooks(hook)
+            else:
+                target = os.path.join(self._repo.full_fs_path, 'hooks', target_filename)
+                shutil.copy2(hook, target)
 
     def _setup_hooks(self, source_path=None, copy_hooks=False):
         'Set up the post-commit and pre-revprop-change hooks'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/57e7f73e/ForgeSVN/forgesvn/tests/data/testsvn/hooks/post-commit
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/data/testsvn/hooks/post-commit b/ForgeSVN/forgesvn/tests/data/testsvn/hooks/post-commit
index 67000e9..d6f67b5 100755
--- a/ForgeSVN/forgesvn/tests/data/testsvn/hooks/post-commit
+++ b/ForgeSVN/forgesvn/tests/data/testsvn/hooks/post-commit
@@ -1 +1,9 @@
-post-commit
+#!/bin/sh
+# THIS FILE IS AUTOGENERATED - DO NOT EDIT
+/var/local/mastertree/host/sfp-svn/hook-scripts/sf-svn-stats-hook.py $*
+/var/local/mastertree/host/sfp-svn/hook-scripts/keepsake -p "$1"
+/var/local/mastertree/host/sfp-svn/hook-scripts/ciabot_svn.py --revisionURI="http://t2809.svn.sourceforge.net/%(project)s/?view=rev&rev=%(revision)s"
--repositoryURI=https://t2809.svn.sourceforge.net/svnroot/t2809 "$1" "$2" t2809
+/var/local/mastertree/host/sfp-svn/hook-scripts/ciabot_svn.py --revisionURI="http://t2809.svn.sourceforge.net/t2809/?view=rev&rev=%(revision)s"
--repositoryURI=https://t2809.svn.sourceforge.net/svnroot/t2809 "$1" "$2" "foo"
+/var/local/mastertree/host/sfp-svn/hook-scripts/svnnotify --repos-path "$1" --revision "$2"
--to "test@example.com" --subject-prefix "SF.net SVN: t2809:" --subject-cx --no-first-line
--with-diff --viewcvs-url "http://t2809.svn.sourceforge.net/t2809/?rev=%s&view=rev" --user-domain
"users.sourceforge.net" --footer "This was sent by the SourceForge.net collaborative development
platform, the world's largest Open Source development site." -l /usr/bin/svnlook --max-diff-length
100000
+/var/local/mastertree/host/sfp-svn/hook-scripts/svnnotify --repos-path "$1" --revision "$2"
--to "test@example.com" --subject-prefix "SF.net SVN: t2809:" --subject-cx --no-first-line
--viewcvs-url "http://t2809.svn.sourceforge.net/t2809/?rev=%s&view=rev" --user-domain
"users.sourceforge.net" --footer "This was sent by the SourceForge.net collaborative development
platform, the world's largest Open Source development site." -l /usr/bin/svnlook --max-diff-length
100000
+exit 0

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/57e7f73e/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 94912f9..1ea425f 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -5,6 +5,7 @@ import pkg_resources
 
 import mock
 from ming.orm import ThreadLocalORMSession
+import tg
 
 from alluratest.controller import setup_basic_test, setup_global_objects
 from allura.lib import helpers as h
@@ -161,7 +162,23 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         assert os.path.exists('/tmp/testsvn/hooks/post-commit-user')
         assert os.access('/tmp/testsvn/hooks/post-commit-user', os.X_OK)
         with open('/tmp/testsvn/hooks/post-commit-user') as f: c = f.read()
-        self.assertEqual(c, 'post-commit\n')
+        expected = (
+                    '#!/bin/bash\n'
+                    '/var/local/mastertree/host/sfu-scm/hook-scripts/ciabot_svn.py --revisionURI="http://localhost//p/test/src/%(revision)s"
--repositoryURI=https://localhost:8022/scm-repo/test/testsvn/ "$1" "$2" t2809\n'
+                    '/var/local/mastertree/host/sfu-scm/hook-scripts/ciabot_svn.py --revisionURI="http://localhost//p/test/src/%(revision)s"
--repositoryURI=https://localhost:8022/scm-repo/test/testsvn/ "$1" "$2" "foo"\n'
+                    '/var/local/mastertree/host/sfu-scm/hook-scripts/svnnotify --repos-path
"$1" --revision "$2" --to "test@example.com" --subject-prefix "SF.net SVN: t2809:" --subject-cx
--no-first-line --with-diff --viewcvs-url "http://localhost//p/test/src/%s" --user-domain
"users.sourceforge.net" --footer "This was sent by the SourceForge.net collaborative development
platform, the world\'s largest Open Source development site." -l /usr/bin/svnlook --max-diff-length
100000\n'
+                    '/var/local/mastertree/host/sfu-scm/hook-scripts/svnnotify --repos-path
"$1" --revision "$2" --to "test@example.com" --subject-prefix "SF.net SVN: t2809:" --subject-cx
--no-first-line --viewcvs-url "http://localhost//p/test/src/%s" --user-domain "users.sourceforge.net"
--footer "This was sent by the SourceForge.net collaborative development platform, the world\'s
largest Open Source development site." -l /usr/bin/svnlook --max-diff-length 100000\n'
+                )
+        self.assertEqual(c, expected, (
+                    'Incorrect post-commit-user; expected:\n'
+                    '-------------------------------------\n'
+                    '%s'
+                    '-------------------------------------\n'
+                    'Got:\n'
+                    '-------------------------------------\n'
+                    '%s'
+                    '-------------------------------------\n'
+                ) % (expected, c))
         assert os.path.exists('/tmp/testsvn/hooks/post-commit')
         assert os.access('/tmp/testsvn/hooks/post-commit', os.X_OK)
         with open('/tmp/testsvn/hooks/post-commit') as f: c = f.read()


Mime
View raw message