Commit graph

302 commits

Author SHA1 Message Date
Kynan Ware
3af535902d Add usage examples to gh gist edit command
Add a cobra Example string to the gist edit command showing common
operations: interactive selection, editing in default editor, editing a
specific file, replacing file content, adding/removing files, and
changing the description.

Closes #8943

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-17 12:38:15 -07:00
Babak K. Shandiz
d002d30327
fix: resolve nilerr issues
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-11-03 20:05:26 +00:00
Babak K. Shandiz
d129b94fc5
refactor: remove returned resp from api.EndpointNeedsScopes
The returned response from `api.EndpointNeedsScopes` causes `bodyclose`
linter to raise a false positive error, assuming it's a new response that
its body needs to be closed.

Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-11-03 20:05:24 +00:00
Lucas
7db532aca0
test(gist/edit): add tests for single file edit and interactive multi-file selection
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
2025-10-30 18:50:49 +01:00
Lucas
6c497e74df
test(gist): fix failing tests 2025-10-30 06:12:15 +01:00
Lucas
42238dc365
fix(gist): prevent fetching full content for already edited files 2025-10-30 05:55:53 +01:00
Lucas
c98c435800
fix(gist): only include files that have changed in request
There was some issues when sending the full list of files, some of them would be truncated.
2025-10-30 05:49:52 +01:00
Lucas
f8651f5e44
fix(gist): fetch full content for truncated files during editing
This change makes it only fetch the raw content, when we wanna edit the specific file.
2025-10-30 05:48:34 +01:00
Lucas Nørgård
cf7180379a
Merge branch 'trunk' into gist-edit-large-file 2025-10-30 04:18:26 +01:00
juejinyuxitu
f5cf156af1 refactor: use strings.FieldsFuncSeq to reduce memory allocations
Signed-off-by: juejinyuxitu <juejinyuxitu@outlook.com>
2025-09-24 23:11:17 +08:00
Lucas
26f1d48fa4
test(gist): add tests for handling truncated files in view command
* Added test cases for viewing truncated files with and without the raw flag.
* Included scenarios for multiple files with truncation behavior.
* Ensured correct output is returned for truncated files when accessed via raw URLs.
2025-09-20 06:55:38 +02:00
Lucas
b9b2654219
test(gist): add tests for editing truncated gist files
* Implement tests for editing gists that contain truncated files.
* Ensure that both single and multiple truncated files are handled correctly.
* Mock responses for retrieving full content from raw URLs for truncated files.
2025-09-20 06:55:10 +02:00
Lucas
e3afc4dae4
test(gist): add tests for GetRawGistFile function
- Implemented unit tests for various scenarios in `GetRawGistFile`.
- Covered cases including successful requests, error handling, and different content types.
- Ensured proper verification of HTTP responses and error messages.
2025-09-19 05:01:16 +02:00
Lucas
bf272305ff
feat(gist): retrieve full content for truncated gist files
* Added logic to fetch full content for truncated files when updating a gist.
* Utilizes `shared.GetRawGistFile` to retrieve the complete content based on the `RawURL`.
2025-09-18 06:35:35 +02:00
Lucas
704bb4164c
feat(gist): retrieve full content for truncated gist files
* Added logic to fetch the full content of a gist file if it is marked as truncated.
* Utilizes the `GetRawGistFile` function to obtain the complete content from the provided `RawURL`.
2025-09-18 06:35:31 +02:00
Lucas
62ea060590
feat(gist): add GetRawGistFile function to retrieve raw gist content
* Implements a new function to fetch the raw content of a gist using its `rawURL`.
* Handles HTTP requests and responses, including error management for non-200 status codes.
2025-09-18 06:35:16 +02:00
Lucas
b1fdb363ff
feat(gist): add RawURL and Truncated fields to GistFile
* Added `RawURL` to store the raw URL of the gist file.
* Added `Truncated` to indicate if the content is truncated.
2025-09-18 05:28:48 +02:00
phanium
19e1178a32
fix: gh gist edit panic when no file in a gist (#10627)
* fix: `gh gist edit` panic when no file in a gist

* fix: improve error message

Signed-off-by: Babak K. Shandiz <babakks@github.com>

---------

Signed-off-by: Babak K. Shandiz <babakks@github.com>
Co-authored-by: Babak K. Shandiz <babakks@github.com>
2025-05-28 14:40:14 +01:00
Babak K. Shandiz
284880c21e
Fix StatusJSONResponse usage (#10810)
* Fix `StatusJSONResponse` usage

Signed-off-by: Babak K. Shandiz <babakks@github.com>

* Replace `assert` with `require`

Signed-off-by: Babak K. Shandiz <babakks@github.com>

* Improve assertion against errors

Signed-off-by: Babak K. Shandiz <babakks@github.com>

* Add `JSONErrorResponse` helper func

Signed-off-by: Babak K. Shandiz <babakks@github.com>

* Use `httpmock.JSONErrorResponse`

Signed-off-by: Babak K. Shandiz <babakks@github.com>

* Replace `StatusJSONResponse` to `JSONErrorResponse` for better readibility

Signed-off-by: Babak K. Shandiz <babakks@github.com>

* Fix improper use of `StatsJSONResponse`

Signed-off-by: Babak K. Shandiz <babakks@github.com>

---------

Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-05-01 20:22:43 +01:00
Andy Feller
47225bcf56
Merge pull request #10737 from cli/andyfeller/muted-text-part2-github-cli-833
Ensure muted text is thematic and customizable
2025-04-08 16:59:36 -04:00
Andy Feller
918cafc222 Deprecate ColorScheme.Gray for ColorScheme.Muted
This commit converts all of the places using ColorScheme.Gray and ColorScheme.Grayf to Muted and Mutedf.

There is a little extra tidying up with local variable names or converting code to use Mutedf format.
2025-04-06 10:18:48 -04:00
Andy Feller
e067eacd81 Refactor ColorScheme initializer
This commit completely removes the iostreams.NewColorScheme() initializer function in favor of exporting the type fields for greater clarity in its use.

The result being code specifying only the fields that matter to test cases.
2025-04-04 11:57:37 -04:00
Andy Feller
e9a12853cb Merge branch 'trunk' into andyfeler/colorize-label-optin 2025-04-04 09:47:41 -04:00
Andy Feller
3eca268a7f Introduce color_labels support, update commands
This commit implements the actual changes around configuration setting / environment variable logic for displaying labels using their RGB hex color code in terminals with truecolor support.

One of the subtler changes in this commit is renaming generic ColorScheme.HexToRGB logic to render truecolor to ColorScheme.Label as this feature was being used exclusively for labels.  This is due to confusion about introducing the new `color_labels` config on top of generic coloring logic.
2025-04-02 18:24:20 -04:00
Andy Feller
3c38cedaf3 Implement tests for muted logic, standardize reset
This commit covers testing around the new ColorScheme.Muted logic based on various situations to gain confidence we get the accessible colors expected when enabled.

Additionally, this commit includes a small change to the existing 8-bit color logic to standardize on the same reset sequence for testing purposes.  Essentially, `ESC[m` and `ESC[0m` are equivalent but this inconsistency with our other libraries makes setting up tests a little extra confusing and difficult.
2025-03-31 15:33:52 -04:00
Andy Feller
d2cd14b4cd Remove out of scope changes, update list commands
After discussing this with the team, the `gh config` changes to display `accessible_colors` have been removed from this branch being outside of acceptance criteria.  This will be moved to a separate issue along with any other work needed to finalize the public preview such as `gh help` entries for `GH_ACCESSIBLE_COLORS` environment variable.

List commands that use ColorScheme.Gray have been updated to use ColorScheme.Muted.
2025-03-31 11:58:30 -04:00
Kynan Ware
e30244686c
Merge pull request #10680 from cli/kw/update-go-gh-and-document-sprig-funcs
Update go-gh and document available sprig funcs
2025-03-28 12:22:14 -06:00
Kynan Ware
c1fbc2f05b test(many): fix whitespace in tests expectations
Due to https://github.com/charmbracelet/glamour/pull/334, the margin
used for markdown rendering has changed by a couple spaces. This
corrects the relevant tests to accomodate that change.
2025-03-27 14:21:13 -06:00
Andy Feller
79f1b07fb1 Implement and fix tests for table headers 2025-03-25 15:29:05 -04:00
Andy Feller
6355e54e3c Ensure table headers are thematically contrasting
This commit refactors the color format around table headers to ensure the GitHub CLI uses thematically appropriate colors based on dark background, light background, or no color at all.

In order to do so, `ColorScheme` needs information from the terminal about the background appearance (dark, light, none) to determine appropriate muted color.
2025-03-21 11:51:03 -04:00
Tyler McGoffin
0bb92c5980
Separate partitioning from globbing in cmdutil/args package and consumers (#3)
* Separate partitioning from globbing in cmdutil/args package and consumers

In the previous commit, GlobPaths was overloaded, containing logic
specific to command use-cases. This commit removes that functionality from
GlobPaths and back into the commands that have the special use-cases.

To do this, I've introduced a new Partition util in cmdutil/args.go that
will separate a slice into two slices given a predicate. This functionality
is leveraged by both the special use-cases described above to separate the
command-specific syntax from the globable filepaths.

* Add test to validate that the order of '-' in gh gist create args doesn't matter
2025-03-04 07:05:23 +05:00
Azeem Sajid
db3df04068
Merge branch 'trunk' into 5099-gh-release-create-upload-expand-glob-patterns-on-windows 2025-02-27 19:20:44 +05:00
Andy Feller
f9d50d86ac
Merge pull request #10508 from iamazeem/10449-inconsistent-examples-format
Inconsistent format of examples in help text
2025-02-27 09:15:14 -05:00
Azeem Sajid
33c30d5bd1 Inconsistent format of examples in help text 2025-02-27 16:26:25 +05:00
Azeem Sajid
69fff52026
Inconsistent format of description of flags (starting with lowercase letter) (#10507) 2025-02-27 11:40:21 +01:00
Azeem Sajid
f4b65b785e Add exclude callback function 2025-02-26 12:46:56 +05:00
Azeem Sajid
8ace163608 Remove slicing 2025-02-25 10:49:28 +05:00
Azeem Sajid
092eb7e962 Support globbing for all platforms 2025-02-22 12:16:42 +05:00
Tyler McGoffin
8748bb0b1a
Add testing to GlobWindowsPaths (#2) 2025-02-21 22:33:19 +05:00
Azeem Sajid
0fb87903e5 Update usage to lower-kebab-case 2025-02-14 22:12:22 +05:00
Azeem Sajid
8b7fb231ec Remove trailing whitespace 2025-02-13 11:06:27 +05:00
Azeem Sajid
d9bfa606cc Fix gh gist create for multiple filenames and glob patterns 2025-02-11 12:56:32 +05:00
Otto Kekäläinen
b19e682455
Update test to be compatible with latest Glamour v0.8.0
Latest Glamour has slightly changed logic in line length / wrapping,
resulting test failures due to string mismatch. Update tests and bump
dependency to v0.8.0, and others to the bare minimal level as generated
by `go mod tidy`.

This was detected then building the GitHub cli package `gh` in Debian
started to fail with src:golang-github-charmbracelet-glamour 0.8.0-1.

Closes: #10179
2025-01-22 20:13:40 -08:00
Kynan Ware
facd0caa29 Fix: accidental whitespace in gist edit 2025-01-16 11:44:46 -07:00
Kynan Ware
5b6fd53a88 Fix: gist edit test name 2025-01-16 11:36:48 -07:00
Kynan Ware
dec46670bb Fix: gist edit/view tests var name consistency 2025-01-16 11:14:33 -07:00
Kynan Ware
a2dce589d6 Merge 'trunk' into fix/issue_10042 2025-01-16 11:06:36 -07:00
Kynan Ware
35d81e3ff5 Fix: Gist edit tests for interactivity
This changes the gist edit tests to use the positive `istty` instead of the previous inverse `nontty`, which is consistent with the way other commands are written.
2025-01-16 10:46:07 -07:00
Tyler McGoffin
3feeb9a826 Add tests for deleteGist 2025-01-14 14:21:49 -08:00
Mateus Marquezini
c0f6eb0598 #10042: Attempt to add a new test scenario for handling error messages when TTY is unavailable 2025-01-13 11:39:48 -03:00