示例#1
0
文件: test_sync.py 项目: xzr/tsrc
def test_sync_with_no_update_manifest_flag_leaves_changes(
    tsrc_cli: CLI, git_server: GitServer, workspace_path: Path
) -> None:
    """
    Scenario:
    * Create a manifest with one repo, foo
    * Initialize a workspace from this manifest
    * Add repo bar and do not commit or push this change
    * Run tsrc sync --no-update-manifest
    * The manifest is not updated from the remote, and the change is left
    * Both foo and bar are present after the sync
    """
    git_server.add_repo("foo")
    git_server.push_file("foo", "foo.txt", contents="foo")
    tsrc_cli.run("init", git_server.manifest_url)

    git_server.add_repo("bar", add_to_manifest=False)
    git_server.push_file("bar", "bar.txt", contents="bar")
    add_repo_unstaged("bar", git_server, workspace_path)

    tsrc_cli.run("sync", "--no-update-manifest")

    bar_path = workspace_path / "bar"
    assert bar_path.exists(), "bar should have been synced"
    assert (
        bar_path / "bar.txt"
    ).read_text() == "bar", "bar should have the correct contents"
示例#2
0
文件: test_sync.py 项目: xzr/tsrc
def test_sync_not_on_master(
    tsrc_cli: CLI,
    git_server: GitServer,
    workspace_path: Path,
    message_recorder: MessageRecorder,
) -> None:
    """ "
    Scenario:
    * Create a manifest with two repos, foo and bar
    * Initialize a workspace from this manifest
    * Checkout a different branch on foo, tracking an existing remote
    * Run `tsrc sync`
    * Check that:
       * foo is updated
       * but the command fails because foo was not an the expected branch
    """
    git_server.add_repo("foo")
    git_server.add_repo("bar")

    git_server.push_file("foo", "devel.txt", branch="devel")
    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url)

    foo_path = workspace_path / "foo"
    tsrc.git.run(foo_path, "checkout", "-B", "devel")
    tsrc.git.run(foo_path, "branch", "--set-upstream-to", "origin/devel")

    tsrc_cli.run_and_fail("sync")

    assert (foo_path / "devel.txt").exists(), "foo should have been updated"
    assert message_recorder.find("not on the correct branch")
示例#3
0
文件: test_sync.py 项目: xzr/tsrc
def test_sync_with_force(
    tsrc_cli: CLI, git_server: GitServer, workspace_path: Path
) -> None:
    """
    Scenario:
    * Create a manifest with one repo, foo
    * Create a tag `latest` on foo
    * Initialize a workspace from this manifest
    * Delete and re-create the `latest` tag
    * Run tsrc sync --force
    * Check that the clone was reset to the correct revision
      (aka, `git fetch --force` was called).
    """
    git_server.add_repo("foo")
    git_server.push_file("foo", "latest.txt", contents="1")
    git_server.tag("foo", "latest")
    tsrc_cli.run("init", git_server.manifest_url)

    git_server.push_file("foo", "latest.txt", contents="2")
    git_server.tag("foo", "latest", force=True)
    tsrc_cli.run("sync", "--force")

    foo_path = workspace_path / "foo"
    assert (
        foo_path / "latest.txt"
    ).read_text() == "2", "foo should have been reset to the latest tag"
示例#4
0
def test_foreach_with_all_cloned_repos_requested(
    tsrc_cli: CLI,
    git_server: GitServer,
    workspace_path: Path,
    message_recorder: MessageRecorder,
) -> None:
    """
    * Create a manifest containing:
       * a group named `foo` with repos `bar` and `baz`,
       * a group named `spam` with repos `eggs` and `beacon`
       * a repo named `quux`, not part of any group
    * Initialize a workspace from this manifest, using the `foo` group
    * Force the clone of the `other` repo
    * Check that `tsrc foreach --all-cloned` visits all repos
    """
    git_server.add_group("foo", ["bar", "baz"])
    git_server.add_group("spam", ["eggs", "bacon"])
    quux_url = git_server.add_repo("quux")

    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url, "--groups", "foo", "spam")

    tsrc.git.run(workspace_path, "clone", quux_url)
    message_recorder.reset()

    tsrc_cli.run("foreach", "--all-cloned", "ls")

    assert message_recorder.find("bar\n")
    assert message_recorder.find("baz\n")
    assert message_recorder.find("eggs\n")
    assert message_recorder.find("bacon\n")
    assert message_recorder.find("quux\n")
