Commit graph

114 commits

Author SHA1 Message Date
Max Beizer
45c68b48da
Add discussion command group scaffolding
Introduce the pkg/cmd/discussion/ package with:

- DiscussionClient interface and domain types (client/)
- Generated mock via moq (client/)
- Factory function for lazy client creation (shared/)
- JSON field definitions for --json output (shared/)
- Root 'discussion' command registered in the core group

The interface defines all planned operations (list, search, get, create,
update, close, reopen, comment, lock, unlock, mark-answer, unmark-answer)
with stub implementations that will be replaced as each subcommand is
added in subsequent PRs.

Domain types are intentionally separate from API types per review guidance.
No JSON struct tags are used; serialization is handled by ExportData methods.

Refs: cli/cli#12810, github/gh-cli-and-desktop#115

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-02 10:55:48 -05:00
William Martin
7ea88b1c4d
Bundle licenses at release time (#12625)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-02-18 17:59:27 +01:00
Babak K. Shandiz
10b4a1f427
fix(root): avoid command name collision when registering extensions
Signed-off-by: Babak K. Shandiz <babakks@github.com>

Co-authored-by: Kynan Ware <bagtoad@github.com>
Co-authored-by: Devraj Mehta <devm33@github.com>
2026-01-19 10:38:39 +00:00
Babak K. Shandiz
08a4413614
chore(root): register copilot command
Signed-off-by: Babak K. Shandiz <babakks@github.com>

Co-authored-by: Kynan Ware <bagtoad@github.com>
Co-authored-by: Devraj Mehta <devm33@github.com>
2026-01-19 10:38:35 +00:00
Kynan Ware
8840df2eb3 Fix agentTaskCmd to use repoResolvingCmdFactory
`agent-task` uses smart base repo func to fix bug with resolving upstream instead of local repo.
2025-10-10 10:39:52 -06:00
Kynan Ware
3573f61b86 Add agent-task command with OAuth token validation
Introduces a new `agent-task` command under pkg/cmd/agent with strict OAuth (device flow) token validation. Includes comprehensive tests for token source and host validation, and registers the command in the root command set.
2025-08-27 12:23:01 -06:00
Kynan Ware
4bc056fe20
Merge branch 'trunk' into kw/preview-prompter-command 2025-05-10 11:30:15 -06:00
Andy Feller
274a09bbc9 Initial gh accessibility command draft
This commit captures the initial command along with functionality and description.

There is an internal discussion about the appropriate place for some of this content.
2025-04-23 10:11:51 -04:00
Kynan Ware
abd573ac66 feat(preview): add preview prompter command 2025-04-08 15:14:28 -06:00
Andy Feller
7b91b17395 Refactor extension command testing
This commit allows for stubbing/mocking the function used for checking update release info.  Additionally, this does a minor refactor moving from non-blocking to blocking channel.
2024-11-17 21:59:06 -05:00
Meredith Lancaster
90b7bf97c5
gh-attestation cmd integration (#8698)
* add attestation cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add codeowners

Signed-off-by: Meredith Lancaster <malancas@github.com>

* update args passed to the attestation cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* rename file

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use gh-attestation branch for passing iostreams from the root

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add package security team entry to codeowners

Signed-off-by: Meredith Lancaster <malancas@github.com>

* start moving over verify cmd and general verification code

Signed-off-by: Meredith Lancaster <malancas@github.com>

* clean up common and verify specific policy code

Signed-off-by: Meredith Lancaster <malancas@github.com>

* move artifact package over

Signed-off-by: Meredith Lancaster <malancas@github.com>

* start pulling in the github api client wrapper

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix imports

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add logger and test packages

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add additional packages to support verify command

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix mock api client

Signed-off-by: Meredith Lancaster <malancas@github.com>

* clean up mock api client

Signed-off-by: Meredith Lancaster <malancas@github.com>

* include missing fields

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use correct owner

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add more mock api client options

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add download cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add inspect cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* pass factory object to inspect cmd, add inspect sub cmd to attestation cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add verify-tuf-root cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* pass iostream struct from command

Signed-off-by: Meredith Lancaster <malancas@github.com>

* rename logger pkg to logger

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix path in codeowners

Signed-off-by: Meredith Lancaster <malancas@github.com>

* formatter

Signed-off-by: Meredith Lancaster <malancas@github.com>

* go mod tidy

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix printf linter issue

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix printf linter issue

Signed-off-by: Meredith Lancaster <malancas@github.com>

* check user's GH host for compatibility

Signed-off-by: Meredith Lancaster <malancas@github.com>

* pass oci client to commands directly

Signed-off-by: Meredith Lancaster <malancas@github.com>

* rename command

Signed-off-by: Meredith Lancaster <malancas@github.com>

* mark tuf-root-verify cmd hidden

Signed-off-by: Meredith Lancaster <malancas@github.com>

* move client initialization back to subcommands

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add more verbose options and logging

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add missing logger

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add testing around OCI and API client

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add integration test

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix file path

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix command

Signed-off-by: Meredith Lancaster <malancas@github.com>

* build executable before integration test

Signed-off-by: Meredith Lancaster <malancas@github.com>

* split integration tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove integration test steps

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix flag value

Signed-off-by: Meredith Lancaster <malancas@github.com>

* run integration tests on ubuntu for now

Signed-off-by: Meredith Lancaster <malancas@github.com>

* pull over doc updates

Signed-off-by: Meredith Lancaster <malancas@github.com>

* delete unused test data

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove Go patch version

Signed-off-by: Meredith Lancaster <malancas@github.com>

* switch assert to require

Signed-off-by: Meredith Lancaster <malancas@github.com>

* rename file

Signed-off-by: Meredith Lancaster <malancas@github.com>

* move integration tests to prexisting test workflow

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use platform matrix for integration tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* simplify build step

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use StringEnumFlag handling

Signed-off-by: Meredith Lancaster <malancas@github.com>

* typo

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use the iostreams.Test helper func

Signed-off-by: Meredith Lancaster <malancas@github.com>

* create interface for oci client

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add tests for oci client

Signed-off-by: Meredith Lancaster <malancas@github.com>

* rename files

Signed-off-by: Meredith Lancaster <malancas@github.com>

* format file

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix shellcheck issues

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use testing TempDir method

Signed-off-by: Meredith Lancaster <malancas@github.com>

* cleanup unused tempdir handling

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use table driven tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* check correct cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* support repo option in download sub cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* switch over to using RunE

Signed-off-by: Meredith Lancaster <malancas@github.com>

* unexport top level subcommand funcs

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add comment around keychain option

Signed-off-by: Meredith Lancaster <malancas@github.com>

* update comments

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix inconsistent naming

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add tests for CLI commands

Signed-off-by: Meredith Lancaster <malancas@github.com>

* check for noattestationsfound err

Signed-off-by: Meredith Lancaster <malancas@github.com>

* try out metadata abstraction instead

Signed-off-by: Meredith Lancaster <malancas@github.com>

* switch to using MetadataStore abstraction

Signed-off-by: Meredith Lancaster <malancas@github.com>

* include test case with failing metadata store

Signed-off-by: Meredith Lancaster <malancas@github.com>

* look for err specific to file write

Signed-off-by: Meredith Lancaster <malancas@github.com>

* unexport fields

Signed-off-by: Meredith Lancaster <malancas@github.com>

* return err when an unsupported hash alg is provided

Signed-off-by: Meredith Lancaster <malancas@github.com>

* PrintTableToStdOut returns err when rendering fails

Signed-off-by: Meredith Lancaster <malancas@github.com>

* start adding sigstore verifier unit tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add more sigstore verifier specific tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use cli table printer

Signed-off-by: Meredith Lancaster <malancas@github.com>

* return JSON results in slice instead of table

Signed-off-by: Meredith Lancaster <malancas@github.com>

* move mock client to test file

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove unneeded table printer method

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add initial tests for tufrootverify cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* formatting

Signed-off-by: Meredith Lancaster <malancas@github.com>

* cleanup method

Signed-off-by: Meredith Lancaster <malancas@github.com>

* close file in error handling branch

Signed-off-by: Meredith Lancaster <malancas@github.com>

* normalize artifact path

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove unneeded embedded file system

Signed-off-by: Meredith Lancaster <malancas@github.com>

* include image name reference err

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use GH_DEBUG value for io handling

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove quiet and verbose flags

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add more tufrootveriify tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* GitHubTUFOptions no longer needs to return error

Signed-off-by: Meredith Lancaster <malancas@github.com>

* remove unneeded slice

Signed-off-by: Meredith Lancaster <malancas@github.com>

* normalize all relative paths

Signed-off-by: Meredith Lancaster <malancas@github.com>

* clean up nil client checks

Signed-off-by: Meredith Lancaster <malancas@github.com>

* set api server based on host

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add comment about http client

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use format flag to handle json output in verify cmd

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use format flag to handle json output

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use normalized path for cli test arg

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add tests for json output

Signed-off-by: Meredith Lancaster <malancas@github.com>

* cleanup error wrapping

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use test fixtures correctly by normalizing path

Signed-off-by: Meredith Lancaster <malancas@github.com>

* dont clean

Signed-off-by: Meredith Lancaster <malancas@github.com>

* escape backwards slash for windows files with replace

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use strings.Split func

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use strings.Replace for all command tests

Signed-off-by: Meredith Lancaster <malancas@github.com>

* use CLI cache dir to store tuf metadata

Signed-off-by: Meredith Lancaster <malancas@github.com>

* Tweaked docstrings for gh attestation download

* Tweaked docstrings for gh attestation verify

* Fix for bug in gh attestation where the wrong hostname was being passed to the API client.

* lets hide tuf-root-verify eh?

* Forgot verify's short str.

* add remote verification test

Signed-off-by: Meredith Lancaster <malancas@github.com>

* Revert "add remote verification test"

This reverts commit c0ceb99ca8.

* update json result handling

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add json tags to struct returned by command

Signed-off-by: Meredith Lancaster <malancas@github.com>

* fix how json results are handled

Signed-off-by: Meredith Lancaster <malancas@github.com>

* add test to ensure JSON output is valid

Signed-off-by: Meredith Lancaster <malancas@github.com>

---------

Signed-off-by: Meredith Lancaster <malancas@github.com>
Co-authored-by: Phill MV <phillmv@github.com>
2024-04-01 11:13:47 -06:00
Lars Lehtonen
07ee387f25
pkg/cmd/root: fix startup panic (#8105) 2023-10-02 07:03:24 +00:00
Raj Hawaldar
c5a7bf8f45
Hint adding codespace scope to auth login (#7961) 2023-09-21 08:43:27 +02:00
Jun Nishimura
508065b72d
Add verbose flag to api cmd (#7826) 2023-08-25 09:37:37 -07:00
John Keech
93e1511bae
Codespaces: Use the host name from the logged in server for commands (#7795)
* Use the host name from the logged in server for codespace commands

* Fix existing tests

* Add tests for server url configuration

* Rename defaultApiUrl to defaultAPIURL and comment cleanup

* Switch to t.Setenv in codespaces api tests

* Switch to t.Setenv in other tests

* Support custom server in web flows for list and create

* Rename GetServerURL() to ServerURL()
2023-08-08 09:32:06 -07:00
Nate Smith
96d7274044
Merge pull request #7403 from joshkraft/gh-cache-command
Create `gh cache list`, `gh cache delete`
2023-07-10 16:00:57 -07:00
Nate Smith
4ba2f2ffb3
Merge pull request #7650 from vaindil/vaindil/rulesets
Add support for repository rulesets
2023-07-10 12:50:23 -07:00
whi-tw
a7e2fc49b0
Use SmartBaseRepoFunc for api command (#7594) 2023-07-06 15:02:32 +09:00
vilmibm
bcb4194692 WIP compute branch, call API 2023-07-05 13:57:19 -04:00
Ariel Deitcher
ad4a489f8d
Introduce gh project commands (#7375)
Co-authored-by: Mislav Marohnić <mislav@github.com>
2023-06-09 16:57:01 +00:00
Mislav Marohnić
e3569dc7bd
Fix bash completions for extensions and aliases
Now that extensions and alises are real Cobra Command instances, they will appear in
completions automatically and don't need to be additionally inserted via ValidArgs.
Their addition to ValidArgs have caused all extensions and aliases to be listed twice
within completion results, which didn't seem to affect zsh completions at all, but in
bash completions it had caused the completion description to be a part of the expansion.
2023-06-02 13:31:02 +02:00
srz_zumix
dfb6d9d5bb
fix: Allow aliases to recognize extended commands (#7523) 2023-06-02 08:20:11 +09:00
Sam Coe
74ee8cacae
Allow creating of nested aliases (#7457) 2023-05-25 09:46:45 +09:00
Josh Kraft
2e5a728338
Merge branch 'trunk' into gh-cache-command 2023-05-17 14:34:10 -06:00
William Martin
07ed1e4e8a
Introduce helpTopics type and reduce duplication across commands (#7414) 2023-05-11 14:59:12 +02:00
Josh Kraft
213a59b8bd create cache commands 2023-05-03 11:03:50 -06:00
Josh Kraft
37970f4863 feat: add gh org list 2023-03-31 15:53:55 -06:00
Anupam Kumar
88cc4d2531
Add variable set command (#6928) 2023-03-13 03:01:38 +00:00
Sam Coe
c9a2d85793
Cleanup config.AuthToken and config.DefaultHost methods (#7049) 2023-02-28 00:24:45 +00:00
Robin Neatherway
78fb90956c
Teach gh cs create to use current repo as default (#6596)
Co-authored-by: Mislav Marohnić <mislav@github.com>
2023-02-07 20:05:38 +00:00
Mislav Marohnić
b3aeaf6c2e
Remove the feedback section from gh help 2022-11-09 16:43:18 +01:00
Mislav Marohnić
b12ea845ef
Migrate to the new Cobra command grouping feature 2022-11-09 16:42:13 +01:00
Matthew Runo
9b16d1ecdd Fixes #6024.
Adding documentation for exit codes used by 'gh'
2022-08-15 15:20:19 -07:00
Mislav Marohnić
d21d388b8d
Restore old GH_DEBUG=1 behavior for HTTP logging (#6054)
- No HTTP bodies or headers are logged until `GH_DEBUG=api` is used.
- Logging to terminal now supports colorization.
2022-08-10 17:59:13 +02:00
Sam Coe
074ed50b8a
Integrate go-gh API package (#5614) 2022-06-23 04:05:31 +01:00
Mislav Marohnić
7859afb586 Fix Cobra completion output going to stdout 2022-05-25 14:57:47 +02:00
Mislav Marohnić
cfaca91d06 Fix --version flag printing to stdout 2022-05-24 16:21:13 +02:00
Mislav Marohnić
2139e763fb Write Cobra deprecation messages to stderr
We used to do the equivalent of `rootCmd.SetOut(os.Stdout)` because we
thought that Cobra's "Out" stream represents standard output. However,
upon closer inspection it turns out that this is Cobra's stream for
usage errors and deprecation warnings, and those we want written to
stderr as well. It is not clear to me why Cobra maintains a distinction
between "Out" and "Err" streams since both seem to go to sdterr by
default.

This change also ceases our usage of `command.Print()` functions in
favor of explicitly writing to `IOStreams.Out/ErrOut`.
2022-05-23 20:23:42 +02:00
xiaotong
4a5864708c
Add label list and label create commands (#5316) 2022-03-29 17:38:59 +00:00
nate smith
f22c325ea4 gh status 2022-03-28 11:53:13 -05:00
Sam Coe
e0045f26b9
Add top level search command and search repos sub command (#5172) 2022-03-09 12:24:27 +00:00
Nate Smith
91c4a5d828
Merge pull request #5234 from markphelps/codespaces-accept-perms
Codespaces Create: Allow Accepting Permissions
2022-02-28 16:54:45 -06:00
Mislav Marohnić
7235384f12 gh: list help topics in help output 2022-02-18 18:39:30 +01:00
Mark Phelps
590acaa1d6 WIP 2022-02-15 19:35:53 -05:00
Mislav Marohnić
3b7e5fc246 Store Executable() information on codespaces App
This is to avoid having to explicitly pass it to each subcommand that
needs it. Each codespaces command runs in the context of App, so that's
a point of shared context that we can store state in.
2021-12-21 14:03:10 +01:00
Jason Lunz
f22be4a03d
use a more robust method to get the executable path
cmdutil.Factory.Executable() accounts for things like package managers
and symlinks to the actual executable.

An alternative to passing the *cmdutil.Factory down the stack would be
stashing the executable string in the codespace.App, which works (and
the diff is smaller), but it produced some odd non-local test failures.
This way seems less mysterious and more like other uses of Factory in
the codebase.
2021-12-20 13:57:52 -07:00
Marwan Sulaiman
a3940020f9
Inherit API endpoint configuration from the Codespaces environment (#4723)
gh codespace commands now respect the following environment variables:

- GITHUB_SERVER_URL: typically "https://github.com"
- GITHUB_API_URL: typically "https://api.github.com"
- INTERNAL_VSCS_TARGET_URL: typically "https://online.visualstudio.com"
- GITHUB_TOKEN when CODESPACES is set, even if the host connecting to isn't "github.com".

This set of changes ensures that `gh codespace` commands automatically connect to the right API endpoints when gh is used within a codespace.

Co-authored-by: Mislav Marohnić <mislav@github.com>
2021-11-22 12:40:01 +01:00
Mislav Marohnić
a843cbd728 Mark codespace a core command 2021-10-25 19:42:22 +02:00
Mislav Marohnić
31ba2ea4d5
Publish codespace commands (#4606) 2021-10-25 17:38:00 +00:00
Jose Garcia
bbea5ac95e
codespace: progress indication, logging (#4555)
* Rework logging, showing progress, and printing from `codespace` commands
* Change rendering of the general progress indicator so that it's visible on both dark and light backgrounds
* The progress indicator now "spins" faster

Co-authored-by: Mislav Marohnić <mislav@github.com>
2021-10-21 18:04:04 +02:00