Esempio n. 1
0
    def test_uncommon_branch_names(self):
        stderr_lines = fixture('uncommon_branch_prefix_stderr').decode('ascii').splitlines()
        fetch_lines = fixture('uncommon_branch_prefix_FETCH_HEAD').decode('ascii').splitlines()

        # The contents of the files above must be fetched with a custom refspec:
        # +refs/pull/*:refs/heads/pull/*
        res = [FetchInfo._from_line('ShouldntMatterRepo', stderr, fetch_line)
               for stderr, fetch_line in zip(stderr_lines, fetch_lines)]
        assert len(res)
        assert res[0].remote_ref_path == 'refs/pull/1/head'
        assert res[0].ref.path == 'refs/heads/pull/1/head'
        assert isinstance(res[0].ref, Head)
Esempio n. 2
0
    def test_fetch_info(self):
        # assure we can handle remote-tracking branches
        fetch_info_line_fmt = "c437ee5deb8d00cf02f03720693e4c802e99f390	not-for-merge	%s '0.3' of "
        fetch_info_line_fmt += "git://github.com/gitpython-developers/GitPython"
        remote_info_line_fmt = "* [new branch]      nomatter     -> %s"

        self.failUnlessRaises(
            ValueError, FetchInfo._from_line, self.rorepo,
            remote_info_line_fmt % "refs/something/branch",
            "269c498e56feb93e408ed4558c8138d750de8893\t\t/Users/ben/test/foo\n"
        )

        fi = FetchInfo._from_line(
            self.rorepo, remote_info_line_fmt % "local/master",
            fetch_info_line_fmt % 'remote-tracking branch')
        assert not fi.ref.is_valid()
        assert fi.ref.name == "local/master"

        # handles non-default refspecs: One can specify a different path in refs/remotes
        # or a special path just in refs/something for instance

        fi = FetchInfo._from_line(self.rorepo,
                                  remote_info_line_fmt % "subdir/tagname",
                                  fetch_info_line_fmt % 'tag')

        assert isinstance(fi.ref, TagReference)
        assert fi.ref.path.startswith('refs/tags')

        # it could be in a remote direcftory though
        fi = FetchInfo._from_line(
            self.rorepo, remote_info_line_fmt % "remotename/tags/tagname",
            fetch_info_line_fmt % 'tag')

        assert isinstance(fi.ref, TagReference)
        assert fi.ref.path.startswith('refs/remotes/')

        # it can also be anywhere !
        tag_path = "refs/something/remotename/tags/tagname"
        fi = FetchInfo._from_line(self.rorepo, remote_info_line_fmt % tag_path,
                                  fetch_info_line_fmt % 'tag')

        assert isinstance(fi.ref, TagReference)
        assert fi.ref.path == tag_path

        # branches default to refs/remotes
        fi = FetchInfo._from_line(self.rorepo,
                                  remote_info_line_fmt % "remotename/branch",
                                  fetch_info_line_fmt % 'branch')

        assert isinstance(fi.ref, RemoteReference)
        assert fi.ref.remote_name == 'remotename'

        # but you can force it anywhere, in which case we only have a references
        fi = FetchInfo._from_line(
            self.rorepo, remote_info_line_fmt % "refs/something/branch",
            fetch_info_line_fmt % 'branch')

        assert type(fi.ref) is Reference
        assert fi.ref.path == "refs/something/branch"
Esempio n. 3
0
    def test_fetch_info(self):
        # assure we can handle remote-tracking branches
        fetch_info_line_fmt = "c437ee5deb8d00cf02f03720693e4c802e99f390	not-for-merge	%s '0.3' of "
        fetch_info_line_fmt += "git://github.com/gitpython-developers/GitPython"
        remote_info_line_fmt = "* [new branch]      nomatter     -> %s"

        self.failUnlessRaises(ValueError, FetchInfo._from_line, self.rorepo,
                              remote_info_line_fmt % "refs/something/branch",
                              "269c498e56feb93e408ed4558c8138d750de8893\t\t/Users/ben/test/foo\n")

        fi = FetchInfo._from_line(self.rorepo,
                                  remote_info_line_fmt % "local/master",
                                  fetch_info_line_fmt % 'remote-tracking branch')
        assert not fi.ref.is_valid()
        assert fi.ref.name == "local/master"

        # handles non-default refspecs: One can specify a different path in refs/remotes
        # or a special path just in refs/something for instance

        fi = FetchInfo._from_line(self.rorepo,
                                  remote_info_line_fmt % "subdir/tagname",
                                  fetch_info_line_fmt % 'tag')

        assert isinstance(fi.ref, TagReference)
        assert fi.ref.path.startswith('refs/tags')

        # it could be in a remote direcftory though
        fi = FetchInfo._from_line(self.rorepo,
                                  remote_info_line_fmt % "remotename/tags/tagname",
                                  fetch_info_line_fmt % 'tag')

        assert isinstance(fi.ref, TagReference)
        assert fi.ref.path.startswith('refs/remotes/')

        # it can also be anywhere !
        tag_path = "refs/something/remotename/tags/tagname"
        fi = FetchInfo._from_line(self.rorepo,
                                  remote_info_line_fmt % tag_path,
                                  fetch_info_line_fmt % 'tag')

        assert isinstance(fi.ref, TagReference)
        assert fi.ref.path == tag_path

        # branches default to refs/remotes
        fi = FetchInfo._from_line(self.rorepo,
                                  remote_info_line_fmt % "remotename/branch",
                                  fetch_info_line_fmt % 'branch')

        assert isinstance(fi.ref, RemoteReference)
        assert fi.ref.remote_name == 'remotename'

        # but you can force it anywhere, in which case we only have a references
        fi = FetchInfo._from_line(self.rorepo,
                                  remote_info_line_fmt % "refs/something/branch",
                                  fetch_info_line_fmt % 'branch')

        assert type(fi.ref) is Reference
        assert fi.ref.path == "refs/something/branch"