示例#5
0
def test_foreach_with_groups_from_config(
    tsrc_cli: CLI, git_server: GitServer, message_recorder: MessageRecorder
) -> None:
    """
    * Create a manifest containing:
       * a group named `foo` with repos `bar` and `baz`,
       * a group named `spam` with repos `eggs` and `beacon`
       * a repo named `other`, not part of any group
    * Initialize a workspace from this manifest, using the `foo`
      and `spam` groups
    * Check that `tsrc foreach ---group "foo" --ls README` works and
      runs `ls` only on everything but `other`
    """
    git_server.add_group("foo", ["bar", "baz"])
    git_server.add_group("spam", ["eggs", "beacon"])
    git_server.add_repo("other")

    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url, "--groups", "foo", "spam")

    message_recorder.reset()
    tsrc_cli.run("foreach", "ls")

    assert message_recorder.find("bar\n")
    assert message_recorder.find("baz\n")
    assert message_recorder.find("eggs\n")
    assert not message_recorder.find("other\n")
示例#6
0
def test_status_not_on_any_branch(
    tsrc_cli: CLI,
    git_server: GitServer,
    workspace_path: Path,
    message_recorder: MessageRecorder,
) -> None:
    """Scenario:
    * Create a workspace with one repo
    * Make sure the repo is not an any branch
    * Run `tsrc status`
    * Check that the output contains a sha1
    """
    git_server.add_repo("foo")
    # we need more that one commit
    # to be in 'detached HEAD':
    git_server.push_file("foo", "new.txt")

    git_server.add_repo("bar")

    tsrc_cli.run("init", git_server.manifest_url)

    # detach HEAD on foo repo
    foo_path = workspace_path / "foo"
    run_git(foo_path, "checkout", "HEAD~1")

    tsrc_cli.run("status")

    assert message_recorder.find(r"\* foo [a-f0-9]{7}")
示例#7
0
def test_empty_repo(tsrc_cli: CLI, git_server: GitServer,
                    workspace_path: Path) -> None:
    git_server.add_repo("foo", empty=True)
    git_server.add_repo("bar")

    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url, expect_fail=True)
示例#8
0
def test_use_given_group(
    tsrc_cli: CLI,
    git_server: GitServer,
    workspace_path: Path,
    message_recorder: MessageRecorder,
) -> None:
    """Scenario:
    * Create a manifest with two disjoint groups,
      group1 and group2
    * Initialize a workspace from this manifest using
      the two groups
    * Run `tsrc status --group group1`
    * Check that the output contains repos from group1, but not
      from group2
    """
    git_server.add_group("group1", ["foo"])
    git_server.add_group("group2", ["bar"])

    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url, "--groups", "group1", "group2")

    message_recorder.reset()
    tsrc_cli.run("status", "--group", "group1")
    assert message_recorder.find(r"\* foo"), "foo status have been read"
    assert not message_recorder.find(r"\* bar"), "bar should have been skipped"
示例#9
0
def test_status_incorrect_branch(
    tsrc_cli: CLI,
    git_server: GitServer,
    workspace_path: Path,
    message_recorder: MessageRecorder,
) -> None:
    """Scenario:
    * Create a workspace with  one repo
    * Create and checkout an 'other' branch
    * Run `tsrc status`
    * Check that the repo is shown as not being
      on the correct branch
    """
    git_server.add_repo("foo")

    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url)

    foo_path = workspace_path / "foo"
    run_git(foo_path, "checkout", "-b", "other")
    run_git(foo_path, "push", "--set-upstream", "origin", "other:other")

    tsrc_cli.run("status")

    assert message_recorder.find(r"\* foo\s+other\s+\(expected: master\)")
示例#10
0
def test_status_with_missing_repos(
    tsrc_cli: CLI,
    git_server: GitServer,
    workspace_path: Path,
    message_recorder: MessageRecorder,
) -> None:
    """Scenario:
    * Create a manifest with two repos, foo and bar
    * Initialize a workspace from this manifest
    * Remove the `foo` clone
    * Run `tsrc status`
    * Check that it does not crash
    """
    git_server.add_repo("foo")
    git_server.add_repo("bar")

    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url)

    # shutil.rmtree has trouble removing read-only
    # files in the .git repo, but this won't affect
    # the outcome of the test anyway
    shutil.rmtree(workspace_path / "foo", ignore_errors=True)

    tsrc_cli.run("status")
