Any errors from fetching and rendering the README were silenced and
ignored in `repo view`. This change:
- Tolerates HTTP 404, but will raise exceptions for any other error;
- Moves markdown rendering from `api` package to command implementation;
- Ensures markdown rendering errors are correctly reported.
This commit improves behavior and error handling for pr commands when
run unattached to a tty.
- error if pr create and no -t/-f
- error if pr create and -w
- machine readable pr list
- machine readable pr view
- various cleanup of informational messages
Goals:
- print command usage information on `gh gist create` when no args nor stdin
- disallow passing `-` as argument multiple times
- utilize Cobra's Args to do argument validation
First, consolidate the functionality between `pr merge` and `pr
checkout` that resolves the default branch name of the base repo. With
an added bonus, the new approach avoids an API request when one isn't
necessary.
Then, ensure that checking out 3rd-party PRs will result in local branch
name such as `<owner>/<branch>` when the head branch of the repository
matches the default branch of the base repository. We already have had
code in place to take care of this, but it only took effect in the `pr
checkout <number>`-style invocation.
This commit is part of work to make gh more scriptable. It includes both
some general purpose helpers towards this goal as well as improvements
to the issue commands. Other commands will follow.
- Adds `utils/terminal.go` for finding out about gh's execution environment
- introduces `stubTerminal` for either faking being attached to a tty or not during tests
- updates issue commands to behave better when not attached to a tty:
- issue list doesn't print fuzzy dates
- issue list doesn't print header
- issue list prints state explicitly
- issue create no longer hangs
- issue create fails with clear error unless both -t and -b are specified
- issue view prints raw issue body
- issue view prints metadata in a consistent, linewise format