コード例 #1
0
ファイル: test_core.py プロジェクト: pombredanne/battenberg
def test_install_raises_template_conflict(repo: Repository,
                                          template_repo: Repository):
    # Create an existing template branch to force the error.
    repo.create_branch('template', repo[repo.head.target])

    battenberg = Battenberg(repo)

    with pytest.raises(TemplateConflictException):
        battenberg.install(template_repo.workdir)
コード例 #2
0
def install(ctx, template: str, initial_branch: Optional[str], **kwargs):
    """Create a new copy from the TEMPLATE repository.

    TEMPLATE is expected to be the URL of a git repository.
    """

    battenberg = Battenberg(
        open_or_init_repository(ctx.obj['target'], template, initial_branch))
    battenberg.install(template, **kwargs)
コード例 #3
0
def test_install_raises_failed_hook(cookiecutter: Mock, repo: Repository,
                                    template_repo: Repository):
    cookiecutter.side_effect = FailedHookException

    battenberg = Battenberg(repo)

    with pytest.raises(SystemExit) as e:
        battenberg.install(template_repo.workdir)

    assert e.value.code == 1
コード例 #4
0
ファイル: test_core.py プロジェクト: pombredanne/battenberg
def test_install(repo: Repository, template_repo: Repository):
    battenberg = Battenberg(repo)
    battenberg.install(template_repo.workdir, no_input=True)

    assert battenberg.is_installed()
    # Ensure we have the appropriate branches we expect.
    assert not {'master', 'template'} - set(repo.listall_branches())

    # Ensure we have a valid structure for the template branch.
    template_oids = {
        ref.oid_new
        for ref in repo.references['refs/heads/template'].log()
    }
    template_commits = [repo[oid].message for oid in template_oids]
    assert template_commits == ['Prepared template installation']

    # Ensure we have valid merge commit from the template branch -> master.
    template_install_message = f'commit (merge): Installed template \'{template_repo.workdir}\''
    master_merge_ref = find_ref_from_message(repo, template_install_message)
    assert master_merge_ref
    # Ensure the merge commit was derived from the template branch.
    assert not template_oids - set(repo[master_merge_ref.oid_new].parent_ids)
コード例 #5
0
ファイル: cli.py プロジェクト: kevinj-z/battenberg
def install(ctx, template: str, **kwargs):
    battenberg = Battenberg(open_or_init_repository(ctx.obj['target']))
    battenberg.install(template, **kwargs)
コード例 #6
0
ファイル: conftest.py プロジェクト: zillow/battenberg
def installed_repo(repo: Repository, template_repo: Repository) -> Repository:
    battenberg = Battenberg(repo)
    battenberg.install(template_repo.workdir, no_input=True)
    return repo