You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/02/22 00:03:06 UTC

[1/2] git commit: [#5459] Added hotcopy flag for git repos so hotcopy is not performed when unwanted (e.g., forks)

[#5459] Added hotcopy flag for git repos so hotcopy is not performed when unwanted (e.g., forks)

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/c3f622ef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c3f622ef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c3f622ef

Branch: refs/heads/master
Commit: c3f622ef33798b008a585affddf9d2cb04e61c32
Parents: 11e8813
Author: Cory Johns <jo...@geek.net>
Authored: Thu Feb 21 21:27:08 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Thu Feb 21 22:53:57 2013 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py              |    3 +-
 ForgeGit/forgegit/tests/model/test_repository.py |   44 ++++++++--------
 2 files changed, 24 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c3f622ef/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 4a0942e..a659ed5 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -97,7 +97,8 @@ class GitImplementation(M.RepositoryImplementation):
     def can_hotcopy(self, source_url):
         enabled = asbool(tg.config.get('scm.git.hotcopy', True))
         is_local = os.path.exists(source_url)
-        return enabled and is_local
+        requested = self._repo.app.config.options.get('hotcopy', False)
+        return enabled and is_local and requested
 
     def clone_from(self, source_url):
         '''Initialize a repo as a clone of another'''

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c3f622ef/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 8ed46dd..223c1af 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -148,29 +148,28 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
 
     @mock.patch('forgegit.model.git_repo.g.post_event')
     def test_clone(self, post_event):
-        with h.push_config(tg.config, **{'scm.git.hotcopy': 'False'}):
-            repo = GM.Repository(
-                name='testgit.git',
-                fs_path='/tmp/',
-                url_path = '/test/',
-                tool = 'git',
-                status = 'creating')
-            repo_path = pkg_resources.resource_filename(
-                'forgegit', 'tests/data/testgit.git')
-            dirname = os.path.join(repo.fs_path, repo.name)
-            if os.path.exists(dirname):
-                shutil.rmtree(dirname)
-            repo.init()
-            repo._impl.clone_from(repo_path)
-            assert len(repo.log())
-            assert not os.path.exists('/tmp/testgit.git/hooks/update')
-            assert not os.path.exists('/tmp/testgit.git/hooks/post-receive-user')
-            assert os.path.exists('/tmp/testgit.git/hooks/post-receive')
-            assert os.access('/tmp/testgit.git/hooks/post-receive', os.X_OK)
-            with open('/tmp/testgit.git/hooks/post-receive') as f: c = f.read()
-            self.assertIn('curl -s http://localhost//auth/refresh_repo/p/test/src-git/\n', c)
-            self.assertIn('exec $DIR/post-receive-user\n', c)
+        repo = GM.Repository(
+            name='testgit.git',
+            fs_path='/tmp/',
+            url_path = '/test/',
+            tool = 'git',
+            status = 'creating')
+        repo_path = pkg_resources.resource_filename(
+            'forgegit', 'tests/data/testgit.git')
+        dirname = os.path.join(repo.fs_path, repo.name)
+        if os.path.exists(dirname):
             shutil.rmtree(dirname)
+        repo.init()
+        repo._impl.clone_from(repo_path)
+        assert len(repo.log())
+        assert not os.path.exists('/tmp/testgit.git/hooks/update')
+        assert not os.path.exists('/tmp/testgit.git/hooks/post-receive-user')
+        assert os.path.exists('/tmp/testgit.git/hooks/post-receive')
+        assert os.access('/tmp/testgit.git/hooks/post-receive', os.X_OK)
+        with open('/tmp/testgit.git/hooks/post-receive') as f: c = f.read()
+        self.assertIn('curl -s http://localhost//auth/refresh_repo/p/test/src-git/\n', c)
+        self.assertIn('exec $DIR/post-receive-user\n', c)
+        shutil.rmtree(dirname)
 
     @mock.patch('forgegit.model.git_repo.git.Repo.clone_from')
     @mock.patch('forgegit.model.git_repo.g.post_event')
@@ -182,6 +181,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
                 url_path = '/test/',
                 tool = 'git',
                 status = 'creating')
+            repo.app.config.options['hotcopy'] = True
             repo_path = pkg_resources.resource_filename(
                 'forgegit', 'tests/data/testgit.git')
             dirname = os.path.join(repo.fs_path, repo.name)