Exemplo n.º 1
0
    def _(event: events.GitFailed) -> None:
        def _lines() -> Iterator[str]:
            yield (f"The command [command]git {event.command}[/] failed"
                   f" with status [status]{event.status}[/].")

            command = escape(shlex.join(["git", event.command,
                                         *event.options]))

            yield ""
            yield f"❯ {command}"

            for stream in ["stdout", "stderr"]:
                output = getattr(event, stream)
                if output:
                    yield ""
                    for line in output.splitlines():
                        line = escape(line)
                        yield f"[{stream}]{line}[/]"

            yield ""

        console.failure("\n".join(_lines()))

        if event.command == "cherry-pick":
            console.hint("Looks like the changes did not apply cleanly.")
            console.hint(
                "Try running [command]retrocookie[/] on a local clone instead."
            )
Exemplo n.º 2
0
    def _(event: events.ConnectionError) -> None:
        def _lines() -> Iterator[str]:
            yield "Connection to GitHub API could not be established."
            yield f"[http.method]{event.method}[/] [repr.url]{event.url}[/]"

        console.failure("\n".join(_lines()))
        console.highlight(event.error)
Exemplo n.º 3
0
    def _(event: events.GitHubError) -> None:
        def _lines() -> Iterator[str]:
            yield "The GitHub API returned an error response."
            yield f"[http.method]{event.method}[/] [repr.url]{event.url}[/]"
            yield f"[http.status]{event.code}[/] {event.message}"
            yield from event.errors

        console.failure("\n".join(_lines()))
Exemplo n.º 4
0
 def _(event: events.TemplateNotFound) -> None:
     console.failure(
         f"Project template for [repository]{event.project.full_name}[/] not found"
     )
     console.hint("Does the project contain a .cookiecutter.json file?")
     console.hint(
         'Does the .cookiecutter.json contain the repository URL under "_template"?'
     )
     console.hint("Is the template repository on GitHub?")
Exemplo n.º 5
0
 def _(event: events.BadGitVersion) -> None:
     console.failure(
         f"This program requires git [version]{event.expected}[/].")
     console.hint(
         f"You have git [version]{event.version}[/], which is too old.")
Exemplo n.º 6
0
 def _(event: events.GitNotFound) -> None:
     console.failure("git not found")
     console.hint("Do you have git installed?")
     console.hint("Is git on your PATH?")
     console.hint("Can you run [command]git version[/]?")
Exemplo n.º 7
0
 def _(event: events.PullRequestAlreadyExists) -> None:
     console.failure("Already imported"
                     f" [pull]#{event.project_pull.number}[/]"
                     f" [title]{escape(event.project_pull.title)}[/]")
     console.hint(f"See [pull]#{event.template_pull.number}[/]")
     console.hint("Use --force to update an existing pull request.")
Exemplo n.º 8
0
 def _(event: events.PullRequestNotFound) -> None:
     spec = event.pull_request
     if spec.isnumeric():
         spec = f"#{spec}"
     console.failure(f"Pull request [pull]{spec}[/] not found")
Exemplo n.º 9
0
 def _(event: events.RepositoryNotFound) -> None:
     console.failure(
         f"Repository [repository]{event.repository}[/] not found")
Exemplo n.º 10
0
 def _(event: events.ProjectNotFound) -> None:
     console.failure("Project not found")
     console.hint("Does the current directory contain a repository?")
     console.hint("Is the repository on GitHub?")