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_pre_receive_hook_declined(self):
141
'pre-receive hook declined')
142
self.assertIsInstance(e, PermissionDenied)
143
self.assertEqual(e.path, "url")
144
self.assertEqual(e.extra, ': pre-receive hook declined')
146
def test_invalid_repo_name(self):
149
"""Gregwar/fatcat/tree/debian is not a valid repository name
150
Email support@github.com for help
152
self.assertIsInstance(e, NotBranchError)
154
def test_invalid_git_error(self):
158
'GitLab: You are not allowed to push code to protected '
159
'branches on this project.'),
163
'GitLab: You are not allowed to push code to '
164
'protected branches on this project.')))
167
class ParseHangupTests(TestCase):
170
super(ParseHangupTests, self).setUp()
172
HangupException([b'foo'])
174
self.skipTest('dulwich version too old')
176
def test_not_set(self):
177
self.assertIsInstance(
178
parse_git_hangup('http://', HangupException()), HangupException)
180
def test_single_line(self):
182
RemoteGitError('foo bar'),
183
parse_git_hangup('http://', HangupException([b'foo bar'])))
185
def test_multi_lines(self):
187
RemoteGitError('foo bar\nbla bla'),
189
'http://', HangupException([b'foo bar', b'bla bla'])))
191
def test_filter_boring(self):
193
RemoteGitError('foo bar'), parse_git_hangup('http://', HangupException(
194
[b'=======', b'foo bar', b'======'])))
196
RemoteGitError('foo bar'), parse_git_hangup('http://', HangupException(
197
[b'remote: =======', b'remote: foo bar', b'remote: ======'])))
199
def test_permission_denied(self):
201
PermissionDenied('http://', 'You are not allowed to push code to this project.'),
206
b'You are not allowed to push code to this project.', b'', b'======'])))
209
128
class TestRemoteGitBranchFormat(TestCase):
420
339
self.remote_real.get_refs())
422
def test_push_branch_symref(self):
423
cfg = self.remote_real.get_config()
424
cfg.set((b'core', ), b'bare', True)
426
self.remote_real.refs.set_symbolic_ref(b'HEAD', b'refs/heads/master')
427
c1 = self.remote_real.do_commit(
429
committer=b'committer <committer@example.com>',
430
author=b'author <author@example.com>',
431
ref=b'refs/heads/master')
432
remote = ControlDir.open(self.remote_url)
433
wt = self.make_branch_and_tree('local', format=self._from_format)
434
self.build_tree(['local/blah'])
436
revid = wt.commit('blah')
438
if self._from_format == 'git':
439
result = remote.push_branch(wt.branch, overwrite=True)
441
result = remote.push_branch(wt.branch, lossy=True, overwrite=True)
443
self.assertEqual(None, result.old_revno)
444
if self._from_format == 'git':
445
self.assertEqual(1, result.new_revno)
447
self.assertIs(None, result.new_revno)
449
result.report(BytesIO())
453
b'HEAD': self.remote_real.refs[b'refs/heads/master'],
454
b'refs/heads/master': self.remote_real.refs[b'refs/heads/master'],
456
self.remote_real.get_refs())
458
341
def test_push_branch_new_with_tags(self):
459
342
remote = ControlDir.open(self.remote_url)
460
343
builder = self.make_branch_builder('local', format=self._from_format)
629
512
self.assertEqual(
630
513
{'': 'master', 'blah': 'blah', 'master': 'master'},
631
514
{n: b.name for (n, b) in remote.get_branches().items()})
633
set(['', 'blah', 'master']), set(remote.branch_names()))
635
516
def test_remove_tag(self):
636
517
c1 = self.remote_real.do_commit(
720
601
author=b'author <author@example.com>')
721
602
remote = ControlDir.open(self.remote_url)
722
603
self.assertEqual('master', remote.open_branch().nick)
725
class GitUrlAndPathFromTransportTests(TestCase):
728
split_url = _git_url_and_path_from_transport('file:///home/blah')
729
self.assertEqual(split_url.scheme, 'file')
730
self.assertEqual(split_url.path, '/home/blah')
732
def test_file_segment_params(self):
733
split_url = _git_url_and_path_from_transport('file:///home/blah,branch=master')
734
self.assertEqual(split_url.scheme, 'file')
735
self.assertEqual(split_url.path, '/home/blah')
737
def test_git_smart(self):
738
split_url = _git_url_and_path_from_transport(
739
'git://github.com/dulwich/dulwich,branch=master')
740
self.assertEqual(split_url.scheme, 'git')
741
self.assertEqual(split_url.path, '/dulwich/dulwich')
743
def test_https(self):
744
split_url = _git_url_and_path_from_transport(
745
'https://github.com/dulwich/dulwich')
746
self.assertEqual(split_url.scheme, 'https')
747
self.assertEqual(split_url.path, '/dulwich/dulwich')
749
def test_https_segment_params(self):
750
split_url = _git_url_and_path_from_transport(
751
'https://github.com/dulwich/dulwich,branch=master')
752
self.assertEqual(split_url.scheme, 'https')
753
self.assertEqual(split_url.path, '/dulwich/dulwich')