1
# Copyright (C) 2007 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Test the GitDir class"""
19
from dulwich.repo import Repo as GitRepo
27
from bzrlib.tests import TestSkipped
29
from bzrlib.plugins.git import (
36
class TestGitDir(tests.TestCaseInTempDir):
38
def test_get_head_branch_reference(self):
41
gd = bzrdir.BzrDir.open('.')
43
"%s,ref=refs%%2Fheads%%2Fmaster" %
44
urlutils.local_path_to_url(os.path.abspath(".")),
45
gd.get_branch_reference())
47
def test_open_existing(self):
50
gd = bzrdir.BzrDir.open('.')
51
self.assertIsInstance(gd, dir.LocalGitDir)
53
def test_open_workingtree(self):
56
gd = bzrdir.BzrDir.open('.')
58
wt = gd.open_workingtree()
59
self.assertIsInstance(wt, workingtree.GitWorkingTree)
61
def test_open_workingtree_bare(self):
62
GitRepo.init_bare(".")
64
gd = bzrdir.BzrDir.open('.')
65
self.assertRaises(errors.NoWorkingTree, gd.open_workingtree)
68
class TestGitDirFormat(tests.TestCase):
71
super(TestGitDirFormat, self).setUp()
72
self.format = dir.LocalGitControlDirFormat()
74
def test_get_format_description(self):
75
self.assertEquals("Local Git Repository",
76
self.format.get_format_description())
79
format2 = dir.LocalGitControlDirFormat()
80
self.assertEquals(self.format, format2)
81
self.assertEquals(self.format, self.format)
82
bzr_format = bzrdir.format_registry.make_bzrdir("default")
83
self.assertNotEquals(self.format, bzr_format)