65
64
self.assertEqual(("foo", None, "la", "/bar"),
66
65
split_git_url("git://la@foo/bar"))
68
def test_username_password(self):
70
("foo", None, "la", "/bar"),
71
split_git_url("git://la:passwd@foo/bar"))
73
67
def test_nopath(self):
74
68
self.assertEqual(("foo", None, None, "/"),
75
69
split_git_url("git://foo/"))
82
76
self.assertEqual(("foo", None, None, "~bar"),
83
77
split_git_url("git://foo/~bar"))
87
("", None, None, "/bar"),
88
split_git_url("file:///bar"))
91
80
class ParseGitErrorTests(TestCase):
135
124
self.assertEqual(e.path, 'porridge/gaduhistory.git')
136
125
self.assertEqual(e.extra, ': denied to jelmer')
138
def test_invalid_repo_name(self):
141
"""Gregwar/fatcat/tree/debian is not a valid repository name
142
Email support@github.com for help
144
self.assertIsInstance(e, NotBranchError)
147
128
class TestRemoteGitBranchFormat(TestCase):
358
339
self.remote_real.get_refs())
360
def test_push_branch_symref(self):
361
cfg = self.remote_real.get_config()
362
cfg.set((b'core', ), b'bare', True)
364
self.remote_real.refs.set_symbolic_ref(b'HEAD', b'refs/heads/master')
365
c1 = self.remote_real.do_commit(
367
committer=b'committer <committer@example.com>',
368
author=b'author <author@example.com>',
369
ref=b'refs/heads/master')
370
remote = ControlDir.open(self.remote_url)
371
wt = self.make_branch_and_tree('local', format=self._from_format)
372
self.build_tree(['local/blah'])
374
revid = wt.commit('blah')
376
if self._from_format == 'git':
377
result = remote.push_branch(wt.branch, overwrite=True)
379
result = remote.push_branch(wt.branch, lossy=True, overwrite=True)
381
self.assertEqual(None, result.old_revno)
382
if self._from_format == 'git':
383
self.assertEqual(1, result.new_revno)
385
self.assertIs(None, result.new_revno)
387
result.report(BytesIO())
391
b'HEAD': self.remote_real.refs[b'refs/heads/master'],
392
b'refs/heads/master': self.remote_real.refs[b'refs/heads/master'],
394
self.remote_real.get_refs())
396
341
def test_push_branch_new_with_tags(self):
397
342
remote = ControlDir.open(self.remote_url)
398
343
builder = self.make_branch_builder('local', format=self._from_format)
567
512
self.assertEqual(
568
513
{'': 'master', 'blah': 'blah', 'master': 'master'},
569
514
{n: b.name for (n, b) in remote.get_branches().items()})
571
set(['', 'blah', 'master']), set(remote.branch_names()))
573
516
def test_remove_tag(self):
574
517
c1 = self.remote_real.do_commit(
658
601
author=b'author <author@example.com>')
659
602
remote = ControlDir.open(self.remote_url)
660
603
self.assertEqual('master', remote.open_branch().nick)
663
class GitUrlAndPathFromTransportTests(TestCase):
666
split_url = _git_url_and_path_from_transport('file:///home/blah')
667
self.assertEqual(split_url.scheme, 'file')
668
self.assertEqual(split_url.path, '/home/blah')
670
def test_file_segment_params(self):
671
split_url = _git_url_and_path_from_transport('file:///home/blah,branch=master')
672
self.assertEqual(split_url.scheme, 'file')
673
self.assertEqual(split_url.path, '/home/blah')
675
def test_git_smart(self):
676
split_url = _git_url_and_path_from_transport(
677
'git://github.com/dulwich/dulwich,branch=master')
678
self.assertEqual(split_url.scheme, 'git')
679
self.assertEqual(split_url.path, '/dulwich/dulwich')
681
def test_https(self):
682
split_url = _git_url_and_path_from_transport(
683
'https://github.com/dulwich/dulwich')
684
self.assertEqual(split_url.scheme, 'https')
685
self.assertEqual(split_url.path, '/dulwich/dulwich')
687
def test_https_segment_params(self):
688
split_url = _git_url_and_path_from_transport(
689
'https://github.com/dulwich/dulwich,branch=master')
690
self.assertEqual(split_url.scheme, 'https')
691
self.assertEqual(split_url.path, '/dulwich/dulwich')