You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2012/10/29 21:10:46 UTC

[4/25] git commit: [#5076] Added conversions for canned SVN hooks

[#5076] Added conversions for canned SVN hooks

Signed-off-by: Cory Johns <jo...@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/db4407ba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/db4407ba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/db4407ba

Branch: refs/heads/cj/5076
Commit: db4407ba7a359390e2ec88ffa168aa9a66cc4c78
Parents: 2350045
Author: Cory Johns <jo...@geek.net>
Authored: Wed Oct 17 20:26:49 2012 +0000
Committer: Cory Johns <jo...@geek.net>
Committed: Mon Oct 29 20:08:19 2012 +0000

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


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/db4407ba/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index c5f5d55..175b420 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -434,6 +434,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://'):
@@ -444,9 +463,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/db4407ba/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/db4407ba/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 ac589e3..6a14843 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -170,7 +170,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()