| Index: infra/libs/git2/test/git2_test.py
|
| diff --git a/infra/services/gnumbd/test/git_test.py b/infra/libs/git2/test/git2_test.py
|
| similarity index 76%
|
| rename from infra/services/gnumbd/test/git_test.py
|
| rename to infra/libs/git2/test/git2_test.py
|
| index 1adec3fa7fb469f3a73a4355fe0bc8ea047d0288..08abab87dec8286e8763a2ca6c286ade568c648b 100644
|
| --- a/infra/services/gnumbd/test/git_test.py
|
| +++ b/infra/libs/git2/test/git2_test.py
|
| @@ -11,7 +11,7 @@ import tempfile
|
| # 'no __init__ method' - pylint: disable=W0232
|
| from testing_support import git_test_utils
|
|
|
| -from infra.services.gnumbd.support import git, util
|
| +from infra.libs import git2
|
|
|
| class TestBasis(git_test_utils.GitRepoReadWriteTestBase):
|
| REPO_SCHEMA = """
|
| @@ -41,7 +41,7 @@ class TestBasis(git_test_utils.GitRepoReadWriteTestBase):
|
| sys.stderr = stderr
|
|
|
| def setUp(self):
|
| - self.repos_dir = tempfile.mkdtemp(suffix='.gnumbd')
|
| + self.repos_dir = tempfile.mkdtemp(suffix='.git_test')
|
| super(TestBasis, self).setUp()
|
| self.repo.git('branch', 'branch_O', self.repo['O'])
|
|
|
| @@ -50,7 +50,7 @@ class TestBasis(git_test_utils.GitRepoReadWriteTestBase):
|
| super(TestBasis, self).tearDown()
|
|
|
| def mkRepo(self):
|
| - r = git.Repo(self.repo.repo_path)
|
| + r = git2.Repo(self.repo.repo_path)
|
| r.repos_dir = self.repos_dir
|
| self.capture_stdio(r.reify)
|
| return r
|
| @@ -58,10 +58,10 @@ class TestBasis(git_test_utils.GitRepoReadWriteTestBase):
|
|
|
| class TestRepo(TestBasis):
|
| def testEmptyRepo(self):
|
| - r = git.Repo('doesnt_exist')
|
| + r = git2.Repo('doesnt_exist')
|
| r.repos_dir = self.repos_dir
|
|
|
| - with self.assertRaises(util.CalledProcessError):
|
| + with self.assertRaises(git2.CalledProcessError):
|
| self.capture_stdio(r.reify)
|
|
|
| with self.assertRaises(AssertionError):
|
| @@ -137,37 +137,37 @@ class TestRepo(TestBasis):
|
| class TestRef(TestBasis):
|
| def testComparison(self):
|
| r = self.mkRepo()
|
| - O = git.Ref(r, 'refs/heads/branch_O')
|
| + O = git2.Ref(r, 'refs/heads/branch_O')
|
| self.assertEqual(O, O)
|
| - self.assertEqual(O, git.Ref(r, 'refs/heads/branch_O'))
|
| + self.assertEqual(O, git2.Ref(r, 'refs/heads/branch_O'))
|
|
|
| - N = git.Ref(r, 'refs/heads/branch_K')
|
| + N = git2.Ref(r, 'refs/heads/branch_K')
|
| self.assertNotEqual(O, N)
|
|
|
| def testRepr(self):
|
| r = self.mkRepo()
|
| - O = git.Ref(r, 'refs/heads/branch_O')
|
| + O = git2.Ref(r, 'refs/heads/branch_O')
|
| self.assertEqual("Ref(%r, 'refs/heads/branch_O')" % r, repr(O))
|
|
|
| def testCommit(self):
|
| r = self.mkRepo()
|
| self.assertEqual(
|
| - git.Ref(r, 'refs/heads/branch_O').commit.hsh,
|
| + git2.Ref(r, 'refs/heads/branch_O').commit.hsh,
|
| self.repo['O'])
|
|
|
| def testCommitBogus(self):
|
| r = self.mkRepo()
|
| - self.assertIs(git.Ref(r, 'refs/heads/bogus').commit, git.INVALID)
|
| + self.assertIs(git2.Ref(r, 'refs/heads/bogus').commit, git2.INVALID)
|
| # exercise __ne__ and __eq__
|
| - self.assertNotEqual(git.Ref(r, 'refs/heads/bogus').commit,
|
| - git.Ref(r, 'refs/heads/other_bogus').commit)
|
| - self.assertFalse(git.Ref(r, 'refs/heads/bogus').commit ==
|
| - git.Ref(r, 'refs/heads/other_bogus').commit)
|
| + self.assertNotEqual(git2.Ref(r, 'refs/heads/bogus').commit,
|
| + git2.Ref(r, 'refs/heads/other_bogus').commit)
|
| + self.assertFalse(git2.Ref(r, 'refs/heads/bogus').commit ==
|
| + git2.Ref(r, 'refs/heads/other_bogus').commit)
|
|
|
| def testTo(self):
|
| r = self.mkRepo()
|
| - A = git.Ref(r, 'refs/heads/root_A')
|
| - O = git.Ref(r, 'refs/heads/branch_O')
|
| + A = git2.Ref(r, 'refs/heads/root_A')
|
| + O = git2.Ref(r, 'refs/heads/branch_O')
|
| self.assertEqual(
|
| list(c.hsh for c in A.to(O)),
|
| [self.repo[c] for c in 'BCDLMNO']
|
| @@ -175,9 +175,9 @@ class TestRef(TestBasis):
|
|
|
| def testNonFastForward(self):
|
| r = self.mkRepo()
|
| - O = git.Ref(r, 'refs/heads/branch_O')
|
| + O = git2.Ref(r, 'refs/heads/branch_O')
|
| D = r.get_commit(self.repo['D'])
|
| - with self.assertRaises(git.CalledProcessError):
|
| + with self.assertRaises(git2.CalledProcessError):
|
| O.fast_forward_push(D)
|
| self.assertEqual(
|
| self.repo.git('rev-parse', 'branch_O').stdout.strip(),
|
| @@ -185,7 +185,7 @@ class TestRef(TestBasis):
|
|
|
| def testFastForward(self):
|
| r = self.mkRepo()
|
| - O = git.Ref(r, 'refs/heads/branch_O')
|
| + O = git2.Ref(r, 'refs/heads/branch_O')
|
| S = r.get_commit(self.repo['S'])
|
| self.capture_stdio(O.fast_forward_push, S)
|
| self.assertEqual(O.commit.hsh, self.repo['S'])
|
| @@ -197,43 +197,43 @@ class TestRef(TestBasis):
|
| class TestCommit(TestBasis):
|
| def testComparison(self):
|
| r = self.mkRepo()
|
| - c = git.Ref(r, 'refs/heads/branch_O').commit
|
| + c = git2.Ref(r, 'refs/heads/branch_O').commit
|
| self.assertEqual(c, c)
|
| - self.assertEqual(c, git.Ref(r, 'refs/heads/branch_O').commit)
|
| - self.assertNotEqual(c, git.Ref(r, 'refs/heads/branch_S').commit)
|
| + self.assertEqual(c, git2.Ref(r, 'refs/heads/branch_O').commit)
|
| + self.assertNotEqual(c, git2.Ref(r, 'refs/heads/branch_S').commit)
|
| self.assertIs(c.repo, r)
|
|
|
| def testRepr(self):
|
| r = self.mkRepo()
|
| - c = git.Ref(r, 'refs/heads/branch_O').commit
|
| + c = git2.Ref(r, 'refs/heads/branch_O').commit
|
| self.assertEqual("Commit(%r, %r)" % (r, self.repo['O']), repr(c))
|
|
|
| def testData(self):
|
| r = self.mkRepo()
|
| - d = git.Ref(r, 'refs/heads/branch_O').commit.data
|
| + d = git2.Ref(r, 'refs/heads/branch_O').commit.data
|
| self.assertEqual(d.committer.email, 'commitish@example.com')
|
|
|
| def testBogus(self):
|
| r = self.mkRepo()
|
| - d = git.Commit(r, 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef').data
|
| - self.assertIs(d, git.INVALID)
|
| - self.assertIs(d.committer, git.INVALID)
|
| - self.assertIs(d.committer.alter(user='tom'), git.INVALID)
|
| + d = git2.Commit(r, 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef').data
|
| + self.assertIs(d, git2.INVALID)
|
| + self.assertIs(d.committer, git2.INVALID)
|
| + self.assertIs(d.committer.alter(user='tom'), git2.INVALID)
|
|
|
| def testParent(self):
|
| r = self.mkRepo()
|
| - c = git.Ref(r, 'refs/heads/branch_O').commit
|
| + c = git2.Ref(r, 'refs/heads/branch_O').commit
|
| self.assertEqual(c.parent.hsh, self.repo['N'])
|
|
|
| - a = git.Ref(r, 'refs/heads/root_A').commit
|
| + a = git2.Ref(r, 'refs/heads/root_A').commit
|
| self.assertIsNone(a.parent)
|
|
|
| - z = git.Ref(r, 'refs/heads/branch_Z').commit
|
| - self.assertIs(z.parent, git.INVALID)
|
| + z = git2.Ref(r, 'refs/heads/branch_Z').commit
|
| + self.assertIs(z.parent, git2.INVALID)
|
|
|
| def testAlter(self):
|
| r = self.mkRepo()
|
| - c = git.Ref(r, 'refs/heads/branch_O').commit
|
| + c = git2.Ref(r, 'refs/heads/branch_O').commit
|
| d = c.data
|
|
|
| a = c.alter(committer=d.committer.alter(email='bob@dude.example.com'))
|
|
|