コード例 #1
0
ファイル: test_sync.py プロジェクト: xzr/tsrc
def test_tags_are_skipped_when_not_clean_tags(
    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
    * Create an untracked file in the foo repo
    * Check that `tsrc sync` fails and that foo is not updated
    """
    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)
    (workspace_path / "foo/untracked.txt").write_text("")

    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_and_fail("sync")

    foo_path = workspace_path / "foo"
    assert not (
        foo_path / "new.txt"
    ).exists(), "foo should not have been updated (untracked files)"
コード例 #2
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"
コード例 #3
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"
コード例 #4
0
ファイル: test_log.py プロジェクト: FelipeCarlini/tsrc
def test_happy(tsrc_cli: CLI, git_server: GitServer,
               message_recorder: MessageRecorder) -> None:
    """
    Scenario:
    * Create a manifest with two repos, foo and bar
    * Initialize a workspace from this manifest
    * Create a tag named v0.1 on foo and bar
    * Run `tsrc log --from v0.1
    """
    git_server.add_repo("foo")
    git_server.add_repo("spam")
    git_server.push_file("foo", "bar.txt", message="boring bar")
    git_server.tag("foo", "v0.1")
    git_server.tag("spam", "v0.1")
    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url)
    git_server.push_file("foo", "foo.txt", message="new foo!")
    tsrc_cli.run("sync")
    message_recorder.reset()

    tsrc_cli.run("log", "--from", "v0.1")

    assert message_recorder.find("new foo!")

    message_recorder.reset()
    tsrc_cli.run("log", "--from", "v0.1", "--to", "v0.1")
    assert not message_recorder.find("new foo!")
コード例 #5
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")
コード例 #6
0
ファイル: test_sync.py プロジェクト: ninjapanzer/tsrc
def test_tags_are_not_updated(tsrc_cli: CLI, git_server: GitServer, workspace_path: Path) -> None:
    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")

    tsrc_cli.run("sync")

    foo_path = workspace_path / "foo"
    assert not (foo_path / "new.txt").exists()
コード例 #7
0
ファイル: test_init.py プロジェクト: ninjapanzer/tsrc
def test_resets_to_tag(tsrc_cli: CLI, git_server: GitServer,
                       workspace_path: Path) -> None:
    git_server.add_repo("foo")
    git_server.tag("foo", "v1.0")
    git_server.push_file("foo", "2.txt", message="Working on v2")
    git_server.manifest.set_repo_tag("foo", "v1.0")

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

    foo_path = workspace_path / "foo"
    _, expected_ref = tsrc.git.run_captured(foo_path, "rev-parse", "v1.0")
    _, actual_ref = tsrc.git.run_captured(foo_path, "rev-parse", "HEAD")
    assert expected_ref == actual_ref
コード例 #8
0
ファイル: test_sync.py プロジェクト: ninjapanzer/tsrc
def test_tags_are_skipped_when_not_clean_tags(tsrc_cli: CLI, git_server:
                                              GitServer, workspace_path: Path) -> None:
    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)
    (workspace_path / "foo/untracked.txt").write_text("")

    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", expect_fail=True)

    foo_path = workspace_path / "foo"
    assert not (foo_path / "new.txt").exists()
コード例 #9
0
ファイル: test_log.py プロジェクト: ninjapanzer/tsrc
def test_happy(tsrc_cli: CLI, git_server: GitServer,
               message_recorder: MessageRecorder) -> None:
    git_server.add_repo("foo")
    git_server.add_repo("spam")
    git_server.push_file("foo", "bar.txt", message="boring bar")
    git_server.tag("foo", "v0.1")
    git_server.tag("spam", "v0.1")
    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url)
    git_server.push_file("foo", "foo.txt", message="new foo!")
    tsrc_cli.run("sync")
    message_recorder.reset()

    tsrc_cli.run("log", "--from", "v0.1")

    assert message_recorder.find("new foo!")

    message_recorder.reset()
    tsrc_cli.run("log", "--from", "v0.1", "--to", "v0.1")
    assert not message_recorder.find("new foo!")
コード例 #10
0
ファイル: test_log.py プロジェクト: FelipeCarlini/tsrc
def test_missing_repos_from_given_group(
        tsrc_cli: CLI, git_server: GitServer,
        message_recorder: MessageRecorder) -> None:
    """
    Scenario:
    * Create a manifest with two disjoint groups, group1 and group2
    * For each repo, create  v0.1 tag
    * Initialize a workspace from this manifest using group1
    * Run `tsrc log --from v0.1 --groups group1 group2`
    * Check it fails
    """
    git_server.add_group("group1", ["foo"])
    git_server.add_group("group2", ["bar"])
    git_server.tag("foo", "v0.1")
    git_server.tag("bar", "v0.1")
    manifest_url = git_server.manifest_url
    tsrc_cli.run("init", manifest_url, "--group", "group1")

    message_recorder.reset()
    tsrc_cli.run_and_fail("log", "--from", "v0.1", "--groups", "group1",
                          "group2")
コード例 #11
0
ファイル: test_log.py プロジェクト: FelipeCarlini/tsrc
def test_use_given_group(tsrc_cli: CLI, git_server: GitServer) -> None:
    """
    Scenario:
    * Create a manifest containing:
      * a group named 'group1' containing the repo 'foo'
      * a group named 'group2' containing the repo 'bar'
    * Initialize a workspace from this manifest using the 'group1' and
    'group2' groups
    * Create a tag named v0.1 on foo
    * Run `tsrc --log --from v0.1 --group group1`
    """

    git_server.add_group("group1", ["foo"])
    git_server.add_group("group2", ["bar"])

    manifest_url = git_server.manifest_url
    git_server.tag("foo", "v0.1")
    git_server.push_file("foo", "foo.txt", message="new foo!")

    tsrc_cli.run("init", manifest_url, "--groups", "group1", "group2")
    tsrc_cli.run("log", "--from", "v0.1", "--group", "group1")
コード例 #12
0
ファイル: test_init.py プロジェクト: xzr/tsrc
def test_resets_to_tag(tsrc_cli: CLI, git_server: GitServer,
                       workspace_path: Path) -> None:
    """Scenario:
    * Create a repository containing a v1.0 tag
    * Add a commit on top of the v1.0 tag
    * Configure the manifest to specify that the repo
      should be reset at the v1.0 tag
    * Run `tsrc init`
    * Check the repo was cloned at the correct revision
    """
    git_server.add_repo("foo")
    git_server.tag("foo", "v1.0")
    git_server.push_file("foo", "2.txt", message="Working on v2")
    git_server.manifest.set_repo_tag("foo", "v1.0")

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

    foo_path = workspace_path / "foo"
    _, expected_ref = tsrc.git.run_captured(foo_path, "rev-parse", "v1.0")
    _, actual_ref = tsrc.git.run_captured(foo_path, "rev-parse", "HEAD")
    assert expected_ref == actual_ref
コード例 #13
0
def test_tags_are_not_updated(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
    * Run `tsrc sync`
    * Check that foo was not updated
    """
    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")

    tsrc_cli.run("sync")

    foo_path = workspace_path / "foo"
    assert not (foo_path / "new.txt").exists(
    ), "foo should not have been updated (frozen at v0.1 tag)"
コード例 #14
0
ファイル: test_test_helpers.py プロジェクト: ninjapanzer/tsrc
def test_git_server_tag(workspace_path: Path, git_server: GitServer) -> None:
    foo_url = git_server.add_repo("foo")
    git_server.tag("foo", "v0.1")
    _, out = tsrc.git.run_captured(workspace_path, "ls-remote", foo_url)
    assert "refs/tags/v0.1" in out
コード例 #15
0
ファイル: test_git_server.py プロジェクト: dmerejkowsky/tsrc
def test_tag(workspace_path: Path, git_server: GitServer) -> None:
    foo_url = git_server.add_repo("foo")
    git_server.tag("foo", "v0.1", branch="master")
    _, out = run_git_captured(workspace_path, "ls-remote", foo_url)
    assert "refs/tags/v0.1" in out