示例#1
0
def test_load() -> None:
    contents = """
repos:
  - src: foo
    url: [email protected]:foo.git
    branch: next

  - src: bar
    url: [email protected]:bar.git
    branch: master
    sha1: ad2b68539c78e749a372414165acdf2a1bb68203

  - src: master
    url: [email protected]:master.git
    tag: v0.1
    copy:
      - src: top.cmake
        dest: CMakeLists.txt
      - src: .clang-format
"""
    manifest = tsrc.Manifest()
    parsed = ruamel.yaml.safe_load(contents)
    manifest.apply_config(parsed)
    assert manifest.get_repos() == [
        tsrc.Repo(
            remotes=[
                tsrc.repo.Remote(name="origin", url="[email protected]:foo.git")
            ],
            src="foo",
            branch="next",
            sha1=None,
            tag=None,
        ),
        tsrc.Repo(
            remotes=[
                tsrc.repo.Remote(name="origin", url="[email protected]:bar.git")
            ],
            src="bar",
            branch="master",
            sha1="ad2b68539c78e749a372414165acdf2a1bb68203",
            tag=None,
        ),
        tsrc.Repo(
            remotes=[
                tsrc.repo.Remote(name="origin",
                                 url="[email protected]:master.git")
            ],
            src="master",
            branch="master",
            sha1=None,
            tag="v0.1",
        ),
    ]
    assert manifest.copyfiles == [
        tsrc.Copy("master", "top.cmake", "CMakeLists.txt"),
        tsrc.Copy("master", ".clang-format", ".clang-format"),
    ]
示例#2
0
def test_get_repo() -> None:
    contents = """
repos:
  - src: foo
    url: [email protected]:proj_one/foo

  - src: bar
    url: [email protected]:proj_two/bar
"""
    manifest = tsrc.Manifest()
    parsed = ruamel.yaml.safe_load(contents)
    manifest.load(parsed)

    def assert_clone_url(src: str, url: str) -> None:
        repo = manifest.get_repo(src)
        assert repo.clone_url == url

    assert_clone_url("foo", "[email protected]:proj_one/foo")
    assert_clone_url("bar", "[email protected]:proj_two/bar")
    with pytest.raises(tsrc.manifest.RepoNotFound) as e:
        manifest.get_repo("no/such")
        assert "no/such" in e.value.message
示例#3
0
def test_load() -> None:
    contents = """
gitlab:
  url: http://gitlab.example.com
github_enterprise:
  url: http://github.example.com
repos:
  - src: foo
    url: [email protected]:foo.git
    branch: next

  - src: bar
    url: [email protected]:bar.git
    branch: master
    sha1: ad2b68539c78e749a372414165acdf2a1bb68203

  - src: master
    url: [email protected]:master.git
    tag: v0.1
    copy:
      - src: top.cmake
        dest: CMakeLists.txt
      - src: .clang-format
"""
    manifest = tsrc.Manifest()
    parsed = ruamel.yaml.safe_load(contents)
    manifest.load(parsed)
    assert manifest.gitlab
    assert manifest.gitlab["url"] == "http://gitlab.example.com"
    assert manifest.github_enterprise
    assert manifest.github_enterprise["url"] == "http://github.example.com"
    assert manifest.get_repos() == [
        tsrc.Repo(
            remotes=[
                tsrc.repo.Remote(name="origin", url="[email protected]:foo.git")
            ],
            src="foo",
            branch="next",
            sha1=None,
            tag=None,
        ),
        tsrc.Repo(
            remotes=[
                tsrc.repo.Remote(name="origin", url="[email protected]:bar.git")
            ],
            src="bar",
            branch="master",
            sha1="ad2b68539c78e749a372414165acdf2a1bb68203",
            tag=None,
        ),
        tsrc.Repo(
            remotes=[
                tsrc.repo.Remote(name="origin",
                                 url="[email protected]:master.git")
            ],
            src="master",
            branch="master",
            sha1=None,
            tag="v0.1",
        ),
    ]
    assert manifest.copyfiles == [
        (os.path.join("master", "top.cmake"), "CMakeLists.txt"),
        (os.path.join("master", ".clang-format"), ".clang-format"),
    ]