示例#11
0
def test_init_with_args(
    tsrc_cli: CLI, git_server: GitServer, monkeypatch: Any, tmp_path: Path
) -> None:
    git_server.add_repo("foo")
    work2_path = (tmp_path / "work2").mkdir()
    tsrc_cli.run("init", "--workspace", work2_path, git_server.manifest_url)
    assert_cloned(work2_path, "foo")
示例#12
0
def test_use_specific_groups(
    tsrc_cli: CLI, git_server: GitServer, workspace_path: Path
) -> None:
    """ Scenario:
    * the manifest contains two groups, 'foo' and 'spam'
    * the manifest contains one repo 'other'
    * the 'other' repo is configured with a file copy

    * the user runs `init --group foo, spam`

    * we don't want 'other' to be cloned
    * we don't want the file copy to be attempted
    """
    git_server.add_group("foo", ["bar", "baz"])
    git_server.add_group("spam", ["eggs", "beacon"])
    git_server.add_repo("other")
    git_server.push_file("other", "THANKS")
    git_server.manifest.set_repo_file_copies("other", [("THANKS", "THANKS.copy")])

    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url, "--groups", "foo", "spam")

    assert_cloned(workspace_path, "bar")
    assert_cloned(workspace_path, "eggs")
    assert_not_cloned(workspace_path, "other")
示例#13
0
文件: test_sync.py 项目: xzr/tsrc
def test_copies_are_up_to_date(
    tsrc_cli: CLI, git_server: GitServer, workspace_path: Path
) -> None:
    """
    Scenario:
    * Create a manifest with one repo, foo
    * Configure a copy from foo/foo.txt to top.txt
    * Initialize a workspace from this manifest
    * Push a new version of `foo.txt` to the foo repo
    * Run `tsrc sync`
    * Check that `top.txt` has been updated

    """
    manifest_url = git_server.manifest_url
    git_server.add_repo("foo")
    git_server.push_file("foo", "foo.txt", contents="v1")
    git_server.manifest.set_file_copy("foo", "foo.txt", "top.txt")
    tsrc_cli.run("init", manifest_url)
    git_server.push_file("foo", "foo.txt", contents="v2")

    tsrc_cli.run("sync")

    assert (
        workspace_path / "top.txt"
    ).read_text() == "v2", "copy should have been updated"
    assert (workspace_path / "top.txt").read_text() == "v2"
示例#14
0
文件: test_sync.py 项目: xzr/tsrc
def test_update_symlink(
    tsrc_cli: CLI, git_server: GitServer, workspace_path: Path
) -> None:
    """Scenario:
    * Crate a manifest with a 'foo' repo
    * Push 'foo.txt' to the 'foo' repo
    * Configure the 'foo' repo with a symlink copy from 'foo.link' to 'foo/foo.txt'
    * Run `tsrc init`
    * Update the link in the manifest
    * Push 'bar.txt' to the 'foo' repo
    * Run `tsrc sync`
    * Update the 'foo' repo with a symlink from 'foo.link' to 'foo/bar.txt'
    * Check that the link in <workspace>/foo.link was updated to point to foo/bar.txt
    """
    manifest_url = git_server.manifest_url
    git_server.add_repo("foo")
    git_server.push_file("foo", "foo.txt")
    git_server.manifest.set_symlink("foo", "foo.link", "foo/foo.txt")
    tsrc_cli.run("init", manifest_url)
    git_server.push_file("foo", "bar.txt")
    git_server.manifest.set_symlink("foo", "foo.link", "foo/bar.txt")

    tsrc_cli.run("sync")

    actual_link = workspace_path / "foo.link"
    assert actual_link.exists()
    assert os.readlink(str(actual_link)) == os.path.normpath("foo/bar.txt")
示例#15
0
def test_apply_manifest_adds_new_repo(tsrc_cli: CLI, git_server: GitServer,
                                      workspace_path: Path) -> None:
    """Scenario:

    * Create a manifest with one repo
    * Create a workspace using `tsrc init`
    * Copy the manifest file somewhere in the workspace
    * Create a new repo on the server
    * Edit the copied manifest to contain the new repo
    * Run `tsrc apply-manifest /path/to/copied_manifest`
    * Check that the new repo gets cloned

    """
    git_server.add_repo("foo")
    tsrc_cli.run("init", git_server.manifest_url)

    cloned_manifest_path = workspace_path / ".tsrc/manifest/manifest.yml"
    copied_manifest_path = workspace_path / "manifest.yml"
    shutil.copy(cloned_manifest_path, copied_manifest_path)

    bar_url = git_server.add_repo("bar", add_to_manifest=False)
    add_repo_to_manifest(copied_manifest_path, "bar", bar_url)

    tsrc_cli.run("apply-manifest", str(copied_manifest_path))

    assert (workspace_path /
            "bar").exists(), "bar repo should have been cloned"
