示例#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."
            )
示例#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)
示例#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()))
示例#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?")
示例#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.")
示例#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[/]?")
示例#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.")
示例#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")
示例#9
0
 def _(event: events.RepositoryNotFound) -> None:
     console.failure(
         f"Repository [repository]{event.repository}[/] not found")
示例#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?")