예제 #1
0
파일: cli.py 프로젝트: zeroae/ght
def init(repository, refspec):
    """Initialize a git project from a ght-template repository.

    \b
    REPOSITORY: A git-url pointing to a ght-repository to use as a template.
    REFSPEC: The git refspec to use. [default: master]

    \b
    This command will:
      - Git-initialize the current working directory
      - Download the ght template configuration file
      - Create the ght/master tracking branch

    \b
    EXAMPLES:
        $ mkdir example
        $ cd example
        $ ght init https://github.com/sodre/ght-pypackage master
    """

    if len(os.listdir(".")) > 0:
        raise click.ClickException(
            "The current directory is not empty, refusing to initialize it.")

    # Setup the GHT Repository
    _ = GHT.init(path=".", template_url=repository, template_ref=refspec)

    return 0
예제 #2
0
파일: test_action.py 프로젝트: zeroae/ght
def ght(tmpdir, template: Repo):
    ght = GHT.init(
        path=os.path.join(tmpdir, "ght"),
        config=dict(
            ght=dict(
                template=dict(url=f"file://{template.working_tree_dir}", ref="master"),
                hello="Hello World!",
                a="alpha",
                b="beta",
                c="charlie",
                abc="{{ght.a}}/{{ght.b}}/{{ght.c}}",
                abcd="{{ght.abc}}/delta",
            )
        ),
    )
    assert not ght.repo.bare

    ght.fetch_template()
    ght.load_config()
    ght.prepare_tree_for_rendering()
    ght.repo.index.commit("[ght]: imported ght/template")

    return ght