示例#16
0
文件: test_init.py 项目: xzr/tsrc
def test_clone_submodules(tsrc_cli: CLI, git_server: GitServer,
                          workspace_path: Path) -> None:
    """
    Scenario:
    * Create repo 'sub1' containing a 'sub2' submodule
    * Create a repo 'top' containing the 'sub1' submodule
    * Add 'top' to the manifest
    * Run `tsrc init`
    * Check that both submodules where cloned properly
    """

    git_server.add_repo("top")
    sub1_url = git_server.add_repo("sub1", add_to_manifest=False)
    sub2_url = git_server.add_repo("sub2", add_to_manifest=False)
    git_server.add_submodule("sub1", url=sub2_url, path=Path("sub2"))
    git_server.add_submodule("top", url=sub1_url, path=Path("sub1"))

    tsrc_cli.run("init", git_server.manifest_url, "-r", "origin")

    clone_path = workspace_path / "top"

    sub1_readme = clone_path / "sub1" / "README"
    assert sub1_readme.exists(), "sub1 was not cloned"

    sub2_readme = clone_path / "sub1" / "sub2" / "README"
    assert sub2_readme.exists(), "sub2 was not cloned"
示例#17
0
def test_set_project_dest_and_branch(
    tsrc_cli: CLI, git_server: GitServer, workspace_path: Path
) -> None:
    git_server.add_repo("foo")
    git_server.add_repo("bar", default_branch="devel")

    tsrc_cli.run("init", git_server.manifest_url)
    bar_path = workspace_path / "bar"
    run_git(bar_path, "checkout", "-b", "other")

    workspace = Workspace(workspace_path)
    manifest = workspace.get_manifest()
    env_setter = EnvSetter(workspace)

    workspace_vars = get_workspace_vars(workspace)
    assert workspace_vars["TSRC_MANIFEST_URL"] == git_server.manifest_url
    assert workspace_vars["TSRC_MANIFEST_BRANCH"] == "master"
    assert workspace_vars["TSRC_WORKSPACE_PATH"] == str(workspace_path)

    foo_repo = manifest.get_repo("foo")
    foo_env = env_setter.get_env_for_repo(foo_repo)
    # check that shared env is part of the result for foo
    assert foo_env["TSRC_MANIFEST_URL"] == git_server.manifest_url
    assert foo_env["TSRC_PROJECT_CLONE_URL"] == foo_repo.clone_url

    # check that bar and foo envs are different
    bar_repo = manifest.get_repo("bar")
    bar_env = env_setter.get_env_for_repo(bar_repo)
    assert bar_env["TSRC_PROJECT_DEST"] == "bar"
    assert bar_env["TSRC_PROJECT_MANIFEST_BRANCH"] == "devel"

    # check that git status is set
    assert bar_env["TSRC_PROJECT_STATUS_BRANCH"] == "other"
示例#18
0
文件: test_sync.py 项目: xzr/tsrc
def test_sync_uses_group_from_config_by_default(
    tsrc_cli: CLI, git_server: GitServer, workspace_path: Path
) -> None:
    """Scenario:
    * Create a manifest containing:
      * a group named 'foo'  containing the repos 'bar'  and 'baz'
      * a repo named 'other' not in any group
    * Initialize a workspace from this manifest using the `foo` group
    * Check that bar and baz are cloned
    * Check that `other` is not cloned
    """
    git_server.add_group("foo", ["bar", "baz"])
    git_server.add_repo("other")

    tsrc_cli.run("init", git_server.manifest_url, "--group", "foo")

    tsrc_cli.run("sync")

    assert (
        workspace_path / "bar"
    ).exists(), "bar should have been cloned (in foo group)"
    assert (
        workspace_path / "baz"
    ).exists(), "baz should have been cloned (in foo group)"
    assert not (
        workspace_path / "other"
    ).exists(), "other should not have been cloned (not in foo group)"
