How to use wily - 10 common examples

To help you get started, we’ve selected a few wily examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tonybaloney / wily / test / integration / test_archiver.py View on Github external
author = Actor("An author", "author@example.com")
    committer = Actor("A committer", "committer@example.com")

    # First commit
    with open(tmppath / ".gitignore", "w") as ignore:
        ignore.write(".wily/")
    index.add([".gitignore"])
    commit1 = index.commit("commit1", author=author, committer=committer)

    # Second commit
    with open(tmppath / "test.py", "w") as file1:
        file1.write("print(1)")
    index.add(["test.py"])
    commit2 = index.commit("commit2", author=author, committer=committer)

    config = DEFAULT_CONFIG
    config.path = tmpdir

    archiver = GitArchiver(config)
    assert archiver.config == config

    revisions = archiver.revisions(tmpdir, 3)
    assert len(revisions) == 2
    assert revisions[0].message == "commit2"
    assert revisions[0].author_email == "author@example.com"
    assert revisions[0].author_name == "An author"
    assert (
        revisions[0].key in commit2.name_rev
        and revisions[0].key not in commit1.name_rev
    )

    assert revisions[1].message == "commit1"
github tonybaloney / wily / test / integration / test_archiver.py View on Github external
repo = Repo.init(path=tmpdir)
    tmppath = pathlib.Path(tmpdir)

    # Write a test file to the repo
    with open(tmppath / ".gitignore", "w") as ignore:
        ignore.write("*.py[co]\n")

    index = repo.index
    index.add([".gitignore"])

    author = Actor("An author", "author@example.com")
    committer = Actor("A committer", "committer@example.com")

    index.commit("ignore python cache", author=author, committer=committer)

    config = DEFAULT_CONFIG
    config.path = tmpdir

    with pytest.raises(WilyIgnoreGitRepositoryError):
        archiver = GitArchiver(config)
github tonybaloney / wily / test / integration / test_archiver.py View on Github external
with open(tmppath / ".gitignore", "w") as ignore:
        ignore.write("*.py[co]\n")

    index = repo.index
    index.add([".gitignore"])

    author = Actor("An author", "author@example.com")
    committer = Actor("A committer", "committer@example.com")

    index.commit("ignore python cache", author=author, committer=committer)

    config = DEFAULT_CONFIG
    config.path = tmpdir

    with pytest.raises(WilyIgnoreGitRepositoryError):
        archiver = GitArchiver(config)
github tonybaloney / wily / test / integration / test_archiver.py View on Github external
with open(tmppath / ".gitignore", "w") as ignore:
        ignore.write(".wily/")

    index.add([".gitignore"])
    commit1 = index.commit("commit1", author=author, committer=committer)

    # Write a test file to the repo
    with open(tmppath / "blah.py", "w") as ignore:
        ignore.write("*.py[co]\n")
    index.add(["blah.py"])

    config = DEFAULT_CONFIG
    config.path = tmpdir

    with pytest.raises(DirtyGitRepositoryError):
        archiver = GitArchiver(config)
        archiver.revisions(tmpdir, 2)
github tonybaloney / wily / test / integration / test_archiver.py View on Github external
# First commit
    with open(tmppath / ".gitignore", "w") as ignore:
        ignore.write(".wily/")
    index.add([".gitignore"])
    commit1 = index.commit("commit1", author=author, committer=committer)

    # Second commit
    with open(tmppath / "test.py", "w") as file1:
        file1.write("print(1)")
    index.add(["test.py"])
    commit2 = index.commit("commit2", author=author, committer=committer)

    config = DEFAULT_CONFIG
    config.path = tmpdir

    archiver = GitArchiver(config)
    assert archiver.config == config

    revisions = archiver.revisions(tmpdir, 3)
    assert len(revisions) == 2
    assert revisions[0].message == "commit2"
    assert revisions[0].author_email == "author@example.com"
    assert revisions[0].author_name == "An author"
    assert (
        revisions[0].key in commit2.name_rev
        and revisions[0].key not in commit1.name_rev
    )

    assert revisions[1].message == "commit1"
    assert revisions[1].author_email == "author@example.com"
    assert revisions[1].author_name == "An author"
    assert (
github tonybaloney / wily / test / integration / test_archiver.py View on Github external
# Write a test file to the repo
    with open(tmppath / ".gitignore", "w") as ignore_f:
        ignore_f.write(ignore)

    index = repo.index
    index.add([".gitignore"])

    author = Actor("An author", "author@example.com")
    committer = Actor("A committer", "committer@example.com")

    index.commit("ignore python cache", author=author, committer=committer)

    config = DEFAULT_CONFIG
    config.path = tmpdir

    archiver = GitArchiver(config)
    assert archiver.config == config
github tonybaloney / wily / test / unit / test_archivers.py View on Github external
def test_git_init(repo):
    with patch("wily.archivers.git.Repo", return_value=repo):
        test_config = wily.config.DEFAULT_CONFIG
        test_config.path = repo.path
        archiver = git.GitArchiver(test_config)
        assert archiver.repo is not None
        assert archiver.config == test_config
github tonybaloney / wily / test / integration / test_build.py View on Github external
def test_build_not_git_repo(tmpdir):
    """
    Test that build defaults to filesystem in a non-git directory
    """
    with patch("wily.logger") as logger:
        runner = CliRunner()
        result = runner.invoke(main.cli, ["--path", tmpdir, "build", "test.py"])
        assert result.exit_code == 0, result.stdout
        cache_path = tmpdir / ".wily"
        assert cache_path.exists()
        index_path = tmpdir / ".wily" / "filesystem" / "index.json"
        assert index_path.exists()
github tonybaloney / wily / test / integration / test_diff.py View on Github external
def test_diff_output(builddir):
    """ Test the diff feature with no changes """
    runner = CliRunner()
    result = runner.invoke(
        main.cli, ["--debug", "--path", builddir, "diff", _path], catch_exceptions=False
    )
    assert result.exit_code == 0, result.stdout
    assert "test.py" not in result.stdout
github tonybaloney / wily / test / integration / test_all_operators.py View on Github external
def test_operator(operator, gitdir):
    runner = CliRunner()
    result = runner.invoke(
        main.cli, ["--debug", "--path", gitdir, "build", "src", "-o", operator]
        , catch_exceptions=False
    )
    assert result.exit_code == 0, result.stdout

    result = runner.invoke(main.cli, ["--debug", "--path", gitdir, "report", _path], catch_exceptions=False)
    assert result.exit_code == 0, result.stdout

    result = runner.invoke(
        main.cli, ["--debug", "--path", gitdir, "diff", _path, "--all"]
        , catch_exceptions=False
    )
    assert result.exit_code == 0, result.stdout
    assert "test.py" in result.stdout

    complex_test = """
            import abc
            foo = 1
            def function1():
                a = 1 + 1
                if a == 2:
                    print(1)