From 90d73cd6ffa6e848da59cb2a35dec74e0fabd00a Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sat, 6 Nov 2010 10:05:55 +0100 Subject: Some cleanup of Daniels contribution. Now it appears to be ready for a merge --- lib/git/submodule.py | 13 ++++---- test/git/.directory | 3 -- test/git/test_submodule.py | 9 ------ test_submodule.py | 75 ---------------------------------------------- 4 files changed, 7 insertions(+), 93 deletions(-) delete mode 100644 test/git/.directory delete mode 100644 test_submodule.py diff --git a/lib/git/submodule.py b/lib/git/submodule.py index c878256d..ead56809 100755 --- a/lib/git/submodule.py +++ b/lib/git/submodule.py @@ -9,7 +9,8 @@ import re class Submodule(object): """ A Submodule is a named reference to a Commit on another Repo. - Every Submodule instance contains a name and local and remote paths. + Every Submodule instance contains a name, a path into the local repo, + and a URI pointing at the remote repository. Submodules are very close in behavior to HEAD pointer. It just sits on top of a structure, in this case, at the end of folders tree, and says @@ -37,16 +38,16 @@ class Submodule(object): Pointer to Repo object instance. 'id' Is the Sha of the commit on a remote server. This object does NOT - (usually) exist on this, current repo. + (usually) exist in this repo. 'mode' A black hole at this time. Trying to keep the input args - similar between Tree, Blob and Subprocess instantiation classes. + similar between Tree, Blob and Submodule classes. 'name' This is just the last segment in the submodule's full local path. It's the name of the actual folder to which a submodule is tied. 'mode' A black hole at this time. Trying to keep the input args - similar between Tree, Blob and Subprocess instantiation classes. + similar between Tree, Blob and Submodule classes. 'commit_context' A string with ID of the commit that was the root for the tree structure that lead us to this folder (Tree object) that contains @@ -57,9 +58,9 @@ class Submodule(object): the parent folders we passed on the way from root of the commit to this point in the folder tree. Submodules in the .gitmodules are referenced by their full path - and contents of this argument are used to retrieve the URI of the + and the contents of this argument is used to retrieve the URI of the remote repo tied to this full local path. - Example: "/lib/vendor/vendors_repoA" + Example: "lib/vendor/vendors_repoA" """ self.repo = repo self.id = id diff --git a/test/git/.directory b/test/git/.directory deleted file mode 100644 index b4ada076..00000000 --- a/test/git/.directory +++ /dev/null @@ -1,3 +0,0 @@ -[Dolphin] -Timestamp=2010,10,28,0,8,28 -ViewMode=1 diff --git a/test/git/test_submodule.py b/test/git/test_submodule.py index bd4179ce..710481a4 100644 --- a/test/git/test_submodule.py +++ b/test/git/test_submodule.py @@ -8,9 +8,6 @@ import os.path import sys -execpath = os.getcwd() -sys.path.append(os.path.join(execpath, 'gitpython\lib')) - import unittest import tempfile import shutil @@ -57,9 +54,3 @@ class TestSubmodule(unittest.TestCase): self.assertEqual(t_s2.url, 'git://gitorious.org/git_http_backend_py/git_http_backend_py.git') self.assertEqual(tb_s2.url, 'git://gitorious.org/git_http_backend_py/git_http_backend_py.git') -if __name__ == "__main__": - unittest.TextTestRunner(verbosity=2).run( - unittest.TestSuite([ - unittest.TestLoader().loadTestsFromTestCase(TestSubmodule), - ]) - ) diff --git a/test_submodule.py b/test_submodule.py deleted file mode 100644 index 11f336a4..00000000 --- a/test_submodule.py +++ /dev/null @@ -1,75 +0,0 @@ -# test_submodule.py -# Copyright (C) 2008-2010 Michael Trier (mtrier@gmail.com) and contributors -# -# This module is part of GitPython and is released under -# the BSD License: http://www.opensource.org/licenses/bsd-license.php - -import os.path -import sys - -execpath = os.getcwd() -sys.path.append(os.path.join(execpath, 'gitpython\lib')) - -import unittest -import tempfile -import shutil -import zipfile - -from test.testlib import * -from git import * - -class test_Submodule(unittest.TestCase): - - def setUp(self): - _p = tempfile.mkdtemp() - demo_repos_file = fixture_path('sample_tree_of_repos_v1.zip') - zipfile.ZipFile(demo_repos_file).extractall(_p) - self.base_path = os.path.join(_p, 'reposbase') - - def tearDown(self): - shutil.rmtree(self.base_path, True) - - def dtest_01_browser_methods(self): - _m = self._rpc_tree['browser.listdir'] - self.assertEquals( - _m(''), - {'path':'/', 'dirs':[{'name':'projects'},{'name':'teams'},{'name':'users'}]} - ) - self.assertEquals( - _m('/'), - {'path':'/', 'dirs':[{'name':'projects'},{'name':'teams'},{'name':'users'}]} - ) - self.assertEquals( - _m('\\'), - {'path':'/', 'dirs':[{'name':'projects'},{'name':'teams'},{'name':'users'}]} - ) - # crossing fingers and hoping the order is same on all platforms. - self.assertEquals( - _m('projects'), - {'path':'/projects', 'dirs':[ - {'name':'common_files'}, - {'name':'demorepoone','is_git_dir':True}, - {'name':'projectone','is_git_dir':True} - ]} - ) - self.assertEquals( - _m('projects/common_files'), - {'path':'/projects/common_files', 'dirs':[]} - ) - # we don't allow seeing files / folders inside repo folders - self.assertRaises(grm.PathUnfitError, _m, 'projects/demorepoone') - self.assertRaises(grm.PathUnfitError, _m, 'projects/demorepoone/objects') - # on top of fobiden, it also does not exist. - self.assertRaises(grm.PathUnfitError, _m, 'projects/demorepoone/kjhgjg') - # all these should not exist - self.assertRaises(grm.PathUnfitError, _m, 'projects/blah') - self.assertRaises(grm.PathUnfitError, _m, '/blah') - # we should forbid seeing contents of folders above base path. - self.assertRaises(grm.PathUnfitError, _m, 'projects/../../../blah') - -if __name__ == "__main__": - unittest.TextTestRunner(verbosity=2).run( - unittest.TestSuite([ - unittest.TestLoader().loadTestsFromTestCase(test_Submodule), - ]) - ) -- cgit v1.2.1