Ejemplo n.º 1
0
Archivo: cli.py Proyecto: zeroae/ght
def render(url, refspec, dest_branch):
    """Render the template.

    \b
    REFSPEC: The template branch/refspec to use for rendering [default=master]
    GHT_BRANCH: The destination branch of the rendered results [default=ght/master]
    """
    if not dest_branch.startswith("ght/"):
        raise click.ClickException(
            "Refusing to render the template."
            f"The destination branch `{dest_branch}` does not begin ght/.")

    repo_path = resolve_repository_path(".")
    ght = GHT(repo_path=repo_path, template_url=url, template_ref=refspec)
    ght.load_config()

    if ght.template_url is None:
        raise click.ClickException(
            "Could not detect the template repository url. "
            "Please set it manually with -u/--url")

    with stashed_checkout(ght.repo, dest_branch):
        ght.render_tree()

    return 0
Ejemplo n.º 2
0
Archivo: cli.py Proyecto: zeroae/ght
def approve(commit):
    """Merge the rendered template from ght/master to master
    """

    repo_path = resolve_repository_path(".")
    ght = GHT(repo_path=repo_path)

    with stashed_checkout(ght.repo, "master"):
        click.echo(ght.repo.git.merge("--no-squash", "--no-ff", commit))
Ejemplo n.º 3
0
Archivo: cli.py Proyecto: zeroae/ght
def configure(repo_path):
    """Edit an existing template configuration file

    A git commit is created if the file is modified.
    """

    # Open the repo
    repo_path = resolve_repository_path(repo_path)
    ght = GHT(repo_path, None)

    with stashed_checkout(ght.repo, "ght/master"):
        click.edit(filename=f"{repo_path}/.github/ght.yaml")
        ght.repo.index.add(".github/ght.yaml")
        ght.repo.index.commit("[ght]: Update configuration file.",
                              skip_hooks=True)