示例#19
0
文件: test_init.py 项目: xzr/tsrc
def test_singular_remote(tsrc_cli: CLI, git_server: GitServer,
                         workspace_path: Path) -> None:
    """
    Scenario:
     * Create a manifest that contains one repo with two remotes
       ('origin' and 'vpn')
     * Make sure that the `origin` URL is valid but the `vpn`
       URL is not.
     * Run `tsrc init --remote origin`
     * Check that foo is cloned
    """
    foo_url = git_server.add_repo("foo")
    vpn_url = "/does/not/exist"
    # fmt: off
    git_server.manifest.set_repo_remotes("foo", [("origin", foo_url),
                                                 ("vpn", vpn_url)])
    # fmt: on

    # only use "origin" remote
    tsrc_cli.run("init", git_server.manifest_url, "-r", "origin")

    foo_path = workspace_path / "foo"
    _, output = tsrc.git.run_captured(foo_path, "remote", "show", check=True)

    assert output == "origin"
示例#20
0
文件: test_sync.py 项目: xzr/tsrc
    def test_can_use_new_group(
        tsrc_cli: CLI, git_server: GitServer, workspace_path: Path
    ) -> None:
        """Scenario:
        * Create a manifest containing:
          * a group named 'default'  containing the repos 'foo'  and 'bar'
        * Initialize a workspace from this manifest using the default group
        * Create a new group 'group1' containing just 'foo'
        * Push a new file to 'foo' and 'bar'
        * Run `tsrc sync --group 'group1'
        * Check only `foo` is updated
        """
        git_server.add_group("default", ["foo", "bar"])

        tsrc_cli.run("init", git_server.manifest_url)

        git_server.manifest.configure_group("group1", ["foo"])
        git_server.push_file("foo", "foo.txt")
        git_server.push_file("bar", "bar.txt")

        tsrc_cli.run("sync", "--group", "group1")

        assert (
            workspace_path / "foo/foo.txt"
        ).exists(), "foo should have been updated - included in the 'group1 group"

        assert not (
            workspace_path / "bar/bar.txt"
        ).exists(), (
            "bar should not have been updated - not included in the 'group1 group"
        )
示例#21
0
文件: test_sync.py 项目: xzr/tsrc
def test_sha1s_are_skipped_when_not_clean(
    tsrc_cli: CLI, git_server: GitServer, workspace_path: Path
) -> None:
    """Scenario:
    * Create a manifest with a foo repo, frozen at an initial revision
    * Initialize a workspace from this manifest
    * Push a new file to the foo repo
    * Configure the manifest so that foo is frozen at the new revision
    * Create an untracked file in the foo repo
    * Run `tsrc sync`
    * Check that `tsrc sync` fails and that foo is not updated
    """
    git_server.add_repo("foo")
    initial_sha1 = git_server.get_sha1("foo")
    git_server.manifest.set_repo_sha1("foo", initial_sha1)

    tsrc_cli.run("init", git_server.manifest_url)
    (workspace_path / "foo/untracked.txt").write_text("")

    git_server.push_file("foo", "new.txt")
    new_sha1 = git_server.get_sha1("foo")
    git_server.manifest.set_repo_sha1("foo", new_sha1)

    tsrc_cli.run_and_fail("sync")

    foo_path = workspace_path / "foo"
    assert not (
        foo_path / "new.txt"
    ).exists(), "foo should not have been updated (untracked files)"
示例#22
0
文件: test_sync.py 项目: xzr/tsrc
def test_sha1s_are_updated_when_clean(
    tsrc_cli: CLI, git_server: GitServer, workspace_path: Path
) -> None:
    """Scenario:
    * Create a manifest with a foo repo, frozen at an initial revision
    * Initialize a workspace from this manifest
    * Push a new file to the foo repo
    * Configure the manifest so that `foo` is frozen at the new revision
    * Run `tsrc sync`
    * Check that foo has been updated to the new revision
    """
    git_server.add_repo("foo")
    initial_sha1 = git_server.get_sha1("foo")
    git_server.manifest.set_repo_sha1("foo", initial_sha1)

    tsrc_cli.run("init", git_server.manifest_url)

    git_server.push_file("foo", "new.txt")
    new_sha1 = git_server.get_sha1("foo")
    git_server.manifest.set_repo_sha1("foo", new_sha1)

    tsrc_cli.run("sync")

    foo_path = workspace_path / "foo"
    assert (
        foo_path / "new.txt"
    ).exists(), f"foo should have been updated to the {new_sha1} revision"
