def setUp(self): super(GitServerSideBand64kTestCase, self).setUp() # side-band-64k is broken in the widows client. # https://github.com/msysgit/git/issues/101 # Fix has landed for the 1.9.3 release. if os.name == 'nt': require_git_version((1, 9, 3))
def test_new_shallow_clone_from_dulwich(self): require_git_version(self.min_single_branch_version) self._source_repo = self.import_repo("server_new.export") self._stub_repo = _StubRepo("shallow") self.addCleanup(tear_down_repo, self._stub_repo) port = self._start_server(self._source_repo) # Fetch at depth 1 run_git_or_fail( [ "clone", "--mirror", "--depth=1", "--no-single-branch", self.url(port), self._stub_repo.path, ] ) clone = self._stub_repo = Repo(self._stub_repo.path) expected_shallow = [ b"35e0b59e187dd72a0af294aedffc213eaa4d03ff", b"514dc6d3fbfe77361bcaef320c4d21b72bc10be9", ] self.assertEqual(expected_shallow, _get_shallow(clone)) self.assertReposNotEqual(clone, self._source_repo)
def test_fetch_same_depth_into_shallow_clone_from_dulwich(self): require_git_version(self.min_single_branch_version) self._source_repo = self.import_repo("server_new.export") self._stub_repo = _StubRepo("shallow") self.addCleanup(tear_down_repo, self._stub_repo) port = self._start_server(self._source_repo) # Fetch at depth 2 run_git_or_fail( [ "clone", "--mirror", "--depth=2", "--no-single-branch", self.url(port), self._stub_repo.path, ] ) clone = self._stub_repo = Repo(self._stub_repo.path) # Fetching at the same depth is a no-op. run_git_or_fail( ["fetch", "--depth=2", self.url(port)] + self.branch_args(), cwd=self._stub_repo.path, ) expected_shallow = [ b"94de09a530df27ac3bb613aaecdd539e0a0655e1", b"da5cd81e1883c62a25bb37c4d1f8ad965b29bf8d", ] self.assertEqual(expected_shallow, _get_shallow(clone)) self.assertReposNotEqual(clone, self._source_repo)
def setUp(self): require_git_version((1, 5, 0)) super(TestPack, self).setUp() self._tempdir = tempfile.mkdtemp() if not isinstance(self._tempdir, bytes): self._tempdir = self._tempdir.encode(sys.getfilesystemencoding()) self.addCleanup(shutil.rmtree, self._tempdir)
def test_git_worktree_config(self): """Test that git worktree config parsing matches the git CLI's behavior.""" # Set some config value in the main repo using the git CLI require_git_version((2, 7, 0)) test_name = "Jelmer" test_email = "*****@*****.**" run_git_or_fail(["config", "user.name", test_name], cwd=self._repo.path) run_git_or_fail(["config", "user.email", test_email], cwd=self._repo.path) worktree_cfg = self._worktree_repo.get_config() main_cfg = self._repo.get_config() # Assert that both the worktree repo and main repo have the same view of the config, # and that the config matches what we set with the git cli self.assertEqual(worktree_cfg, main_cfg) for c in [worktree_cfg, main_cfg]: self.assertEqual(test_name.encode(), c.get((b"user", ), b"name")) self.assertEqual(test_email.encode(), c.get((b"user", ), b"email")) # Read the config values in the worktree with the git cli and assert they match # the dulwich-parsed configs output_name = run_git_or_fail( ["config", "user.name"], cwd=self._mainworktree_repo.path).decode().rstrip("\n") output_email = run_git_or_fail( ["config", "user.email"], cwd=self._mainworktree_repo.path).decode().rstrip("\n") self.assertEqual(test_name, output_name) self.assertEqual(test_email, output_email)
def test_fetch_full_depth_into_shallow_clone_from_dulwich(self): require_git_version(self.min_single_branch_version) self._source_repo = self.import_repo('server_new.export') self._stub_repo = _StubRepo('shallow') self.addCleanup(tear_down_repo, self._stub_repo) port = self._start_server(self._source_repo) # Fetch at depth 1 run_git_or_fail([ 'clone', '--mirror', '--depth=1', '--no-single-branch', self.url(port), self._stub_repo.path ]) clone = self._stub_repo = Repo(self._stub_repo.path) # Fetching at the same depth is a no-op. run_git_or_fail( ['fetch', '--depth=1', self.url(port)] + self.branch_args(), cwd=self._stub_repo.path) # The whole repo only has depth 3, so it should equal server_new. run_git_or_fail( ['fetch', '--depth=3', self.url(port)] + self.branch_args(), cwd=self._stub_repo.path) self.assertEqual([], _get_shallow(clone)) self.assertReposEqual(clone, self._source_repo)
def test_simple(self): # TODO(jelmer): Remove this once dulwich has its own implementation of archive. require_git_version((1, 5, 0)) c1, c2, c3 = build_commit_graph(self.repo.object_store, [[1], [2, 1], [3, 1, 2]]) self.repo.refs[b"refs/heads/master"] = c3.id out = BytesIO() err = BytesIO() porcelain.archive(self.repo.path, b"refs/heads/master", outstream=out, errstream=err) self.assertEqual(b"", err.getvalue()) tf = tarfile.TarFile(fileobj=out) self.addCleanup(tf.close) self.assertEqual([], tf.getnames())
def test_simple(self): # TODO(jelmer): Remove this once dulwich has its own implementation of archive. require_git_version((1, 5, 0)) c1, c2, c3 = build_commit_graph(self.repo.object_store, [[1], [2, 1], [3, 1, 2]]) self.repo.refs["refs/heads/master"] = c3.id out = BytesIO() err = BytesIO() porcelain.archive(self.repo.path, "refs/heads/master", outstream=out, errstream=err) self.assertEqual("", err.getvalue()) tf = tarfile.TarFile(fileobj=out) self.addCleanup(tf.close) self.assertEqual([], tf.getnames())
def test_git_worktree_list(self): # 'git worktree list' was introduced in 2.7.0 require_git_version((2, 7, 0)) output = run_git_or_fail(["worktree", "list"], cwd=self._repo.path) worktrees = self._parse_worktree_list(output) self.assertEqual(len(worktrees), self._number_of_working_tree) self.assertEqual(worktrees[0][1], "(bare)") self.assertTrue(os.path.samefile(worktrees[0][0], self._mainworktree_repo.path)) output = run_git_or_fail(["worktree", "list"], cwd=self._mainworktree_repo.path) worktrees = self._parse_worktree_list(output) self.assertEqual(len(worktrees), self._number_of_working_tree) self.assertEqual(worktrees[0][1], "(bare)") self.assertTrue(os.path.samefile(worktrees[0][0], self._mainworktree_repo.path))
def test_new_shallow_clone_from_dulwich(self): require_git_version(self.min_single_branch_version) self._source_repo = self.import_repo('server_new.export') self._stub_repo = _StubRepo('shallow') self.addCleanup(tear_down_repo, self._stub_repo) port = self._start_server(self._source_repo) # Fetch at depth 1 run_git_or_fail(['clone', '--mirror', '--depth=1', '--no-single-branch', self.url(port), self._stub_repo.path]) clone = self._stub_repo = Repo(self._stub_repo.path) expected_shallow = [b'35e0b59e187dd72a0af294aedffc213eaa4d03ff', b'514dc6d3fbfe77361bcaef320c4d21b72bc10be9'] self.assertEqual(expected_shallow, _get_shallow(clone)) self.assertNotEqual(clone, self._source_repo)
def test_new_shallow_clone_from_dulwich(self): require_git_version(self.min_single_branch_version) self._source_repo = self.import_repo('server_new.export') self._stub_repo = _StubRepo('shallow') self.addCleanup(tear_down_repo, self._stub_repo) port = self._start_server(self._source_repo) # Fetch at depth 1 run_git_or_fail(['clone', '--mirror', '--depth=1', '--no-single-branch', self.url(port), self._stub_repo.path]) clone = self._stub_repo = Repo(self._stub_repo.path) expected_shallow = [b'94de09a530df27ac3bb613aaecdd539e0a0655e1', b'da5cd81e1883c62a25bb37c4d1f8ad965b29bf8d'] self.assertEqual(expected_shallow, _get_shallow(clone)) self.assertReposNotEqual(clone, self._source_repo)
def test_git_worktree_list(self): # 'git worktree list' was introduced in 2.7.0 require_git_version((2, 7, 0)) output = run_git_or_fail(['worktree', 'list'], cwd=self._repo.path) worktrees = self._parse_worktree_list(output) self.assertEqual(len(worktrees), self._number_of_working_tree) self.assertEqual(worktrees[0][1], '(bare)') self.assertEqual(os.path.normcase(worktrees[0][0]), os.path.normcase(self._mainworktree_repo.path)) output = run_git_or_fail( ['worktree', 'list'], cwd=self._mainworktree_repo.path) worktrees = self._parse_worktree_list(output) self.assertEqual(len(worktrees), self._number_of_working_tree) self.assertEqual(worktrees[0][1], '(bare)') self.assertEqual(os.path.normcase(worktrees[0][0]), os.path.normcase(self._mainworktree_repo.path))
def test_git_worktree_list(self): # 'git worktree list' was introduced in 2.7.0 require_git_version((2, 7, 0)) output = run_git_or_fail(['worktree', 'list'], cwd=self._repo.path) worktrees = self._parse_worktree_list(output) self.assertEqual(len(worktrees), self._number_of_working_tree) self.assertEqual(worktrees[0][1], '(bare)') self.assertEqual(os.path.normcase(worktrees[0][0]), os.path.normcase(self._mainworktree_repo.path)) output = run_git_or_fail(['worktree', 'list'], cwd=self._mainworktree_repo.path) worktrees = self._parse_worktree_list(output) self.assertEqual(len(worktrees), self._number_of_working_tree) self.assertEqual(worktrees[0][1], '(bare)') self.assertEqual(os.path.normcase(worktrees[0][0]), os.path.normcase(self._mainworktree_repo.path))
def test_new_shallow_clone_from_dulwich(self): require_git_version(self.min_single_branch_version) self._source_repo = self.import_repo('server_new.export') self._stub_repo = _StubRepo('shallow') self.addCleanup(tear_down_repo, self._stub_repo) port = self._start_server(self._source_repo) # Fetch at depth 1 run_git_or_fail([ 'clone', '--mirror', '--depth=1', '--no-single-branch', self.url(port), self._stub_repo.path ]) clone = self._stub_repo = Repo(self._stub_repo.path) expected_shallow = [ b'94de09a530df27ac3bb613aaecdd539e0a0655e1', b'da5cd81e1883c62a25bb37c4d1f8ad965b29bf8d' ] self.assertEqual(expected_shallow, _get_shallow(clone)) self.assertReposNotEqual(clone, self._source_repo)
def test_shallow_clone_from_git_is_identical(self): require_git_version(self.min_single_branch_version) self._source_repo = self.import_repo('server_new.export') self._stub_repo_git = _StubRepo('shallow-git') self.addCleanup(tear_down_repo, self._stub_repo_git) self._stub_repo_dw = _StubRepo('shallow-dw') self.addCleanup(tear_down_repo, self._stub_repo_dw) # shallow clone using stock git, then using dulwich run_git_or_fail(['clone', '--mirror', '--depth=1', '--no-single-branch', 'file://' + self._source_repo.path, self._stub_repo_git.path]) port = self._start_server(self._source_repo) run_git_or_fail(['clone', '--mirror', '--depth=1', '--no-single-branch', self.url(port), self._stub_repo_dw.path]) # compare the two clones; they should be equal self.assertEqual(Repo(self._stub_repo_git.path), Repo(self._stub_repo_dw.path))
def test_shallow_clone_from_git_is_identical(self): require_git_version(self.min_single_branch_version) self._source_repo = self.import_repo('server_new.export') self._stub_repo_git = _StubRepo('shallow-git') self.addCleanup(tear_down_repo, self._stub_repo_git) self._stub_repo_dw = _StubRepo('shallow-dw') self.addCleanup(tear_down_repo, self._stub_repo_dw) # shallow clone using stock git, then using dulwich run_git_or_fail(['clone', '--mirror', '--depth=1', '--no-single-branch', 'file://' + self._source_repo.path, self._stub_repo_git.path]) port = self._start_server(self._source_repo) run_git_or_fail(['clone', '--mirror', '--depth=1', '--no-single-branch', self.url(port), self._stub_repo_dw.path]) # compare the two clones; they should be equal self.assertReposEqual(Repo(self._stub_repo_git.path), Repo(self._stub_repo_dw.path))
def test_fetch_full_depth_into_shallow_clone_from_dulwich(self): require_git_version(self.min_single_branch_version) self._source_repo = self.import_repo('server_new.export') self._stub_repo = _StubRepo('shallow') self.addCleanup(tear_down_repo, self._stub_repo) port = self._start_server(self._source_repo) # Fetch at depth 1 run_git_or_fail(['clone', '--mirror', '--depth=1', '--no-single-branch', self.url(port), self._stub_repo.path]) clone = self._stub_repo = Repo(self._stub_repo.path) # Fetching at the same depth is a no-op. run_git_or_fail( ['fetch', '--depth=1', self.url(port)] + self.branch_args(), cwd=self._stub_repo.path) # The whole repo only has depth 3, so it should equal server_new. run_git_or_fail( ['fetch', '--depth=3', self.url(port)] + self.branch_args(), cwd=self._stub_repo.path) self.assertEqual([], _get_shallow(clone)) self.assertReposEqual(clone, self._source_repo)
def assertRequireSucceeds(self, required_version): try: utils.require_git_version(required_version) except SkipTest: self.fail()
def setUp(self): require_git_version((1, 5, 0)) super(TestPack, self).setUp() self._tempdir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, self._tempdir)
def setUp(self): require_git_version((1, 5, 0)) PackTests.setUp(self) self._tempdir = tempfile.mkdtemp()