/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/git/tests/test_remote.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    HeadUpdateFailed,
45
45
    RemoteGitError,
46
46
    RemoteGitBranchFormat,
47
 
    _git_url_and_path_from_transport,
48
47
    )
49
48
 
50
49
from dulwich import porcelain
65
64
        self.assertEqual(("foo", None, "la", "/bar"),
66
65
                         split_git_url("git://la@foo/bar"))
67
66
 
68
 
    def test_username_password(self):
69
 
        self.assertEqual(
70
 
            ("foo", None, "la", "/bar"),
71
 
            split_git_url("git://la:passwd@foo/bar"))
72
 
 
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"))
84
78
 
85
 
    def test_file(self):
86
 
        self.assertEqual(
87
 
            ("", None, None, "/bar"),
88
 
            split_git_url("file:///bar"))
89
 
 
90
79
 
91
80
class ParseGitErrorTests(TestCase):
92
81
 
135
124
        self.assertEqual(e.path, 'porridge/gaduhistory.git')
136
125
        self.assertEqual(e.extra, ': denied to jelmer')
137
126
 
138
 
    def test_invalid_repo_name(self):
139
 
        e = parse_git_error(
140
 
            "url",
141
 
            """Gregwar/fatcat/tree/debian is not a valid repository name
142
 
Email support@github.com for help
143
 
""")
144
 
        self.assertIsInstance(e, NotBranchError)
145
 
 
146
127
 
147
128
class TestRemoteGitBranchFormat(TestCase):
148
129
 
357
338
             },
358
339
            self.remote_real.get_refs())
359
340
 
360
 
    def test_push_branch_symref(self):
361
 
        cfg = self.remote_real.get_config()
362
 
        cfg.set((b'core', ), b'bare', True)
363
 
        cfg.write_to_path()
364
 
        self.remote_real.refs.set_symbolic_ref(b'HEAD', b'refs/heads/master')
365
 
        c1 = self.remote_real.do_commit(
366
 
            message=b'message',
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'])
373
 
        wt.add(['blah'])
374
 
        revid = wt.commit('blah')
375
 
 
376
 
        if self._from_format == 'git':
377
 
            result = remote.push_branch(wt.branch, overwrite=True)
378
 
        else:
379
 
            result = remote.push_branch(wt.branch, lossy=True, overwrite=True)
380
 
 
381
 
        self.assertEqual(None, result.old_revno)
382
 
        if self._from_format == 'git':
383
 
            self.assertEqual(1, result.new_revno)
384
 
        else:
385
 
            self.assertIs(None, result.new_revno)
386
 
 
387
 
        result.report(BytesIO())
388
 
 
389
 
        self.assertEqual(
390
 
            {
391
 
                b'HEAD': self.remote_real.refs[b'refs/heads/master'],
392
 
                b'refs/heads/master': self.remote_real.refs[b'refs/heads/master'],
393
 
            },
394
 
            self.remote_real.get_refs())
395
 
 
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()})
570
 
        self.assertEqual(
571
 
            set(['', 'blah', 'master']), set(remote.branch_names()))
572
515
 
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)
661
 
 
662
 
 
663
 
class GitUrlAndPathFromTransportTests(TestCase):
664
 
 
665
 
    def test_file(self):
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')
669
 
 
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')
674
 
 
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')
680
 
 
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')
686
 
 
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')