Commit graph

25 commits

Author SHA1 Message Date
Kynan Ware
48951aca01 Fix invalid ANSI SGR escape code in JSON and diff colorization
Replace `1;38` with `1;37` (bold white) in the delimiter/header
color constant. SGR parameter 38 is the extended foreground color
prefix and requires sub-parameters (e.g. `38;5;n` or `38;2;r;g;b`),
so using it bare produces an invalid escape sequence. Most terminals
silently ignore the malformed parameter, masking the bug.

Fixes cli/cli#12683

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 17:52:01 -07:00
William Martin
a66a646ca5 Add comment to pr diff regex 2024-05-23 11:59:56 +02:00
Katsuhiko Anda
e5e5c4fc43 Update regex in changedFilesNames to handle quoted paths 2024-05-23 03:13:16 +00:00
Yukai Chou
17d336e005 Wrap cli flags in backticks uniformly 2023-11-16 22:54:27 +08:00
Mislav Marohnić
32afc5d67f
pr diff: sanitize control characters for terminal output 2023-03-08 16:59:35 +01:00
ffalor
e7270e401d
add --web flag to pr diff command (#6439) 2022-10-18 09:02:53 +00:00
Bindu
7036d055b5 Add name-only flag to gh pr diff sub command 2022-08-14 06:47:37 -07:00
Mislav Marohnić
19563c4a74 Use StringEnumFlag helper in more places 2022-02-18 12:52:47 +01:00
Mislav Marohnić
0a5e220231 Ignore EPIPE errors when writing to a closed pager
While a gh command is writing stdout to a pager, the user may choose to
close the pager program before the pager has read all the data on its
standard input. In that case, the parent gh process will receive an
EPIPE error, which would bubble up its error handling and cause it to
print something like:

    write |1: broken pipe

Since this was caused by an explicit user action of closing the pager,
and since the user probably doesn't want to see this uninformative
error, this informs our global error handling of this error and causes
it to be ignored.
2022-02-10 16:42:00 +01:00
Mislav Marohnić
4a3ef50d2d
Standardize pager output across commands (#5141)
Add pager functionality to the following commands:
- gist list
- pr checks
- release list
- run list
- run view
- secret list
- workflow list
- workflow view

Additionally, normalize error handling when starting the pager has
failed: only print a non-fatal notice to stderr instead of aborting the
whole command.
2022-02-01 08:36:51 +01:00
Mislav Marohnić
c33eb3bee1 pr diff: support very long lines 2021-12-01 17:03:11 +01:00
Mislav Marohnić
4a6aa0e938 pr diff: respect global NO_COLOR/CLICOLOR_FORCE settings
In the absence of an explicit `--color` setting, or when `--color=auto`
is passed, the pr diff command should fall back to respecting the global
colorization setting as inferred from the environment.
2021-12-01 17:03:11 +01:00
Alan Donovan
f4491c7a80 Add FlagErrorf; encapsulate FlagError.error 2021-10-21 11:40:20 -04:00
Mislav Marohnić
e4c8aa3b2b Add tests for pr diff --patch 2021-10-08 13:53:19 +02:00
Adarsh K Kumar
e0897fd8e8 #2720 | Add patch flag to pull-request diff command 2021-10-07 23:09:21 +05:30
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Mislav Marohnić
9bdc63c4ca Eliminate API overfetching in pr commands
This completely rewrites the PR lookup mechanism so that the caller
must specify the GraphQL fields to query for each PR. Additionally, this
fixes some export problems with `pr view --json`.

Features:

- Each pr command now gets assigned a concept of a Finder. This makes it
  easier to stub the PR in tests without having to stub the underlying
  HTTP calls or git invocations.

- `pr view --web` is much faster since it only fetches the "url" field.

- `pr diff 123` now skips a whole API call where a whole PR was
  unnecessarily preloaded just to access its diff in a subsequent call.

- PullRequestGraphQL query builder is now used to construct queries.

- A bunch of individual commands are now freed of having to know about
  concepts such as BaseRepo, Branch, Config, or Remotes.
2021-04-30 20:34:36 +02:00
Cristian Dominguez
8a0d5b0e43 Add note about current branch detection 2021-04-13 12:30:07 -03:00
Mislav Marohnić
6ad6784c46 Ignore EPIPE when forwarding pr diff output to pager 2020-09-14 15:30:10 +02:00
Mislav Marohnić
d01355e24b Add global PAGER support
Extract the ad-hoc PAGER behavior from `pr diff` command and make it
available opt-in to any command through IOStreams.
2020-09-04 23:07:17 +02:00
Mislav Marohnić
c21caf5b2b Disallow pr -R flag for commands that operate on the current branch
If the `--repo` flag is specified, then the user intends to select a
repository other than the current one. In that case, it doesn't make
sense to fall back to detecting the PR belonging to the current branch,
so throw a descriptive error instead.
2020-08-27 16:30:34 +02:00
Martín Montes
df66a8f131 Using default pager in gh pr diff 2020-08-17 22:31:30 +02:00
Mislav Marohnić
6490d7717c Fix --repo override taking effect for pr commands 2020-08-06 21:39:46 +02:00
Mislav Marohnić
7949d5373d Fix pr diff in notty mode 2020-07-29 22:58:08 +02:00
Mislav Marohnić
af68a749f0 Isolate pr diff command 2020-07-29 22:49:50 +02:00