示例#23
0
文件: test_sync.py 项目: xzr/tsrc
def test_tags_are_updated_when_clean(
    tsrc_cli: CLI, git_server: GitServer, workspace_path: Path
) -> None:
    """Scenario:
    * Create a manifest with a foo repo, frozen at the v0.1 tag
    * Initialize a workspace from this manifest
    * Push a new file to the foo repo
    * Create a new v0.2 tag on the foo repo
    * Configure the manifest so that `foo` is frozen at the v0.2 tag
    * Run `tsrc sync`
    * Check that foo has been updated to the `v0.2` tag
    """
    git_server.add_repo("foo")
    git_server.tag("foo", "v0.1")
    git_server.manifest.set_repo_tag("foo", "v0.1")

    tsrc_cli.run("init", git_server.manifest_url)

    git_server.push_file("foo", "new.txt")
    git_server.tag("foo", "v0.2")
    git_server.manifest.set_repo_tag("foo", "v0.2")

    tsrc_cli.run("sync")

    foo_path = workspace_path / "foo"
    assert (
        foo_path / "new.txt"
    ).exists(), "foo should have been updated to the v0.2 tag"
示例#24
0
文件: test_sync.py 项目: xzr/tsrc
def test_sync_with_errors(
    tsrc_cli: CLI,
    git_server: GitServer,
    workspace_path: Path,
    message_recorder: MessageRecorder,
) -> None:
    """ " Scenario:
    * Create a manifest with two repos (foo and bar)
    * Initialize a workspace from this manifest
    * Push a new file to the foo repo
    * Create a merge conflict in the foo repo
    * Run `tsrc sync`
    * Check that it fails and contains the proper
      error message
    """
    git_server.add_repo("foo")
    git_server.add_repo("bar")
    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url)
    git_server.push_file("foo", "conflict.txt", contents="this is red")

    foo_src = workspace_path / "foo"
    (foo_src / "conflict.txt").write_text("this is green")

    tsrc_cli.run_and_fail("sync")

    assert message_recorder.find("Failed to synchronize workspace")
    assert message_recorder.find(r"\* foo")
示例#25
0
文件: test_init.py 项目: xzr/tsrc
def test_repo_default_branch_not_master(tsrc_cli: CLI, git_server: GitServer,
                                        workspace_path: Path) -> None:
    git_server.add_repo("foo", default_branch="devel")

    tsrc_cli.run("init", git_server.manifest_url)

    foo_path = workspace_path / "foo"
    assert tsrc.git.get_current_branch(foo_path) == "devel"
示例#26
0
文件: test_init.py 项目: xzr/tsrc
def test_init_simple(tsrc_cli: CLI, git_server: GitServer,
                     workspace_path: Path) -> None:
    git_server.add_repo("foo/bar")
    git_server.add_repo("spam/eggs")
    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url)
    assert_cloned(workspace_path, "foo/bar")
    assert_cloned(workspace_path, "spam/eggs")
示例#27
0
文件: test_init.py 项目: xzr/tsrc
def test_no_remote_named_origin(tsrc_cli: CLI, git_server: GitServer,
                                workspace_path: Path) -> None:
    git_server.add_repo("foo")

    tsrc_cli.run("init", git_server.manifest_url)
    foo_path = workspace_path / "foo"
    tsrc.git.run(foo_path, "remote", "rename", "origin", "upstream")

    tsrc_cli.run("sync")
示例#28
0
def repo_path(monkeypatch: Any, git_server: GitServer, tsrc_cli: CLI,
              workspace_path: Path) -> Path:
    """ Path to a freshly cloned repository """
    git_server.add_repo("owner/project")
    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url)
    repo_path = workspace_path / "owner/project"
    monkeypatch.chdir(repo_path)
    return repo_path
示例#29
0
def test_sync_with_force(tsrc_cli: CLI, git_server: GitServer,
                         workspace_path: Path) -> None:
    git_server.add_repo("foo")
    git_server.push_file("foo", "latest.txt", contents="1")
    git_server.tag("foo", "latest")
    tsrc_cli.run("init", git_server.manifest_url)
    git_server.push_file("foo", "latest.txt", contents="2")
    git_server.tag("foo", "latest", force=True)
    tsrc_cli.run("sync", "--force")
示例#30
0
def test_clone_destination_is_a_file(tsrc_cli: CLI, git_server: GitServer,
                                     workspace_path: Path) -> None:
    manifest_url = git_server.manifest_url
    git_server.add_repo("foo")

    with (workspace_path / "foo").open("w") as f:
        f.write("this is a file")

    tsrc_cli.run_and_fail_with(ClonerError, "init", manifest_url)