sheaf · sha:9a2f33078 · fragmentation scan · gh · 2026-06-07 22:34 UTC

218 Commands

Reference docs
100%
217 with doc evidence
show the 217
Tests
82%
179 with test evidence
show the 179
Usage
90%
196 in docs / RFCs
show the 196

945 Flags

Reference docs
100%
941 with doc evidence
show the 941
Tests
42%
394 with test evidence
show the 394
Usage
29%
276 in docs / RFCs
show the 276

835 Gaps · Worklist

Docs cover 1158 commands; tests cover 573; usage covers 520. Usage is the bottleneck — every Completed command needs all three. Closing the largest group would move 70% of the debt — the biggest single shift available.

441
Asserted
DOCS TESTS EXAMPLES
claim in docs, nothing verifies it
gh --helpgh --versiongh agent-task create --from-filegh agent-task list --jqgh agent-task list --jsongh agent-task list --template
328
Completed
DOCS TESTS EXAMPLES
all three surfaces aligned
gh agent-taskgh agent-task creategh agent-task create --followgh agent-task listgh agent-task viewgh alias delete
245
Established
DOCS TESTS EXAMPLES
explained and verified, no example
gh agent-task create --repogh agent-task list --limitgh agent-task list --webgh agent-task view --followgh agent-task view --loggh alias
144
Shown
DOCS TESTS EXAMPLES
explained and demoed, but not verified
ghgh agent-task create --basegh agent-task create --custom-agentgh agent-task view --repogh agent-task view --webgh api --preview
5
Unclaimed
DOCS TESTS EXAMPLES
only the contract, nothing else
gh cogh co --branchgh co --detachgh co --forcegh co --recurse-submodules
5
REPLACE THE STUB Replace the inherited boilerplate with prose that explains the actual behavior.
585
CITE IT IN A TEST Name this element in an existing test (a t.Run label, a table-driven case name, a comment) or add a test that does.
gh agent-task create --base sheaf-cobra-yaml/gh_agent-task_create.yaml:1
gh agent-task create --custom-agent sheaf-cobra-yaml/gh_agent-task_create.yaml:1
gh agent-task create --from-file sheaf-cobra-yaml/gh_agent-task_create.yaml:1
gh agent-task list --json sheaf-cobra-yaml/gh_agent-task_list.yaml:1
gh agent-task list --template sheaf-cobra-yaml/gh_agent-task_list.yaml:1
gh agent-task view --json sheaf-cobra-yaml/gh_agent-task_view.yaml:1
gh agent-task view --repo sheaf-cobra-yaml/gh_agent-task_view.yaml:1
gh agent-task view --template sheaf-cobra-yaml/gh_agent-task_view.yaml:1
gh alias import --clobber sheaf-cobra-yaml/gh_alias_import.yaml:1
gh api --raw-field sheaf-cobra-yaml/gh_api.yaml:1
gh attestation download --hostname sheaf-cobra-yaml/gh_attestation_download.yaml:1
gh attestation download --predicate-type sheaf-cobra-yaml/gh_attestation_download.yaml:1
gh attestation trusted-root --hostname sheaf-cobra-yaml/gh_attestation_trusted-root.yaml:1
gh attestation trusted-root --tuf-root sheaf-cobra-yaml/gh_attestation_trusted-root.yaml:1
gh attestation trusted-root --tuf-url sheaf-cobra-yaml/gh_attestation_trusted-root.yaml:1
gh attestation trusted-root --verify-only sheaf-cobra-yaml/gh_attestation_trusted-root.yaml:1
gh attestation verify --cert-oidc-issuer sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --custom-trusted-root sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --deny-self-hosted-runners sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --no-public-good sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --signer-digest sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --signer-repo sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --signer-workflow sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --source-digest sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --source-ref sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --template sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh auth login --git-protocol sheaf-cobra-yaml/gh_auth_login.yaml:1
gh auth refresh --clipboard sheaf-cobra-yaml/gh_auth_refresh.yaml:1
gh auth refresh --hostname sheaf-cobra-yaml/gh_auth_refresh.yaml:1
gh auth setup-git --force sheaf-cobra-yaml/gh_auth_setup-git.yaml:1
gh auth setup-git --hostname sheaf-cobra-yaml/gh_auth_setup-git.yaml:1
gh auth status --template sheaf-cobra-yaml/gh_auth_status.yaml:1
gh cache list --template sheaf-cobra-yaml/gh_cache_list.yaml:1
gh codespace code --codespace sheaf-cobra-yaml/gh_codespace_code.yaml:1
gh codespace code --insiders sheaf-cobra-yaml/gh_codespace_code.yaml:1
gh codespace code --repo-owner sheaf-cobra-yaml/gh_codespace_code.yaml:1
gh codespace cp --codespace sheaf-cobra-yaml/gh_codespace_cp.yaml:1
gh codespace cp --expand sheaf-cobra-yaml/gh_codespace_cp.yaml:1
gh codespace cp --profile sheaf-cobra-yaml/gh_codespace_cp.yaml:1
gh codespace cp --recursive sheaf-cobra-yaml/gh_codespace_cp.yaml:1
gh codespace cp --repo-owner sheaf-cobra-yaml/gh_codespace_cp.yaml:1
gh codespace create --branch sheaf-cobra-yaml/gh_codespace_create.yaml:1
gh codespace create --devcontainer-path sheaf-cobra-yaml/gh_codespace_create.yaml:1
gh codespace create --location sheaf-cobra-yaml/gh_codespace_create.yaml:1
gh codespace create --machine sheaf-cobra-yaml/gh_codespace_create.yaml:1
gh codespace create --repo sheaf-cobra-yaml/gh_codespace_create.yaml:1
gh codespace create --status sheaf-cobra-yaml/gh_codespace_create.yaml:1
gh codespace delete --codespace sheaf-cobra-yaml/gh_codespace_delete.yaml:1
gh codespace delete --days sheaf-cobra-yaml/gh_codespace_delete.yaml:1
gh codespace delete --force sheaf-cobra-yaml/gh_codespace_delete.yaml:1
gh codespace delete --repo sheaf-cobra-yaml/gh_codespace_delete.yaml:1
gh codespace delete --repo-owner sheaf-cobra-yaml/gh_codespace_delete.yaml:1
gh codespace delete --user sheaf-cobra-yaml/gh_codespace_delete.yaml:1
gh codespace edit --repo-owner sheaf-cobra-yaml/gh_codespace_edit.yaml:1
gh codespace jupyter --codespace sheaf-cobra-yaml/gh_codespace_jupyter.yaml:1
gh codespace jupyter --repo sheaf-cobra-yaml/gh_codespace_jupyter.yaml:1
gh codespace jupyter --repo-owner sheaf-cobra-yaml/gh_codespace_jupyter.yaml:1
gh codespace list --template sheaf-cobra-yaml/gh_codespace_list.yaml:1
gh codespace logs --codespace sheaf-cobra-yaml/gh_codespace_logs.yaml:1
gh codespace logs --follow sheaf-cobra-yaml/gh_codespace_logs.yaml:1
gh codespace logs --repo-owner sheaf-cobra-yaml/gh_codespace_logs.yaml:1
gh codespace ports --codespace sheaf-cobra-yaml/gh_codespace_ports.yaml:1
gh codespace ports --json sheaf-cobra-yaml/gh_codespace_ports.yaml:1
gh codespace ports --repo sheaf-cobra-yaml/gh_codespace_ports.yaml:1
gh codespace ports --repo-owner sheaf-cobra-yaml/gh_codespace_ports.yaml:1
gh codespace ports --template sheaf-cobra-yaml/gh_codespace_ports.yaml:1
gh codespace rebuild --codespace sheaf-cobra-yaml/gh_codespace_rebuild.yaml:1
gh codespace rebuild --full sheaf-cobra-yaml/gh_codespace_rebuild.yaml:1
gh codespace rebuild --repo sheaf-cobra-yaml/gh_codespace_rebuild.yaml:1
gh codespace rebuild --repo-owner sheaf-cobra-yaml/gh_codespace_rebuild.yaml:1
gh codespace ssh --codespace sheaf-cobra-yaml/gh_codespace_ssh.yaml:1
gh codespace ssh --config sheaf-cobra-yaml/gh_codespace_ssh.yaml:1
gh codespace ssh --debug sheaf-cobra-yaml/gh_codespace_ssh.yaml:1
gh codespace ssh --debug-file sheaf-cobra-yaml/gh_codespace_ssh.yaml:1
gh codespace ssh --profile sheaf-cobra-yaml/gh_codespace_ssh.yaml:1
gh codespace ssh --repo-owner sheaf-cobra-yaml/gh_codespace_ssh.yaml:1
gh codespace ssh --server-port sheaf-cobra-yaml/gh_codespace_ssh.yaml:1
gh codespace stop --codespace sheaf-cobra-yaml/gh_codespace_stop.yaml:1
gh codespace stop --repo-owner sheaf-cobra-yaml/gh_codespace_stop.yaml:1
gh codespace view --codespace sheaf-cobra-yaml/gh_codespace_view.yaml:1
gh codespace view --repo-owner sheaf-cobra-yaml/gh_codespace_view.yaml:1
gh codespace view --template sheaf-cobra-yaml/gh_codespace_view.yaml:1
gh extension browse --debug sheaf-cobra-yaml/gh_extension_browse.yaml:1
gh extension browse --single-column sheaf-cobra-yaml/gh_extension_browse.yaml:1
gh extension create --precompiled sheaf-cobra-yaml/gh_extension_create.yaml:1
gh extension install --force sheaf-cobra-yaml/gh_extension_install.yaml:1
gh extension search --json sheaf-cobra-yaml/gh_extension_search.yaml:1
gh extension search --license sheaf-cobra-yaml/gh_extension_search.yaml:1
gh extension search --limit sheaf-cobra-yaml/gh_extension_search.yaml:1
gh extension search --order sheaf-cobra-yaml/gh_extension_search.yaml:1
gh extension search --owner sheaf-cobra-yaml/gh_extension_search.yaml:1
gh extension search --sort sheaf-cobra-yaml/gh_extension_search.yaml:1
gh extension search --template sheaf-cobra-yaml/gh_extension_search.yaml:1
gh extension upgrade --dry-run sheaf-cobra-yaml/gh_extension_upgrade.yaml:1
gh extension upgrade --force sheaf-cobra-yaml/gh_extension_upgrade.yaml:1
gh gist create --filename sheaf-cobra-yaml/gh_gist_create.yaml:1
gh gist create --public sheaf-cobra-yaml/gh_gist_create.yaml:1
gh gist view --filename sheaf-cobra-yaml/gh_gist_view.yaml:1
gh issue create --assignee sheaf-cobra-yaml/gh_issue_create.yaml:1
gh issue create --body-file sheaf-cobra-yaml/gh_issue_create.yaml:1
gh issue create --label sheaf-cobra-yaml/gh_issue_create.yaml:1
gh issue create --milestone sheaf-cobra-yaml/gh_issue_create.yaml:1
gh issue create --project sheaf-cobra-yaml/gh_issue_create.yaml:1
gh issue create --template sheaf-cobra-yaml/gh_issue_create.yaml:1
gh issue create --title sheaf-cobra-yaml/gh_issue_create.yaml:1
gh issue list --assignee sheaf-cobra-yaml/gh_issue_list.yaml:1
gh issue list --author sheaf-cobra-yaml/gh_issue_list.yaml:1
gh issue list --milestone sheaf-cobra-yaml/gh_issue_list.yaml:1
gh issue list --search sheaf-cobra-yaml/gh_issue_list.yaml:1
gh issue list --template sheaf-cobra-yaml/gh_issue_list.yaml:1
gh issue status --template sheaf-cobra-yaml/gh_issue_status.yaml:1
gh issue view --template sheaf-cobra-yaml/gh_issue_view.yaml:1
gh label create --force sheaf-cobra-yaml/gh_label_create.yaml:1
gh label list --template sheaf-cobra-yaml/gh_label_list.yaml:1
gh pr checks --template sheaf-cobra-yaml/gh_pr_checks.yaml:1
gh pr close --delete-branch sheaf-cobra-yaml/gh_pr_close.yaml:1
gh pr create --assignee sheaf-cobra-yaml/gh_pr_create.yaml:1
gh pr create --fill-verbose sheaf-cobra-yaml/gh_pr_create.yaml:1
gh pr create --milestone sheaf-cobra-yaml/gh_pr_create.yaml:1
gh pr create --no-maintainer-edit sheaf-cobra-yaml/gh_pr_create.yaml:1
gh pr create --project sheaf-cobra-yaml/gh_pr_create.yaml:1
gh pr create --recover sheaf-cobra-yaml/gh_pr_create.yaml:1
gh pr create --reviewer sheaf-cobra-yaml/gh_pr_create.yaml:1
gh pr list --assignee sheaf-cobra-yaml/gh_pr_list.yaml:1
gh pr list --template sheaf-cobra-yaml/gh_pr_list.yaml:1
gh pr merge --disable-auto sheaf-cobra-yaml/gh_pr_merge.yaml:1
gh pr merge --subject sheaf-cobra-yaml/gh_pr_merge.yaml:1
gh pr revert --body-file sheaf-cobra-yaml/gh_pr_revert.yaml:1
gh pr status --conflict-status sheaf-cobra-yaml/gh_pr_status.yaml:1
gh pr status --template sheaf-cobra-yaml/gh_pr_status.yaml:1
gh pr view --template sheaf-cobra-yaml/gh_pr_view.yaml:1
gh project close --template sheaf-cobra-yaml/gh_project_close.yaml:1
gh project copy --template sheaf-cobra-yaml/gh_project_copy.yaml:1
gh project create --template sheaf-cobra-yaml/gh_project_create.yaml:1
gh project delete --template sheaf-cobra-yaml/gh_project_delete.yaml:1
gh project edit --template sheaf-cobra-yaml/gh_project_edit.yaml:1
gh project field-create --data-type sheaf-cobra-yaml/gh_project_field-create.yaml:1
gh project field-create --format sheaf-cobra-yaml/gh_project_field-create.yaml:1
gh project field-create --name sheaf-cobra-yaml/gh_project_field-create.yaml:1
gh project field-create --owner sheaf-cobra-yaml/gh_project_field-create.yaml:1
gh project field-create --single-select-options sheaf-cobra-yaml/gh_project_field-create.yaml:1
gh project field-create --template sheaf-cobra-yaml/gh_project_field-create.yaml:1
gh project field-delete --format sheaf-cobra-yaml/gh_project_field-delete.yaml:1
gh project field-delete --template sheaf-cobra-yaml/gh_project_field-delete.yaml:1
gh project field-list --format sheaf-cobra-yaml/gh_project_field-list.yaml:1
gh project field-list --limit sheaf-cobra-yaml/gh_project_field-list.yaml:1
gh project field-list --owner sheaf-cobra-yaml/gh_project_field-list.yaml:1
gh project field-list --template sheaf-cobra-yaml/gh_project_field-list.yaml:1
gh project item-add --format sheaf-cobra-yaml/gh_project_item-add.yaml:1
gh project item-add --owner sheaf-cobra-yaml/gh_project_item-add.yaml:1
gh project item-add --template sheaf-cobra-yaml/gh_project_item-add.yaml:1
gh project item-archive --format sheaf-cobra-yaml/gh_project_item-archive.yaml:1
gh project item-archive --owner sheaf-cobra-yaml/gh_project_item-archive.yaml:1
gh project item-archive --template sheaf-cobra-yaml/gh_project_item-archive.yaml:1
gh project item-archive --undo sheaf-cobra-yaml/gh_project_item-archive.yaml:1
gh project item-create --body sheaf-cobra-yaml/gh_project_item-create.yaml:1
gh project item-create --format sheaf-cobra-yaml/gh_project_item-create.yaml:1
gh project item-create --owner sheaf-cobra-yaml/gh_project_item-create.yaml:1
gh project item-create --template sheaf-cobra-yaml/gh_project_item-create.yaml:1
gh project item-create --title sheaf-cobra-yaml/gh_project_item-create.yaml:1
gh project item-delete --format sheaf-cobra-yaml/gh_project_item-delete.yaml:1
gh project item-delete --owner sheaf-cobra-yaml/gh_project_item-delete.yaml:1
gh project item-delete --template sheaf-cobra-yaml/gh_project_item-delete.yaml:1
gh project item-edit --body sheaf-cobra-yaml/gh_project_item-edit.yaml:1
gh project item-edit --clear sheaf-cobra-yaml/gh_project_item-edit.yaml:1
gh project item-edit --date sheaf-cobra-yaml/gh_project_item-edit.yaml:1
gh project item-edit --field-id sheaf-cobra-yaml/gh_project_item-edit.yaml:1
gh project item-edit --format sheaf-cobra-yaml/gh_project_item-edit.yaml:1
gh project item-edit --iteration-id sheaf-cobra-yaml/gh_project_item-edit.yaml:1
gh project item-edit --number sheaf-cobra-yaml/gh_project_item-edit.yaml:1
gh project item-edit --project-id sheaf-cobra-yaml/gh_project_item-edit.yaml:1
gh project item-edit --single-select-option-id sheaf-cobra-yaml/gh_project_item-edit.yaml:1
gh project item-edit --template sheaf-cobra-yaml/gh_project_item-edit.yaml:1
gh project item-edit --text sheaf-cobra-yaml/gh_project_item-edit.yaml:1
gh project item-edit --title sheaf-cobra-yaml/gh_project_item-edit.yaml:1
gh project item-list --format sheaf-cobra-yaml/gh_project_item-list.yaml:1
gh project item-list --limit sheaf-cobra-yaml/gh_project_item-list.yaml:1
gh project item-list --owner sheaf-cobra-yaml/gh_project_item-list.yaml:1
gh project item-list --query sheaf-cobra-yaml/gh_project_item-list.yaml:1
gh project item-list --template sheaf-cobra-yaml/gh_project_item-list.yaml:1
gh project list --limit sheaf-cobra-yaml/gh_project_list.yaml:1
gh project list --template sheaf-cobra-yaml/gh_project_list.yaml:1
gh project view --template sheaf-cobra-yaml/gh_project_view.yaml:1
gh release create --draft sheaf-cobra-yaml/gh_release_create.yaml:1
gh release create --notes sheaf-cobra-yaml/gh_release_create.yaml:1
gh release create --notes-file sheaf-cobra-yaml/gh_release_create.yaml:1
gh release create --prerelease sheaf-cobra-yaml/gh_release_create.yaml:1
gh release create --title sheaf-cobra-yaml/gh_release_create.yaml:1
gh release delete-asset --yes sheaf-cobra-yaml/gh_release_delete-asset.yaml:1
gh release edit --notes-file sheaf-cobra-yaml/gh_release_edit.yaml:1
gh release list --template sheaf-cobra-yaml/gh_release_list.yaml:1
gh release upload --clobber sheaf-cobra-yaml/gh_release_upload.yaml:1
gh release verify --format sheaf-cobra-yaml/gh_release_verify.yaml:1
gh release verify --template sheaf-cobra-yaml/gh_release_verify.yaml:1
gh release verify-asset --format sheaf-cobra-yaml/gh_release_verify-asset.yaml:1
gh release verify-asset --template sheaf-cobra-yaml/gh_release_verify-asset.yaml:1
gh release view --template sheaf-cobra-yaml/gh_release_view.yaml:1
gh repo autolink list --template sheaf-cobra-yaml/gh_repo_autolink_list.yaml:1
gh repo autolink view --template sheaf-cobra-yaml/gh_repo_autolink_view.yaml:1
gh repo create --add-readme sheaf-cobra-yaml/gh_repo_create.yaml:1
gh repo create --description sheaf-cobra-yaml/gh_repo_create.yaml:1
gh repo create --disable-issues sheaf-cobra-yaml/gh_repo_create.yaml:1
gh repo create --disable-wiki sheaf-cobra-yaml/gh_repo_create.yaml:1
gh repo create --homepage sheaf-cobra-yaml/gh_repo_create.yaml:1
gh repo deploy-key --repo sheaf-cobra-yaml/gh_repo_deploy-key.yaml:1
gh repo deploy-key add --allow-write sheaf-cobra-yaml/gh_repo_deploy-key_add.yaml:1
gh repo deploy-key add --title sheaf-cobra-yaml/gh_repo_deploy-key_add.yaml:1
gh repo deploy-key list --json sheaf-cobra-yaml/gh_repo_deploy-key_list.yaml:1
gh repo deploy-key list --template sheaf-cobra-yaml/gh_repo_deploy-key_list.yaml:1
gh repo edit --add-topic sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --allow-forking sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --allow-update-branch sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --default-branch sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --delete-branch-on-merge sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --enable-advanced-security sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --enable-auto-merge sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --enable-discussions sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --enable-issues sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --enable-merge-commit sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --enable-projects sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --enable-rebase-merge sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --enable-secret-scanning sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --enable-secret-scanning-push-protection sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --enable-wiki sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --homepage sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --remove-topic sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --template sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo fork --default-branch-only sheaf-cobra-yaml/gh_repo_fork.yaml:1
gh repo list --language sheaf-cobra-yaml/gh_repo_list.yaml:1
gh repo list --template sheaf-cobra-yaml/gh_repo_list.yaml:1
gh repo set-default --unset sheaf-cobra-yaml/gh_repo_set-default.yaml:1
gh repo set-default --view sheaf-cobra-yaml/gh_repo_set-default.yaml:1
gh repo view --branch sheaf-cobra-yaml/gh_repo_view.yaml:1
gh repo view --template sheaf-cobra-yaml/gh_repo_view.yaml:1
gh run download --pattern sheaf-cobra-yaml/gh_run_download.yaml:1
gh run list --template sheaf-cobra-yaml/gh_run_list.yaml:1
gh run view --template sheaf-cobra-yaml/gh_run_view.yaml:1
gh run view --verbose sheaf-cobra-yaml/gh_run_view.yaml:1
gh run watch --interval sheaf-cobra-yaml/gh_run_watch.yaml:1
gh search code --extension sheaf-cobra-yaml/gh_search_code.yaml:1
gh search code --filename sheaf-cobra-yaml/gh_search_code.yaml:1
gh search code --language sheaf-cobra-yaml/gh_search_code.yaml:1
gh search code --template sheaf-cobra-yaml/gh_search_code.yaml:1
gh search commits --author sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --author-date sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --author-email sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --author-name sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --committer sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --committer-date sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --committer-email sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --committer-name sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --merge sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --owner sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --parent sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --template sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --visibility sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search issues --archived sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --assignee sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --closed sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --commenter sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --comments sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --created sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --interactions sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --involves sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --label sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --language sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --locked sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --match sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --mentions sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --milestone sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --no-assignee sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --no-label sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --no-milestone sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --no-project sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --owner sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --project sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --reactions sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --state sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --team-mentions sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --template sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --updated sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --visibility sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search prs --archived sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --assignee sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --checks sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --closed sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --commenter sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --comments sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --created sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --interactions sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --involves sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --language sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --locked sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --mentions sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --merged sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --merged-at sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --milestone sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --no-assignee sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --no-label sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --no-milestone sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --no-project sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --project sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --reactions sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --review sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --reviewed-by sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --team-mentions sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --template sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --updated sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search prs --visibility sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search repos --archived sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --created sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --followers sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --forks sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --good-first-issues sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --help-wanted-issues sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --include-forks sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --language sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --license sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --match sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --number-topics sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --owner sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --stars sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --template sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --topic sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --updated sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --visibility sheaf-cobra-yaml/gh_search_repos.yaml:1
gh secret list --template sheaf-cobra-yaml/gh_secret_list.yaml:1
gh secret set --env-file sheaf-cobra-yaml/gh_secret_set.yaml:1
gh secret set --no-store sheaf-cobra-yaml/gh_secret_set.yaml:1
gh skill install --agent sheaf-cobra-yaml/gh_skill_install.yaml:1
gh skill install --allow-hidden-dirs sheaf-cobra-yaml/gh_skill_install.yaml:1
gh skill install --force sheaf-cobra-yaml/gh_skill_install.yaml:1
gh skill install --from-local sheaf-cobra-yaml/gh_skill_install.yaml:1
gh skill install --scope sheaf-cobra-yaml/gh_skill_install.yaml:1
gh skill install --upstream sheaf-cobra-yaml/gh_skill_install.yaml:1
gh skill preview --allow-hidden-dirs sheaf-cobra-yaml/gh_skill_preview.yaml:1
gh skill publish --dry-run sheaf-cobra-yaml/gh_skill_publish.yaml:1
gh skill search --limit sheaf-cobra-yaml/gh_skill_search.yaml:1
gh skill search --owner sheaf-cobra-yaml/gh_skill_search.yaml:1
gh skill search --template sheaf-cobra-yaml/gh_skill_search.yaml:1
gh skill update --dry-run sheaf-cobra-yaml/gh_skill_update.yaml:1
gh skill update --force sheaf-cobra-yaml/gh_skill_update.yaml:1
gh skill update --unpin sheaf-cobra-yaml/gh_skill_update.yaml:1
gh status --exclude sheaf-cobra-yaml/gh_status.yaml:1
gh variable get --template sheaf-cobra-yaml/gh_variable_get.yaml:1
gh variable list --template sheaf-cobra-yaml/gh_variable_list.yaml:1
gh variable set --env-file sheaf-cobra-yaml/gh_variable_set.yaml:1
gh variable set --repos sheaf-cobra-yaml/gh_variable_set.yaml:1
gh variable set --visibility sheaf-cobra-yaml/gh_variable_set.yaml:1
gh workflow list --template sheaf-cobra-yaml/gh_workflow_list.yaml:1
gh workflow run --field sheaf-cobra-yaml/gh_workflow_run.yaml:1
gh workflow run --raw-field sheaf-cobra-yaml/gh_workflow_run.yaml:1
245
ADD AN EXAMPLE Add a runnable snippet, or promote an existing test into an example.
gh agent-task create --repo sheaf-cobra-yaml/gh_agent-task_create.yaml:1
gh agent-task list --limit sheaf-cobra-yaml/gh_agent-task_list.yaml:1
gh agent-task view --follow sheaf-cobra-yaml/gh_agent-task_view.yaml:1
gh alias set --clobber sheaf-cobra-yaml/gh_alias_set.yaml:1
gh api --hostname sheaf-cobra-yaml/gh_api.yaml:1
gh attestation download --digest-alg sheaf-cobra-yaml/gh_attestation_download.yaml:1
gh attestation download --limit sheaf-cobra-yaml/gh_attestation_download.yaml:1
gh attestation verify --bundle-from-oci sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --cert-identity sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --cert-identity-regex sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --digest-alg sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --hostname sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --limit sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh attestation verify --predicate-type sheaf-cobra-yaml/gh_attestation_verify.yaml:1
gh auth login --insecure-storage sheaf-cobra-yaml/gh_auth_login.yaml:1
gh auth login --scopes sheaf-cobra-yaml/gh_auth_login.yaml:1
gh auth login --skip-ssh-key sheaf-cobra-yaml/gh_auth_login.yaml:1
gh auth refresh --insecure-storage sheaf-cobra-yaml/gh_auth_refresh.yaml:1
gh auth token --hostname sheaf-cobra-yaml/gh_auth_token.yaml:1
gh browse --actions sheaf-cobra-yaml/gh_browse.yaml:1
gh browse --no-browser sheaf-cobra-yaml/gh_browse.yaml:1
gh browse --projects sheaf-cobra-yaml/gh_browse.yaml:1
gh browse --releases sheaf-cobra-yaml/gh_browse.yaml:1
gh codespace create --default-permissions sheaf-cobra-yaml/gh_codespace_create.yaml:1
gh codespace create --display-name sheaf-cobra-yaml/gh_codespace_create.yaml:1
gh codespace create --idle-timeout sheaf-cobra-yaml/gh_codespace_create.yaml:1
gh codespace create --retention-period sheaf-cobra-yaml/gh_codespace_create.yaml:1
gh codespace edit --codespace sheaf-cobra-yaml/gh_codespace_edit.yaml:1
gh codespace edit --display-name sheaf-cobra-yaml/gh_codespace_edit.yaml:1
gh codespace edit --machine sheaf-cobra-yaml/gh_codespace_edit.yaml:1
gh codespace list --limit sheaf-cobra-yaml/gh_codespace_list.yaml:1
gh gist list --public sheaf-cobra-yaml/gh_gist_list.yaml:1
gh issue comment --body-file sheaf-cobra-yaml/gh_issue_comment.yaml:1
gh issue comment --create-if-none sheaf-cobra-yaml/gh_issue_comment.yaml:1
gh issue comment --delete-last sheaf-cobra-yaml/gh_issue_comment.yaml:1
gh issue comment --edit-last sheaf-cobra-yaml/gh_issue_comment.yaml:1
gh issue comment --editor sheaf-cobra-yaml/gh_issue_comment.yaml:1
gh issue create --editor sheaf-cobra-yaml/gh_issue_create.yaml:1
gh issue create --recover sheaf-cobra-yaml/gh_issue_create.yaml:1
gh issue list --mention sheaf-cobra-yaml/gh_issue_list.yaml:1
gh issue lock --reason sheaf-cobra-yaml/gh_issue_lock.yaml:1
gh issue reopen --comment sheaf-cobra-yaml/gh_issue_reopen.yaml:1
gh issue view --comments sheaf-cobra-yaml/gh_issue_view.yaml:1
gh pr checkout --branch sheaf-cobra-yaml/gh_pr_checkout.yaml:1
gh pr checkout --detach sheaf-cobra-yaml/gh_pr_checkout.yaml:1
gh pr checkout --recurse-submodules sheaf-cobra-yaml/gh_pr_checkout.yaml:1
gh pr checks --fail-fast sheaf-cobra-yaml/gh_pr_checks.yaml:1
gh pr checks --interval sheaf-cobra-yaml/gh_pr_checks.yaml:1
gh pr checks --required sheaf-cobra-yaml/gh_pr_checks.yaml:1
gh pr close --comment sheaf-cobra-yaml/gh_pr_close.yaml:1
gh pr comment --body-file sheaf-cobra-yaml/gh_pr_comment.yaml:1
gh pr comment --create-if-none sheaf-cobra-yaml/gh_pr_comment.yaml:1
gh pr comment --delete-last sheaf-cobra-yaml/gh_pr_comment.yaml:1
gh pr comment --edit-last sheaf-cobra-yaml/gh_pr_comment.yaml:1
gh pr comment --editor sheaf-cobra-yaml/gh_pr_comment.yaml:1
gh pr create --body-file sheaf-cobra-yaml/gh_pr_create.yaml:1
gh pr create --dry-run sheaf-cobra-yaml/gh_pr_create.yaml:1
gh pr create --editor sheaf-cobra-yaml/gh_pr_create.yaml:1
gh pr create --fill-first sheaf-cobra-yaml/gh_pr_create.yaml:1
gh pr merge --author-email sheaf-cobra-yaml/gh_pr_merge.yaml:1
gh pr merge --body-file sheaf-cobra-yaml/gh_pr_merge.yaml:1
gh pr merge --delete-branch sheaf-cobra-yaml/gh_pr_merge.yaml:1
gh pr merge --match-head-commit sheaf-cobra-yaml/gh_pr_merge.yaml:1
gh pr reopen --comment sheaf-cobra-yaml/gh_pr_reopen.yaml:1
gh pr review --body-file sheaf-cobra-yaml/gh_pr_review.yaml:1
gh pr review --request-changes sheaf-cobra-yaml/gh_pr_review.yaml:1
gh pr view --comments sheaf-cobra-yaml/gh_pr_view.yaml:1
gh project close --format sheaf-cobra-yaml/gh_project_close.yaml:1
gh project copy --drafts sheaf-cobra-yaml/gh_project_copy.yaml:1
gh project copy --format sheaf-cobra-yaml/gh_project_copy.yaml:1
gh project create --format sheaf-cobra-yaml/gh_project_create.yaml:1
gh project delete --format sheaf-cobra-yaml/gh_project_delete.yaml:1
gh project edit --description sheaf-cobra-yaml/gh_project_edit.yaml:1
gh project edit --format sheaf-cobra-yaml/gh_project_edit.yaml:1
gh project edit --readme sheaf-cobra-yaml/gh_project_edit.yaml:1
gh project edit --visibility sheaf-cobra-yaml/gh_project_edit.yaml:1
gh project list --format sheaf-cobra-yaml/gh_project_list.yaml:1
gh project view --format sheaf-cobra-yaml/gh_project_view.yaml:1
gh release create --notes-start-tag sheaf-cobra-yaml/gh_release_create.yaml:1
gh release create --target sheaf-cobra-yaml/gh_release_create.yaml:1
gh release create --verify-tag sheaf-cobra-yaml/gh_release_create.yaml:1
gh release delete --cleanup-tag sheaf-cobra-yaml/gh_release_delete.yaml:1
gh release download --clobber sheaf-cobra-yaml/gh_release_download.yaml:1
gh release download --output sheaf-cobra-yaml/gh_release_download.yaml:1
gh release download --skip-existing sheaf-cobra-yaml/gh_release_download.yaml:1
gh release edit --discussion-category sheaf-cobra-yaml/gh_release_edit.yaml:1
gh release edit --latest sheaf-cobra-yaml/gh_release_edit.yaml:1
gh release edit --notes sheaf-cobra-yaml/gh_release_edit.yaml:1
gh release edit --prerelease sheaf-cobra-yaml/gh_release_edit.yaml:1
gh release edit --target sheaf-cobra-yaml/gh_release_edit.yaml:1
gh release edit --title sheaf-cobra-yaml/gh_release_edit.yaml:1
gh release edit --verify-tag sheaf-cobra-yaml/gh_release_edit.yaml:1
gh release list --exclude-drafts sheaf-cobra-yaml/gh_release_list.yaml:1
gh release list --exclude-pre-releases sheaf-cobra-yaml/gh_release_list.yaml:1
gh release list --limit sheaf-cobra-yaml/gh_release_list.yaml:1
gh release list --order sheaf-cobra-yaml/gh_release_list.yaml:1
gh repo autolink delete --yes sheaf-cobra-yaml/gh_repo_autolink_delete.yaml:1
gh repo autolink list --json sheaf-cobra-yaml/gh_repo_autolink_list.yaml:1
gh repo autolink list --web sheaf-cobra-yaml/gh_repo_autolink_list.yaml:1
gh repo autolink view --json sheaf-cobra-yaml/gh_repo_autolink_view.yaml:1
gh repo clone --upstream-remote-name sheaf-cobra-yaml/gh_repo_clone.yaml:1
gh repo create --gitignore sheaf-cobra-yaml/gh_repo_create.yaml:1
gh repo create --include-all-branches sheaf-cobra-yaml/gh_repo_create.yaml:1
gh repo create --internal sheaf-cobra-yaml/gh_repo_create.yaml:1
gh repo create --license sheaf-cobra-yaml/gh_repo_create.yaml:1
gh repo create --template sheaf-cobra-yaml/gh_repo_create.yaml:1
gh repo edit --accept-visibility-change-consequences sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --description sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --enable-squash-merge sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --squash-merge-commit-message sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo edit --visibility sheaf-cobra-yaml/gh_repo_edit.yaml:1
gh repo fork --fork-name sheaf-cobra-yaml/gh_repo_fork.yaml:1
gh repo fork --remote sheaf-cobra-yaml/gh_repo_fork.yaml:1
gh repo fork --remote-name sheaf-cobra-yaml/gh_repo_fork.yaml:1
gh repo list --archived sheaf-cobra-yaml/gh_repo_list.yaml:1
gh repo list --no-archived sheaf-cobra-yaml/gh_repo_list.yaml:1
gh repo list --source sheaf-cobra-yaml/gh_repo_list.yaml:1
gh repo list --visibility sheaf-cobra-yaml/gh_repo_list.yaml:1
gh ruleset list --limit sheaf-cobra-yaml/gh_ruleset_list.yaml:1
gh ruleset view --parents sheaf-cobra-yaml/gh_ruleset_view.yaml:1
gh run list --created sheaf-cobra-yaml/gh_run_list.yaml:1
gh run list --workflow sheaf-cobra-yaml/gh_run_list.yaml:1
gh run rerun --failed sheaf-cobra-yaml/gh_run_rerun.yaml:1
gh run view --log-failed sheaf-cobra-yaml/gh_run_view.yaml:1
gh run watch --exit-status sheaf-cobra-yaml/gh_run_watch.yaml:1
gh search commits --limit sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search commits --order sheaf-cobra-yaml/gh_search_commits.yaml:1
gh search issues --author sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --limit sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search issues --order sheaf-cobra-yaml/gh_search_issues.yaml:1
gh search prs --author sheaf-cobra-yaml/gh_search_prs.yaml:1
gh search repos --limit sheaf-cobra-yaml/gh_search_repos.yaml:1
gh search repos --order sheaf-cobra-yaml/gh_search_repos.yaml:1
gh workflow list --limit sheaf-cobra-yaml/gh_workflow_list.yaml:1

Depth

Coverage counts the docs that exist; depth weighs what they actually say — from full behavioral prose down to a bare signature stub.

Full
100%
Brief
0%
Stub
0%
None
0%

Lag

i
Per-element doc-lag isn’t available here: no (element → doc) pair resolved a git commit on both sides — the contract or its reference docs aren’t tracked in this repo’s own history. Cross-repo guide staleness is measured instead — see Guide freshness below: 0 of 48 need review.

Evidence

5
REPLACE THE STUB Signature-only — documented in name only
gh co
gh co --branch
gh co --detach
gh co --force
gh co --recurse-submodules
245
ADD AN EXAMPLE No runnable example
gh agent-task create --repo
gh agent-task list --limit
gh agent-task list --web
gh agent-task view --follow
gh agent-task view --log
gh alias
gh alias set --clobber
gh api --cache
gh api --hostname
gh api --silent
gh api --verbose
gh attestation
gh attestation download --digest-alg
gh attestation download --limit
gh attestation verify --bundle-from-oci
gh attestation verify --cert-identity
gh attestation verify --cert-identity-regex
gh attestation verify --digest-alg
gh attestation verify --hostname
gh attestation verify --limit
gh attestation verify --predicate-type
gh auth login --insecure-storage
gh auth login --scopes
gh auth login --skip-ssh-key
gh auth refresh --insecure-storage
gh auth token --hostname
gh auth token --user
gh browse --actions
gh browse --no-browser
gh browse --projects
gh browse --releases
gh browse --wiki
gh cache list --limit
gh codespace create --default-permissions
gh codespace create --display-name
gh codespace create --idle-timeout
gh codespace create --retention-period
gh codespace create --web
gh codespace edit --codespace
gh codespace edit --display-name
gh codespace edit --machine
gh codespace list --limit
gh codespace list --org
gh codespace list --repo
gh codespace list --user
gh codespace list --web
gh config get --host
gh config list --host
gh extension
gh gist delete --yes
gh gist list --limit
gh gist list --public
gh gist view --files
gh gpg-key delete --yes
gh issue comment --body-file
gh issue comment --create-if-none
gh issue comment --delete-last
gh issue comment --edit-last
gh issue comment --editor
gh issue comment --web
gh issue comment --yes
gh issue create --editor
gh issue create --recover
gh issue create --web
gh issue develop --name
gh issue list --app
gh issue list --limit
gh issue list --mention
gh issue lock --reason
gh issue reopen --comment
gh issue view --comments
gh label delete --yes
gh label list --json
gh label list --limit
gh label list --order
gh label list --web
gh pr checkout --branch
gh pr checkout --detach
gh pr checkout --force
gh pr checkout --recurse-submodules
gh pr checks --fail-fast
gh pr checks --interval
gh pr checks --json
gh pr checks --required
gh pr checks --watch
gh pr close --comment
gh pr comment --body-file
gh pr comment --create-if-none
gh pr comment --delete-last
gh pr comment --edit-last
gh pr comment --editor
gh pr comment --web
gh pr comment --yes
gh pr create --body-file
gh pr create --dry-run
gh pr create --editor
gh pr create --fill
gh pr create --fill-first
gh pr create --web
gh pr diff --color
gh pr diff --web
gh pr edit --base
gh pr list --draft
gh pr list --limit
gh pr list --web
gh pr merge --admin
gh pr merge --author-email
gh pr merge --body
gh pr merge --body-file
gh pr merge --delete-branch
gh pr merge --match-head-commit
gh pr merge --merge
gh pr merge --rebase
gh pr merge --squash
gh pr ready --undo
gh pr reopen --comment
gh pr revert --body
gh pr revert --draft
gh pr revert --title
gh pr review --body
gh pr review --body-file
gh pr review --request-changes
gh pr view --comments
gh preview
gh project close --format
gh project copy --drafts
gh project copy --format
gh project create --format
gh project delete --format
gh project edit --description
gh project edit --format
gh project edit --readme
gh project edit --visibility
gh project list --format
gh project list --web
gh project view --format
gh release create --notes-start-tag
gh release create --target
gh release create --verify-tag
gh release delete --cleanup-tag
gh release download --clobber
gh release download --dir
gh release download --output
gh release download --skip-existing
gh release edit --discussion-category
gh release edit --latest
gh release edit --notes
gh release edit --prerelease
gh release edit --tag
gh release edit --target
gh release edit --title
gh release edit --verify-tag
gh release list --exclude-drafts
gh release list --exclude-pre-releases
gh release list --limit
gh release list --order
gh repo archive --yes
gh repo autolink delete --yes
gh repo autolink list --json
gh repo autolink list --web
gh repo autolink view --json
gh repo clone --upstream-remote-name
gh repo create --gitignore
gh repo create --include-all-branches
gh repo create --internal
gh repo create --license
gh repo create --push
gh repo create --template
gh repo delete --yes
gh repo edit --accept-visibility-change-consequences
gh repo edit --description
gh repo edit --enable-squash-merge
gh repo edit --squash-merge-commit-message
gh repo edit --visibility
gh repo fork --clone
gh repo fork --fork-name
gh repo fork --org
gh repo fork --remote
gh repo fork --remote-name
gh repo list --archived
gh repo list --fork
gh repo list --no-archived
gh repo list --source
gh repo list --topic
gh repo list --visibility
gh repo rename --repo
gh repo rename --yes
gh repo sync --force
gh repo unarchive --yes
gh ruleset check --web
gh ruleset list --limit
gh ruleset list --web
gh ruleset view --parents
gh ruleset view --web
gh run
gh run cancel --force
gh run list --branch
gh run list --created
gh run list --event
gh run list --limit
gh run list --status
gh run list --user
gh run list --workflow
gh run rerun --debug
gh run rerun --failed
gh run rerun --job
gh run view --json
gh run view --log-failed
gh run view --web
gh run watch --exit-status
gh search
gh search code --limit
gh search code --web
gh search commits --limit
gh search commits --order
gh search commits --web
gh search issues --app
gh search issues --author
gh search issues --limit
gh search issues --order
gh search issues --web
gh search prs --app
gh search prs --author
gh search prs --limit
gh search prs --order
gh search prs --web
gh search repos --limit
gh search repos --order
gh search repos --web
gh secret delete --app
gh secret delete --env
gh secret delete --org
gh secret list --app
gh secret list --org
gh ssh-key delete --yes
gh variable delete --env
gh variable delete --org
gh variable get --env
gh variable get --json
gh variable get --org
gh workflow list --all
gh workflow list --limit
gh workflow view --ref
gh workflow view --web
gh workflow view --yaml
585
CITE IT IN A TEST Not named in any test
gh
gh --help
gh --version
gh agent-task create --base
gh agent-task create --custom-agent
gh agent-task create --from-file
gh agent-task list --jq
gh agent-task list --json
gh agent-task list --template
gh agent-task view --jq
gh agent-task view --json
gh agent-task view --repo
gh agent-task view --template
gh agent-task view --web
gh alias import --clobber
gh api --field
gh api --header
gh api --include
gh api --method
gh api --preview
gh api --raw-field
gh attestation download --hostname
gh attestation download --predicate-type
gh attestation trusted-root --hostname
gh attestation trusted-root --tuf-root
gh attestation trusted-root --tuf-url
gh attestation trusted-root --verify-only
gh attestation verify --cert-oidc-issuer
gh attestation verify --custom-trusted-root
gh attestation verify --deny-self-hosted-runners
gh attestation verify --jq
gh attestation verify --no-public-good
gh attestation verify --signer-digest
gh attestation verify --signer-repo
gh attestation verify --signer-workflow
gh attestation verify --source-digest
gh attestation verify --source-ref
gh attestation verify --template
gh auth
gh auth login --git-protocol
gh auth refresh --clipboard
gh auth refresh --hostname
gh auth setup-git --force
gh auth setup-git --hostname
gh auth status --jq
gh auth status --json
gh auth status --template
gh browse --repo
gh cache
gh cache --repo
gh cache list --jq
gh cache list --json
gh cache list --template
gh codespace
gh codespace code --codespace
gh codespace code --insiders
gh codespace code --repo
gh codespace code --repo-owner
gh codespace code --web
gh codespace cp
gh codespace cp --codespace
gh codespace cp --expand
gh codespace cp --profile
gh codespace cp --recursive
gh codespace cp --repo
gh codespace cp --repo-owner
gh codespace create --branch
gh codespace create --devcontainer-path
gh codespace create --location
gh codespace create --machine
gh codespace create --repo
gh codespace create --status
gh codespace delete --all
gh codespace delete --codespace
gh codespace delete --days
gh codespace delete --force
gh codespace delete --org
gh codespace delete --repo
gh codespace delete --repo-owner
gh codespace delete --user
gh codespace edit --repo
gh codespace edit --repo-owner
gh codespace jupyter
gh codespace jupyter --codespace
gh codespace jupyter --repo
gh codespace jupyter --repo-owner
gh codespace list --jq
gh codespace list --json
gh codespace list --template
gh codespace logs --codespace
gh codespace logs --follow
gh codespace logs --repo
gh codespace logs --repo-owner
gh codespace ports --codespace
gh codespace ports --jq
gh codespace ports --json
gh codespace ports --repo
gh codespace ports --repo-owner
gh codespace ports --template
gh codespace ports forward
gh codespace ports visibility
gh codespace rebuild --codespace
gh codespace rebuild --full
gh codespace rebuild --repo
gh codespace rebuild --repo-owner
gh codespace ssh --codespace
gh codespace ssh --config
gh codespace ssh --debug
gh codespace ssh --debug-file
gh codespace ssh --profile
gh codespace ssh --repo
gh codespace ssh --repo-owner
gh codespace ssh --server-port
gh codespace stop --codespace
gh codespace stop --org
gh codespace stop --repo
gh codespace stop --repo-owner
gh codespace stop --user
gh codespace view --codespace
gh codespace view --jq
gh codespace view --json
gh codespace view --repo
gh codespace view --repo-owner
gh codespace view --template
gh completion --shell
gh config
gh extension browse --debug
gh extension browse --single-column
gh extension create
gh extension create --precompiled
gh extension install
gh extension install --force
gh extension install --pin
gh extension list
gh extension remove
gh extension search
gh extension search --jq
gh extension search --json
gh extension search --license
gh extension search --limit
gh extension search --order
gh extension search --owner
gh extension search --sort
gh extension search --template
gh extension search --web
gh extension upgrade
gh extension upgrade --all
gh extension upgrade --dry-run
gh extension upgrade --force
gh gist
gh gist create --desc
gh gist create --filename
gh gist create --public
gh gist create --web
gh gist edit --desc
gh gist view --filename
gh gist view --raw
gh gist view --web
gh gpg-key
gh gpg-key add --title
gh issue
gh issue --repo
gh issue create --assignee
gh issue create --body
gh issue create --body-file
gh issue create --label
gh issue create --milestone
gh issue create --project
gh issue create --template
gh issue create --title
gh issue delete --yes
gh issue list --assignee
gh issue list --author
gh issue list --jq
gh issue list --json
gh issue list --label
gh issue list --milestone
gh issue list --search
gh issue list --state
gh issue list --template
gh issue list --web
gh issue status --jq
gh issue status --json
gh issue status --template
gh issue unlock
gh issue view --jq
gh issue view --json
gh issue view --template
gh issue view --web
gh label
gh label --repo
gh label create --force
gh label list --jq
gh label list --template
gh licenses
gh org
gh org list --limit
gh pr
gh pr --repo
gh pr checks --jq
gh pr checks --template
gh pr checks --web
gh pr close --delete-branch
gh pr create --assignee
gh pr create --draft
gh pr create --fill-verbose
gh pr create --label
gh pr create --milestone
gh pr create --no-maintainer-edit
gh pr create --project
gh pr create --recover
gh pr create --reviewer
gh pr diff --patch
gh pr list --app
gh pr list --assignee
gh pr list --author
gh pr list --base
gh pr list --head
gh pr list --jq
gh pr list --json
gh pr list --label
gh pr list --search
gh pr list --state
gh pr list --template
gh pr lock
gh pr lock --reason
gh pr merge --auto
gh pr merge --disable-auto
gh pr merge --subject
gh pr revert --body-file
gh pr status --conflict-status
gh pr status --jq
gh pr status --json
gh pr status --template
gh pr unlock
gh pr view --jq
gh pr view --json
gh pr view --template
gh pr view --web
gh preview prompter
gh project
gh project close --jq
gh project close --template
gh project copy --jq
gh project copy --template
gh project create --jq
gh project create --template
gh project delete --jq
gh project delete --template
gh project edit --jq
gh project edit --template
gh project field-create --data-type
gh project field-create --format
gh project field-create --jq
gh project field-create --name
gh project field-create --owner
gh project field-create --single-select-options
gh project field-create --template
gh project field-delete --format
gh project field-delete --id
gh project field-delete --jq
gh project field-delete --template
gh project field-list --format
gh project field-list --jq
gh project field-list --limit
gh project field-list --owner
gh project field-list --template
gh project item-add --format
gh project item-add --jq
gh project item-add --owner
gh project item-add --template
gh project item-add --url
gh project item-archive --format
gh project item-archive --id
gh project item-archive --jq
gh project item-archive --owner
gh project item-archive --template
gh project item-archive --undo
gh project item-create --body
gh project item-create --format
gh project item-create --jq
gh project item-create --owner
gh project item-create --template
gh project item-create --title
gh project item-delete --format
gh project item-delete --id
gh project item-delete --jq
gh project item-delete --owner
gh project item-delete --template
gh project item-edit --body
gh project item-edit --clear
gh project item-edit --date
gh project item-edit --field-id
gh project item-edit --format
gh project item-edit --id
gh project item-edit --iteration-id
gh project item-edit --jq
gh project item-edit --number
gh project item-edit --project-id
gh project item-edit --single-select-option-id
gh project item-edit --template
gh project item-edit --text
gh project item-edit --title
gh project item-list --format
gh project item-list --jq
gh project item-list --limit
gh project item-list --owner
gh project item-list --query
gh project item-list --template
gh project list --jq
gh project list --limit
gh project list --template
gh project view --jq
gh project view --template
gh release
gh release --repo
gh release create --draft
gh release create --notes
gh release create --notes-file
gh release create --prerelease
gh release create --title
gh release delete --yes
gh release delete-asset --yes
gh release edit --notes-file
gh release list --jq
gh release list --json
gh release list --template
gh release upload --clobber
gh release verify --format
gh release verify --jq
gh release verify --template
gh release verify-asset --format
gh release verify-asset --jq
gh release verify-asset --template
gh release view --jq
gh release view --json
gh release view --template
gh release view --web
gh repo autolink
gh repo autolink --repo
gh repo autolink list --jq
gh repo autolink list --template
gh repo autolink view --jq
gh repo autolink view --template
gh repo create --add-readme
gh repo create --description
gh repo create --disable-issues
gh repo create --disable-wiki
gh repo create --homepage
gh repo create --team
gh repo deploy-key
gh repo deploy-key --repo
gh repo deploy-key add --allow-write
gh repo deploy-key add --title
gh repo deploy-key list --jq
gh repo deploy-key list --json
gh repo deploy-key list --template
gh repo edit --add-topic
gh repo edit --allow-forking
gh repo edit --allow-update-branch
gh repo edit --default-branch
gh repo edit --delete-branch-on-merge
gh repo edit --enable-advanced-security
gh repo edit --enable-auto-merge
gh repo edit --enable-discussions
gh repo edit --enable-issues
gh repo edit --enable-merge-commit
gh repo edit --enable-projects
gh repo edit --enable-rebase-merge
gh repo edit --enable-secret-scanning
gh repo edit --enable-secret-scanning-push-protection
gh repo edit --enable-wiki
gh repo edit --homepage
gh repo edit --remove-topic
gh repo edit --template
gh repo fork --default-branch-only
gh repo gitignore
gh repo license
gh repo license view --web
gh repo list --jq
gh repo list --json
gh repo list --language
gh repo list --limit
gh repo list --template
gh repo set-default --unset
gh repo set-default --view
gh repo view --branch
gh repo view --jq
gh repo view --json
gh repo view --template
gh repo view --web
gh ruleset
gh ruleset --repo
gh run --repo
gh run download --dir
gh run download --name
gh run download --pattern
gh run list --all
gh run list --commit
gh run list --jq
gh run list --json
gh run list --template
gh run view --jq
gh run view --template
gh run view --verbose
gh run watch --interval
gh search code --extension
gh search code --filename
gh search code --jq
gh search code --json
gh search code --language
gh search code --match
gh search code --owner
gh search code --repo
gh search code --size
gh search code --template
gh search commits --author
gh search commits --author-date
gh search commits --author-email
gh search commits --author-name
gh search commits --committer
gh search commits --committer-date
gh search commits --committer-email
gh search commits --committer-name
gh search commits --hash
gh search commits --jq
gh search commits --json
gh search commits --merge
gh search commits --owner
gh search commits --parent
gh search commits --repo
gh search commits --sort
gh search commits --template
gh search commits --tree
gh search commits --visibility
gh search issues --archived
gh search issues --assignee
gh search issues --closed
gh search issues --commenter
gh search issues --comments
gh search issues --created
gh search issues --interactions
gh search issues --involves
gh search issues --jq
gh search issues --json
gh search issues --label
gh search issues --language
gh search issues --locked
gh search issues --match
gh search issues --mentions
gh search issues --milestone
gh search issues --no-assignee
gh search issues --no-label
gh search issues --no-milestone
gh search issues --no-project
gh search issues --owner
gh search issues --project
gh search issues --reactions
gh search issues --repo
gh search issues --sort
gh search issues --state
gh search issues --team-mentions
gh search issues --template
gh search issues --updated
gh search issues --visibility
gh search prs --archived
gh search prs --assignee
gh search prs --base
gh search prs --checks
gh search prs --closed
gh search prs --commenter
gh search prs --comments
gh search prs --created
gh search prs --draft
gh search prs --head
gh search prs --interactions
gh search prs --involves
gh search prs --jq
gh search prs --json
gh search prs --label
gh search prs --language
gh search prs --locked
gh search prs --match
gh search prs --mentions
gh search prs --merged
gh search prs --merged-at
gh search prs --milestone
gh search prs --no-assignee
gh search prs --no-label
gh search prs --no-milestone
gh search prs --no-project
gh search prs --owner
gh search prs --project
gh search prs --reactions
gh search prs --repo
gh search prs --review
gh search prs --reviewed-by
gh search prs --sort
gh search prs --state
gh search prs --team-mentions
gh search prs --template
gh search prs --updated
gh search prs --visibility
gh search repos --archived
gh search repos --created
gh search repos --followers
gh search repos --forks
gh search repos --good-first-issues
gh search repos --help-wanted-issues
gh search repos --include-forks
gh search repos --jq
gh search repos --json
gh search repos --language
gh search repos --license
gh search repos --match
gh search repos --number-topics
gh search repos --owner
gh search repos --size
gh search repos --sort
gh search repos --stars
gh search repos --template
gh search repos --topic
gh search repos --updated
gh search repos --visibility
gh secret
gh secret --repo
gh secret delete --user
gh secret list --env
gh secret list --jq
gh secret list --json
gh secret list --template
gh secret list --user
gh secret set --env
gh secret set --env-file
gh secret set --no-store
gh skill
gh skill install --agent
gh skill install --allow-hidden-dirs
gh skill install --dir
gh skill install --force
gh skill install --from-local
gh skill install --pin
gh skill install --scope
gh skill install --upstream
gh skill preview --allow-hidden-dirs
gh skill publish --dry-run
gh skill publish --fix
gh skill publish --tag
gh skill search --jq
gh skill search --json
gh skill search --limit
gh skill search --owner
gh skill search --page
gh skill search --template
gh skill update --all
gh skill update --dir
gh skill update --dry-run
gh skill update --force
gh skill update --unpin
gh ssh-key
gh ssh-key add --title
gh ssh-key add --type
gh status --exclude
gh status --org
gh variable
gh variable --repo
gh variable get --jq
gh variable get --template
gh variable list --env
gh variable list --jq
gh variable list --json
gh variable list --org
gh variable list --template
gh variable set --body
gh variable set --env
gh variable set --env-file
gh variable set --repos
gh variable set --visibility
gh workflow
gh workflow --repo
gh workflow list --jq
gh workflow list --json
gh workflow list --template
gh workflow run --field
gh workflow run --raw-field
328
Bridged
gh agent-task
gh agent-task create
gh agent-task create --follow
gh agent-task list
gh agent-task view
gh alias delete
gh alias delete --all
gh alias import
gh alias list
gh alias set
gh alias set --shell
gh api
gh api --input
gh api --jq
gh api --paginate
gh api --slurp
gh api --template
gh attestation download
gh attestation download --owner
gh attestation download --repo
gh attestation trusted-root
gh attestation verify
gh attestation verify --bundle
gh attestation verify --format
gh attestation verify --owner
gh attestation verify --repo
gh auth login
gh auth login --clipboard
gh auth login --hostname
gh auth login --web
gh auth login --with-token
gh auth logout
gh auth logout --hostname
gh auth logout --user
gh auth refresh
gh auth refresh --remove-scopes
gh auth refresh --reset-scopes
gh auth refresh --scopes
gh auth setup-git
gh auth status
gh auth status --active
gh auth status --hostname
gh auth status --show-token
gh auth switch
gh auth switch --hostname
gh auth switch --user
gh auth token
gh browse
gh browse --blame
gh browse --branch
gh browse --commit
gh browse --settings
gh cache delete
gh cache delete --all
gh cache delete --ref
gh cache delete --succeed-on-no-caches
gh cache list
gh cache list --key
gh cache list --order
gh cache list --ref
gh cache list --sort
gh codespace code
gh codespace create
gh codespace delete
gh codespace edit
gh codespace list
gh codespace logs
gh codespace ports
gh codespace rebuild
gh codespace ssh
gh codespace stop
gh codespace view
gh completion
gh config clear-cache
gh config get
gh config list
gh config set
gh config set --host
gh copilot
gh copilot --remove
gh extension browse
gh gist clone
gh gist create
gh gist delete
gh gist edit
gh gist edit --add
gh gist edit --filename
gh gist edit --remove
gh gist list
gh gist list --filter
gh gist list --include-content
gh gist list --secret
gh gist rename
gh gist view
gh gpg-key add
gh gpg-key delete
gh gpg-key list
gh issue close
gh issue close --comment
gh issue close --duplicate-of
gh issue close --reason
gh issue comment
gh issue comment --body
gh issue create
gh issue delete
gh issue develop
gh issue develop --base
gh issue develop --branch-repo
gh issue develop --checkout
gh issue develop --list
gh issue edit
gh issue edit --add-assignee
gh issue edit --add-label
gh issue edit --add-project
gh issue edit --body
gh issue edit --body-file
gh issue edit --milestone
gh issue edit --remove-assignee
gh issue edit --remove-label
gh issue edit --remove-milestone
gh issue edit --remove-project
gh issue edit --title
gh issue list
gh issue lock
gh issue pin
gh issue reopen
gh issue status
gh issue transfer
gh issue unpin
gh issue view
gh label clone
gh label clone --force
gh label create
gh label create --color
gh label create --description
gh label delete
gh label edit
gh label edit --color
gh label edit --description
gh label edit --name
gh label list
gh label list --search
gh label list --sort
gh org list
gh pr checkout
gh pr checks
gh pr close
gh pr comment
gh pr comment --body
gh pr create
gh pr create --base
gh pr create --body
gh pr create --head
gh pr create --template
gh pr create --title
gh pr diff
gh pr diff --exclude
gh pr diff --name-only
gh pr edit
gh pr edit --add-assignee
gh pr edit --add-label
gh pr edit --add-project
gh pr edit --add-reviewer
gh pr edit --body
gh pr edit --body-file
gh pr edit --milestone
gh pr edit --remove-assignee
gh pr edit --remove-label
gh pr edit --remove-milestone
gh pr edit --remove-project
gh pr edit --remove-reviewer
gh pr edit --title
gh pr list
gh pr merge
gh pr ready
gh pr reopen
gh pr revert
gh pr review
gh pr review --approve
gh pr review --comment
gh pr status
gh pr view
gh project close
gh project close --owner
gh project close --undo
gh project copy
gh project copy --source-owner
gh project copy --target-owner
gh project copy --title
gh project create
gh project create --owner
gh project create --title
gh project delete
gh project delete --owner
gh project edit
gh project edit --owner
gh project edit --title
gh project field-create
gh project field-delete
gh project field-list
gh project item-add
gh project item-archive
gh project item-create
gh project item-delete
gh project item-edit
gh project item-list
gh project link
gh project link --owner
gh project link --repo
gh project link --team
gh project list
gh project list --closed
gh project list --owner
gh project unlink
gh project unlink --owner
gh project unlink --repo
gh project unlink --team
gh project view
gh project view --owner
gh project view --web
gh release create
gh release create --discussion-category
gh release create --fail-on-no-commits
gh release create --generate-notes
gh release create --latest
gh release create --notes-from-tag
gh release delete
gh release delete-asset
gh release download
gh release download --archive
gh release download --pattern
gh release edit
gh release edit --draft
gh release list
gh release upload
gh release verify
gh release verify-asset
gh release view
gh repo
gh repo archive
gh repo autolink create
gh repo autolink create --numeric
gh repo autolink delete
gh repo autolink list
gh repo autolink view
gh repo clone
gh repo clone --no-upstream
gh repo create
gh repo create --clone
gh repo create --private
gh repo create --public
gh repo create --remote
gh repo create --source
gh repo delete
gh repo deploy-key add
gh repo deploy-key delete
gh repo deploy-key list
gh repo edit
gh repo fork
gh repo gitignore list
gh repo gitignore view
gh repo license list
gh repo license view
gh repo list
gh repo rename
gh repo set-default
gh repo sync
gh repo sync --branch
gh repo sync --source
gh repo unarchive
gh repo view
gh ruleset check
gh ruleset check --default
gh ruleset list
gh ruleset list --org
gh ruleset list --parents
gh ruleset view
gh ruleset view --org
gh run cancel
gh run delete
gh run download
gh run list
gh run rerun
gh run view
gh run view --attempt
gh run view --exit-status
gh run view --job
gh run view --log
gh run watch
gh run watch --compact
gh search code
gh search commits
gh search issues
gh search issues --include-prs
gh search prs
gh search prs --review-requested
gh search repos
gh secret delete
gh secret list
gh secret set
gh secret set --app
gh secret set --body
gh secret set --no-repos-selected
gh secret set --org
gh secret set --repos
gh secret set --user
gh secret set --visibility
gh skill install
gh skill preview
gh skill publish
gh skill search
gh skill update
gh ssh-key add
gh ssh-key delete
gh ssh-key list
gh status
gh variable delete
gh variable get
gh variable list
gh variable set
gh variable set --org
gh workflow disable
gh workflow enable
gh workflow list
gh workflow run
gh workflow run --json
gh workflow run --ref
gh workflow view
+ 298 more (use a filter or search to surface them)
CONTRACT
command: gh
short: Work seamlessly with GitHub from the command line.
options:
    - option: help
      value_type: bool
      default_value: "false"
      description: Show help for command
    - option: version
      value_type: bool
      default_value: "false"
      description: Show gh version
DOCS
gh.md:1Markdown · 114 words
TESTS

N/A

EXAMPLES
gh.md:66Markdown
WORKFLOWS

N/A

CONTRACT
command: gh
short: Work seamlessly with GitHub from the command line.
options:
    - option: help
      value_type: bool
      default_value: "false"
      description: Show help for command
    - option: version
      value_type: bool
      default_value: "false"
      description: Show gh version
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh
short: Work seamlessly with GitHub from the command line.
options:
    - option: help
      value_type: bool
      default_value: "false"
      description: Show help for command
    - option: version
      value_type: bool
      default_value: "false"
      description: Show gh version
DOCS
gh.md:59Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task
short: Working with agent tasks in the GitHub CLI is in preview and
long: subject to change without notice.
pname: gh
plink: gh.yaml
DOCS
gh_agent-task.md:1Markdown · 45 words
TESTS
pkg/cmd/agent-task/agent_task_test.go:35pkg/cmd/agent-task/agent_task_test::TestNewCmdAgentTask · Go · 104 lines
func TestNewCmdAgentTask(t *testing.T) {
	tests := []struct {
		name            string
		tokenSource     string
		customConfig    func() (gh.Config, error)
		wantErr         bool
		wantErrContains string
		wantStdout      string
	}{
		{
			name:        "oauth token is accepted",
			tokenSource: "oauth_token",
			wantErr:     false,
			wantStdout:  "",
		},
		{
			name:        "keyring oauth token is accepted",
			tokenSource: "keyring",
			wantErr:     false,
			wantStdout:  "",
		},
		{
			name:            "env var token is rejected",
			tokenSource:     "GH_TOKEN",
			wantErr:         true,
			wantErrContains: "requires an OAuth token",
		},
		{
			name:        "enterprise token alone is ignored and rejected",
			tokenSource: "GH_ENTERPRISE_TOKEN",
+ 74 more lines · read full file
pkg/cmd/agent-task/agent_task_test.go:140pkg/cmd/agent-task/agent_task_test::TestAliasAreSet · Go · 10 lines
func TestAliasAreSet(t *testing.T) {
	f := &cmdutil.Factory{}
	ios, _, _, _ := iostreams.Test()
	f.IOStreams = ios
	f.Config = func() (gh.Config, error) { return setupMockOAuthConfig(t, "oauth_token"), nil }

	cmd := NewCmdAgentTask(f)

	require.ElementsMatch(t, []string{"agent-tasks", "agent", "agents"}, cmd.Aliases)
}
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh agent-task create
short: Create an agent task (preview)
DOCS
gh_agent-task_create.md:1Markdown · 15 words
TESTS
pkg/cmd/agent-task/create/create_test.go:25pkg/cmd/agent-task/create/create_test::TestNewCmdCreate · Go · 102 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		tty      bool
		wantOpts *CreateOptions
		wantErr  string
	}{
		{
			name: "no args nor file returns no error (prompting path)",
			tty:  true,
			wantOpts: &CreateOptions{
				ProblemStatement:     "",
				ProblemStatementFile: "",
			},
		},
		{
			name: "arg only success",
			args: "'task description from args'",
			wantOpts: &CreateOptions{
				ProblemStatement:     "task description from args",
				ProblemStatementFile: "",
			},
		},
		{
			name:    "empty arg",
			args:    "''",
			wantErr: "task description cannot be empty",
		},
		{
+ 72 more lines · read full file
pkg/cmd/agent-task/create/create_test.go:128pkg/cmd/agent-task/create/create_test::Test_createRun · Go · 416 lines
func Test_createRun(t *testing.T) {
	tmpDir := t.TempDir()
	taskDescFile := filepath.Join(tmpDir, "task-description.md")
	emptyTaskDescFile := filepath.Join(tmpDir, "empty-task-description.md")
	require.NoError(t, os.WriteFile(taskDescFile, []byte("task description from file"), 0600))
	require.NoError(t, os.WriteFile(emptyTaskDescFile, []byte("  \n\n"), 0600))

	sampleDateString := "2025-08-29T00:00:00Z"
	sampleDate, err := time.Parse(time.RFC3339, sampleDateString)
	require.NoError(t, err)

	createdJobSuccess := capi.Job{
		ID:        "job123",
		SessionID: "sess1",
		Actor: &capi.JobActor{
			ID:    1,
			Login: "octocat",
		},
		CreatedAt: sampleDate,
		UpdatedAt: sampleDate,
	}
	createdJobSuccessWithPR := capi.Job{
		ID:        "job123",
		SessionID: "sess1",
		Actor: &capi.JobActor{
			ID:    1,
			Login: "octocat",
		},
		CreatedAt: sampleDate,
		UpdatedAt: sampleDate,
+ 386 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh agent-task create
short: Create an agent task (preview)
DOCS
gh_agent-task_create.md:19Markdown · 12 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh agent-task create
short: Create an agent task (preview)
DOCS
gh_agent-task_create.md:20Markdown · 14 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh agent-task create
short: Create an agent task (preview)
DOCS
gh_agent-task_create.md:21Markdown · 4 words
TESTS
pkg/cmd/agent-task/create/create_test.go:25pkg/cmd/agent-task/create/create_test::TestNewCmdCreate · Go · 102 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		tty      bool
		wantOpts *CreateOptions
		wantErr  string
	}{
		{
			name: "no args nor file returns no error (prompting path)",
			tty:  true,
			wantOpts: &CreateOptions{
				ProblemStatement:     "",
				ProblemStatementFile: "",
			},
		},
		{
			name: "arg only success",
			args: "'task description from args'",
			wantOpts: &CreateOptions{
				ProblemStatement:     "task description from args",
				ProblemStatementFile: "",
			},
		},
		{
			name:    "empty arg",
			args:    "''",
			wantErr: "task description cannot be empty",
		},
		{
+ 72 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh agent-task create
short: Create an agent task (preview)
DOCS
gh_agent-task_create.md:22Markdown · 12 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task create
short: Create an agent task (preview)
DOCS
gh_agent-task_create.md:23Markdown · 7 words
TESTS
pkg/cmd/agent-task/create/create_test.go:128pkg/cmd/agent-task/create/create_test::Test_createRun · Go · 416 lines
func Test_createRun(t *testing.T) {
	tmpDir := t.TempDir()
	taskDescFile := filepath.Join(tmpDir, "task-description.md")
	emptyTaskDescFile := filepath.Join(tmpDir, "empty-task-description.md")
	require.NoError(t, os.WriteFile(taskDescFile, []byte("task description from file"), 0600))
	require.NoError(t, os.WriteFile(emptyTaskDescFile, []byte("  \n\n"), 0600))

	sampleDateString := "2025-08-29T00:00:00Z"
	sampleDate, err := time.Parse(time.RFC3339, sampleDateString)
	require.NoError(t, err)

	createdJobSuccess := capi.Job{
		ID:        "job123",
		SessionID: "sess1",
		Actor: &capi.JobActor{
			ID:    1,
			Login: "octocat",
		},
		CreatedAt: sampleDate,
		UpdatedAt: sampleDate,
	}
	createdJobSuccessWithPR := capi.Job{
		ID:        "job123",
		SessionID: "sess1",
		Actor: &capi.JobActor{
			ID:    1,
			Login: "octocat",
		},
		CreatedAt: sampleDate,
		UpdatedAt: sampleDate,
+ 386 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task list
short: List agent tasks (preview)
DOCS
gh_agent-task_list.md:1Markdown · 27 words
TESTS
pkg/cmd/agent-task/list/list_test.go:21pkg/cmd/agent-task/list/list_test::TestNewCmdList · Go · 70 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantOpts ListOptions
		wantErr  string
	}{
		{
			name: "no arguments",
			wantOpts: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "custom limit",
			args: "--limit 15",
			wantOpts: ListOptions{
				Limit: 15,
			},
		},
		{
			name:    "invalid limit",
			args:    "--limit 0",
			wantErr: "invalid limit: 0",
		},
		{
			name:    "negative limit",
			args:    "--limit -5",
			wantErr: "invalid limit: -5",
		},
+ 40 more lines · read full file
pkg/cmd/agent-task/list/list_test.go:92pkg/cmd/agent-task/list/list_test::Test_listRun · Go · 312 lines
func Test_listRun(t *testing.T) {
	sampleDate := time.Now().Add(-6 * time.Hour) // 6h ago
	sampleDateString := sampleDate.Format(time.RFC3339)

	tests := []struct {
		name           string
		tty            bool
		capiStubs      func(*testing.T, *capi.CapiClientMock)
		limit          int
		web            bool
		jsonFields     []string
		wantOut        string
		wantErr        error
		wantStderr     string
		wantBrowserURL string
	}{
		{
			name: "viewer-scoped no sessions",
			tty:  true,
			capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
				m.ListLatestSessionsForViewerFunc = func(ctx context.Context, limit int) ([]*capi.Session, error) {
					return nil, nil
				}
			},
			wantErr: cmdutil.NewNoResultsError("no agent tasks found"),
		},
		{
			name:  "viewer-scoped respects --limit",
			tty:   true,
			limit: 999,
+ 282 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh agent-task list
short: List agent tasks (preview)
DOCS
gh_agent-task_list.md:19Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task list
short: List agent tasks (preview)
DOCS
gh_agent-task_list.md:20Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task list
short: List agent tasks (preview)
DOCS
gh_agent-task_list.md:21Markdown · 7 words
TESTS
pkg/cmd/agent-task/list/list_test.go:21pkg/cmd/agent-task/list/list_test::TestNewCmdList · Go · 70 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantOpts ListOptions
		wantErr  string
	}{
		{
			name: "no arguments",
			wantOpts: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "custom limit",
			args: "--limit 15",
			wantOpts: ListOptions{
				Limit: 15,
			},
		},
		{
			name:    "invalid limit",
			args:    "--limit 0",
			wantErr: "invalid limit: 0",
		},
		{
			name:    "negative limit",
			args:    "--limit -5",
			wantErr: "invalid limit: -5",
		},
+ 40 more lines · read full file
pkg/cmd/agent-task/list/list_test.go:92pkg/cmd/agent-task/list/list_test::Test_listRun · Go · 312 lines
func Test_listRun(t *testing.T) {
	sampleDate := time.Now().Add(-6 * time.Hour) // 6h ago
	sampleDateString := sampleDate.Format(time.RFC3339)

	tests := []struct {
		name           string
		tty            bool
		capiStubs      func(*testing.T, *capi.CapiClientMock)
		limit          int
		web            bool
		jsonFields     []string
		wantOut        string
		wantErr        error
		wantStderr     string
		wantBrowserURL string
	}{
		{
			name: "viewer-scoped no sessions",
			tty:  true,
			capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
				m.ListLatestSessionsForViewerFunc = func(ctx context.Context, limit int) ([]*capi.Session, error) {
					return nil, nil
				}
			},
			wantErr: cmdutil.NewNoResultsError("no agent tasks found"),
		},
		{
			name:  "viewer-scoped respects --limit",
			tty:   true,
			limit: 999,
+ 282 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task list
short: List agent tasks (preview)
DOCS
gh_agent-task_list.md:22Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task list
short: List agent tasks (preview)
DOCS
gh_agent-task_list.md:23Markdown · 6 words
TESTS
pkg/cmd/agent-task/list/list_test.go:21pkg/cmd/agent-task/list/list_test::TestNewCmdList · Go · 70 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantOpts ListOptions
		wantErr  string
	}{
		{
			name: "no arguments",
			wantOpts: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "custom limit",
			args: "--limit 15",
			wantOpts: ListOptions{
				Limit: 15,
			},
		},
		{
			name:    "invalid limit",
			args:    "--limit 0",
			wantErr: "invalid limit: 0",
		},
		{
			name:    "negative limit",
			args:    "--limit -5",
			wantErr: "invalid limit: -5",
		},
+ 40 more lines · read full file
pkg/cmd/agent-task/list/list_test.go:92pkg/cmd/agent-task/list/list_test::Test_listRun · Go · 312 lines
func Test_listRun(t *testing.T) {
	sampleDate := time.Now().Add(-6 * time.Hour) // 6h ago
	sampleDateString := sampleDate.Format(time.RFC3339)

	tests := []struct {
		name           string
		tty            bool
		capiStubs      func(*testing.T, *capi.CapiClientMock)
		limit          int
		web            bool
		jsonFields     []string
		wantOut        string
		wantErr        error
		wantStderr     string
		wantBrowserURL string
	}{
		{
			name: "viewer-scoped no sessions",
			tty:  true,
			capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
				m.ListLatestSessionsForViewerFunc = func(ctx context.Context, limit int) ([]*capi.Session, error) {
					return nil, nil
				}
			},
			wantErr: cmdutil.NewNoResultsError("no agent tasks found"),
		},
		{
			name:  "viewer-scoped respects --limit",
			tty:   true,
			limit: 999,
+ 282 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task view
short: View an agent task session.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh agent-task
plink: gh_agent-task.yaml
options:
    - option: follow
      value_type: bool
      default_value: "false"
      description: Follow agent session logs
    - option: jq
      shorthand: q
DOCS
gh_agent-task_view.md:1Markdown · 29 words
TESTS
pkg/cmd/agent-task/view/view_test.go:26pkg/cmd/agent-task/view/view_test::TestNewCmdList · Go · 133 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name         string
		tty          bool
		args         string
		wantOpts     ViewOptions
		wantBaseRepo ghrepo.Interface
		wantErr      string
	}{
		{
			name:     "no arg tty",
			tty:      true,
			args:     "",
			wantOpts: ViewOptions{},
		},
		{
			name: "session ID arg tty",
			tty:  true,
			args: "00000000-0000-0000-0000-000000000000",
			wantOpts: ViewOptions{
				SelectorArg: "00000000-0000-0000-0000-000000000000",
				SessionID:   "00000000-0000-0000-0000-000000000000",
			},
		},
		{
			name: "PR agent-session URL arg tty",
			tty:  true,
			args: "https://github.com/OWNER/REPO/pull/101/agent-sessions/00000000-0000-0000-0000-000000000000",
			wantOpts: ViewOptions{
				SelectorArg: "https://github.com/OWNER/REPO/pull/101/agent-sessions/00000000-0000-0000-0000-000000000000",
+ 103 more lines · read full file
pkg/cmd/agent-task/view/view_test.go:160pkg/cmd/agent-task/view/view_test::Test_viewRun · Go · 1165 lines
func Test_viewRun(t *testing.T) {
	sampleDate := time.Now().Add(-6 * time.Hour) // 6h ago
	sampleCompletedAt := sampleDate.Add(5 * time.Minute)

	tests := []struct {
		name             string
		tty              bool
		opts             ViewOptions
		promptStubs      func(*testing.T, *prompter.MockPrompter)
		capiStubs        func(*testing.T, *capi.CapiClientMock)
		logRendererStubs func(*testing.T, *shared.LogRendererMock)
		jsonFields       []string
		wantOut          string
		wantErr          error
		wantStderr       string
		wantBrowserURL   string
	}{
		{
			name: "with session id, not found (tty)",
			tty:  true,
			opts: ViewOptions{
				SelectorArg: "some-session-id",
				SessionID:   "some-session-id",
			},
			capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
				m.GetSessionFunc = func(_ context.Context, _ string) (*capi.Session, error) {
					return nil, capi.ErrSessionNotFound
				}
			},
			wantStderr: "session not found\n",
+ 1135 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh agent-task view
short: View an agent task session.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh agent-task
plink: gh_agent-task.yaml
options:
    - option: follow
      value_type: bool
      default_value: "false"
      description: Follow agent session logs
    - option: jq
      shorthand: q
DOCS
gh_agent-task_view.md:20Markdown · 4 words
TESTS
pkg/cmd/agent-task/view/view_test.go:26pkg/cmd/agent-task/view/view_test::TestNewCmdList · Go · 133 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name         string
		tty          bool
		args         string
		wantOpts     ViewOptions
		wantBaseRepo ghrepo.Interface
		wantErr      string
	}{
		{
			name:     "no arg tty",
			tty:      true,
			args:     "",
			wantOpts: ViewOptions{},
		},
		{
			name: "session ID arg tty",
			tty:  true,
			args: "00000000-0000-0000-0000-000000000000",
			wantOpts: ViewOptions{
				SelectorArg: "00000000-0000-0000-0000-000000000000",
				SessionID:   "00000000-0000-0000-0000-000000000000",
			},
		},
		{
			name: "PR agent-session URL arg tty",
			tty:  true,
			args: "https://github.com/OWNER/REPO/pull/101/agent-sessions/00000000-0000-0000-0000-000000000000",
			wantOpts: ViewOptions{
				SelectorArg: "https://github.com/OWNER/REPO/pull/101/agent-sessions/00000000-0000-0000-0000-000000000000",
+ 103 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task view
short: View an agent task session.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh agent-task
plink: gh_agent-task.yaml
options:
    - option: follow
      value_type: bool
      default_value: "false"
      description: Follow agent session logs
    - option: jq
      shorthand: q
DOCS
gh_agent-task_view.md:21Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task view
short: View an agent task session.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh agent-task
plink: gh_agent-task.yaml
options:
    - option: follow
      value_type: bool
      default_value: "false"
      description: Follow agent session logs
    - option: jq
      shorthand: q
DOCS
gh_agent-task_view.md:22Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task view
short: View an agent task session.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh agent-task
plink: gh_agent-task.yaml
options:
    - option: follow
      value_type: bool
      default_value: "false"
      description: Follow agent session logs
    - option: jq
      shorthand: q
DOCS
gh_agent-task_view.md:23Markdown · 4 words
TESTS
pkg/cmd/agent-task/view/view_test.go:26pkg/cmd/agent-task/view/view_test::TestNewCmdList · Go · 133 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name         string
		tty          bool
		args         string
		wantOpts     ViewOptions
		wantBaseRepo ghrepo.Interface
		wantErr      string
	}{
		{
			name:     "no arg tty",
			tty:      true,
			args:     "",
			wantOpts: ViewOptions{},
		},
		{
			name: "session ID arg tty",
			tty:  true,
			args: "00000000-0000-0000-0000-000000000000",
			wantOpts: ViewOptions{
				SelectorArg: "00000000-0000-0000-0000-000000000000",
				SessionID:   "00000000-0000-0000-0000-000000000000",
			},
		},
		{
			name: "PR agent-session URL arg tty",
			tty:  true,
			args: "https://github.com/OWNER/REPO/pull/101/agent-sessions/00000000-0000-0000-0000-000000000000",
			wantOpts: ViewOptions{
				SelectorArg: "https://github.com/OWNER/REPO/pull/101/agent-sessions/00000000-0000-0000-0000-000000000000",
+ 103 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task view
short: View an agent task session.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh agent-task
plink: gh_agent-task.yaml
options:
    - option: follow
      value_type: bool
      default_value: "false"
      description: Follow agent session logs
    - option: jq
      shorthand: q
DOCS
gh_agent-task_view.md:24Markdown · 7 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh agent-task view
short: View an agent task session.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh agent-task
plink: gh_agent-task.yaml
options:
    - option: follow
      value_type: bool
      default_value: "false"
      description: Follow agent session logs
    - option: jq
      shorthand: q
DOCS
gh_agent-task_view.md:25Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh agent-task view
short: View an agent task session.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh agent-task
plink: gh_agent-task.yaml
options:
    - option: follow
      value_type: bool
      default_value: "false"
      description: Follow agent session logs
    - option: jq
      shorthand: q
DOCS
gh_agent-task_view.md:26Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh alias
short: Aliases can be used to make shortcuts for gh commands or to compose multiple commands.
long: Run `gh help alias set` to learn more.
pname: gh
plink: gh.yaml
DOCS
gh_alias.md:1Markdown · 47 words
TESTS
pkg/cmd/root/alias_test.go:10pkg/cmd/root/alias_test::TestExpandAlias · Go · 64 lines
func TestExpandAlias(t *testing.T) {
	tests := []struct {
		name         string
		expansion    string
		args         []string
		wantExpanded []string
		wantErr      string
	}{
		{
			name:         "no expansion",
			expansion:    "pr status",
			args:         []string{},
			wantExpanded: []string{"pr", "status"},
		},
		{
			name:         "adding arguments after expansion",
			expansion:    "pr checkout",
			args:         []string{"123"},
			wantExpanded: []string{"pr", "checkout", "123"},
		},
		{
			name:      "not enough arguments for expansion",
			expansion: `issue list --author="$1" --label="$2"`,
			args:      []string{},
			wantErr:   `not enough arguments for alias: issue list --author="$1" --label="$2"`,
		},
		{
			name:      "not enough arguments for expansion 2",
			expansion: `issue list --author="$1" --label="$2"`,
			args:      []string{"vilmibm"},
+ 34 more lines · read full file
pkg/cmd/root/alias_test.go:75pkg/cmd/root/alias_test::TestExpandShellAlias · Go · 49 lines
func TestExpandShellAlias(t *testing.T) {
	findShFunc := func() (string, error) {
		return "/usr/bin/sh", nil
	}
	tests := []struct {
		name         string
		expansion    string
		args         []string
		findSh       func() (string, error)
		wantExpanded []string
		wantErr      string
	}{
		{
			name:         "simple expansion",
			expansion:    "!git branch --show-current",
			args:         []string{},
			findSh:       findShFunc,
			wantExpanded: []string{"/usr/bin/sh", "-c", "git branch --show-current"},
		},
		{
			name:         "adding arguments after expansion",
			expansion:    "!git branch checkout",
			args:         []string{"123"},
			findSh:       findShFunc,
			wantExpanded: []string{"/usr/bin/sh", "-c", "git branch checkout", "--", "123"},
		},
		{
			name:      "unable to find sh",
			expansion: "!git branch --show-current",
			args:      []string{},
+ 19 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh alias delete
short: Delete set aliases
pname: gh alias
plink: gh_alias.yaml
options:
    - option: all
      value_type: bool
      default_value: "false"
      description: Delete all aliases
DOCS
gh_alias_delete.md:1Markdown · 12 words
TESTS
pkg/cmd/alias/delete/delete_test.go:17pkg/cmd/alias/delete/delete_test::TestNewCmdDelete · Go · 69 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  DeleteOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify an alias to delete or `--all`",
		},
		{
			name:  "specified alias",
			input: "co",
			output: DeleteOptions{
				Name: "co",
			},
		},
		{
			name:  "all flag",
			input: "--all",
			output: DeleteOptions{
				All: true,
			},
		},
		{
			name:    "specified alias and all flag",
+ 39 more lines · read full file
pkg/cmd/alias/delete/delete_test.go:87pkg/cmd/alias/delete/delete_test::TestDeleteRun · Go · 102 lines
func TestDeleteRun(t *testing.T) {
	tests := []struct {
		name        string
		config      string
		isTTY       bool
		opts        *DeleteOptions
		wantAliases map[string]string
		wantStdout  string
		wantStderr  string
		wantErrMsg  string
	}{
		{
			name: "delete alias",
			config: heredoc.Doc(`
				aliases:
				  il: issue list
				  co: pr checkout
			`),
			isTTY: true,
			opts: &DeleteOptions{
				Name: "co",
				All:  false,
			},
			wantAliases: map[string]string{
				"il": "issue list",
			},
			wantStderr: "✓ Deleted alias co; was pr checkout\n",
		},
		{
			name: "delete all aliases",
+ 72 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh alias delete
short: Delete set aliases
pname: gh alias
plink: gh_alias.yaml
options:
    - option: all
      value_type: bool
      default_value: "false"
      description: Delete all aliases
DOCS
gh_alias_delete.md:19Markdown · 3 words
TESTS
pkg/cmd/alias/delete/delete_test.go:17pkg/cmd/alias/delete/delete_test::TestNewCmdDelete · Go · 69 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  DeleteOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify an alias to delete or `--all`",
		},
		{
			name:  "specified alias",
			input: "co",
			output: DeleteOptions{
				Name: "co",
			},
		},
		{
			name:  "all flag",
			input: "--all",
			output: DeleteOptions{
				All: true,
			},
		},
		{
			name:    "specified alias and all flag",
+ 39 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh alias import
short: Import aliases from the contents of a YAML file.
long: |-
    Aliases should be defined as a map in YAML, where the keys represent aliases and
    the values represent the corresponding expansions. An example file should look like
    the following:

       bugs: issue list --label=bug
       igrep: '!gh issue list --label="$1" | grep "$2"'
       features: |-
           issue list
           --label=enhancement
DOCS
gh_alias_import.md:1Markdown · 113 words
TESTS
pkg/cmd/alias/imports/import_test.go:24pkg/cmd/alias/imports/import_test::TestNewCmdImport · Go · 85 lines
func TestNewCmdImport(t *testing.T) {
	tests := []struct {
		name       string
		cli        string
		tty        bool
		wants      ImportOptions
		wantsError string
	}{
		{
			name: "no filename and stdin tty",
			cli:  "",
			tty:  true,
			wants: ImportOptions{
				Filename:          "",
				OverwriteExisting: false,
			},
			wantsError: "no filename passed and nothing on STDIN",
		},
		{
			name: "no filename and stdin is not tty",
			cli:  "",
			tty:  false,
			wants: ImportOptions{
				Filename:          "-",
				OverwriteExisting: false,
			},
		},
		{
			name: "stdin arg",
			cli:  "-",
+ 55 more lines · read full file
pkg/cmd/alias/imports/import_test.go:110pkg/cmd/alias/imports/import_test::TestImportRun · Go · 241 lines
func TestImportRun(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "aliases.yml")
	importFileMsg := fmt.Sprintf(`- Importing aliases from file %q`, tmpFile)
	importStdinMsg := "- Importing aliases from standard input"

	tests := []struct {
		name          string
		opts          *ImportOptions
		stdin         string
		fileContents  string
		initConfig    string
		aliasCommands []*cobra.Command
		wantConfig    string
		wantStderr    string
	}{
		{
			name: "with no existing aliases",
			opts: &ImportOptions{
				Filename:          tmpFile,
				OverwriteExisting: false,
			},
			fileContents: heredoc.Doc(`
                co: pr checkout
                igrep: '!gh issue list --label="$1" | grep "$2"'
            `),
			wantConfig: heredoc.Doc(`
                aliases:
                    co: pr checkout
                    igrep: '!gh issue list --label="$1" | grep "$2"'
            `),
+ 211 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh alias import
short: Import aliases from the contents of a YAML file.
long: |-
    Aliases should be defined as a map in YAML, where the keys represent aliases and
    the values represent the corresponding expansions. An example file should look like
    the following:

       bugs: issue list --label=bug
       igrep: '!gh issue list --label="$1" | grep "$2"'
       features: |-
           issue list
           --label=enhancement
DOCS
gh_alias_import.md:36Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh alias list
short: This command prints out all of the aliases gh is configured to use.
pname: gh alias
plink: gh_alias.yaml
DOCS
gh_alias_list.md:1Markdown · 25 words
TESTS
pkg/cmd/alias/list/list_test.go:17pkg/cmd/alias/list/list_test::TestAliasList · Go · 77 lines
func TestAliasList(t *testing.T) {
	tests := []struct {
		name       string
		config     string
		isTTY      bool
		wantErr    bool
		wantStdout string
		wantStderr string
	}{
		{
			name:       "empty",
			config:     "",
			isTTY:      true,
			wantErr:    true,
			wantStdout: "",
			wantStderr: "",
		},
		{
			name: "some",
			config: heredoc.Doc(`
				aliases:
				  co: pr checkout
				  gc: "!gh gist create \"$@\" | pbcopy"
			`),
			isTTY:      true,
			wantStdout: "co: pr checkout\ngc: '!gh gist create \"$@\" | pbcopy'\n",
			wantStderr: "",
		},
		{
			name: "multiline",
+ 47 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh alias set
short: Define a word that will expand to a full gh command when invoked.
long: |-
    The expansion may specify additional arguments and flags. If the expansion includes
    positional placeholders such as `$1`, extra arguments that follow the alias will be
    inserted appropriately. Otherwise, extra arguments will be appended to the expanded
    command.

    Use `-` as expansion argument to read the expansion string from standard input. This
    is useful to avoid quoting issues when defining expansions.

    If the expansion starts with `!` or if `--shell` was given, the expansion is a shell
DOCS
gh_alias_set.md:1Markdown · 123 words
TESTS
pkg/cmd/alias/set/set_test.go:18pkg/cmd/alias/set/set_test::TestNewCmdSet · Go · 79 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  SetOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "accepts 2 arg(s), received 0",
		},
		{
			name:    "only one argument",
			input:   "name",
			wantErr: true,
			errMsg:  "accepts 2 arg(s), received 1",
		},
		{
			name:  "name and expansion",
			input: "alias-name alias-expansion",
			output: SetOptions{
				Name:      "alias-name",
				Expansion: "alias-expansion",
			},
		},
		{
			name:  "shell flag",
+ 49 more lines · read full file
pkg/cmd/alias/set/set_test.go:98pkg/cmd/alias/set/set_test::TestSetRun · Go · 213 lines
func TestSetRun(t *testing.T) {
	tests := []struct {
		name          string
		tty           bool
		opts          *SetOptions
		stdin         string
		wantExpansion string
		wantStdout    string
		wantStderr    string
		wantErrMsg    string
	}{
		{
			name: "creates alias tty",
			tty:  true,
			opts: &SetOptions{
				Name:      "foo",
				Expansion: "bar",
			},
			wantExpansion: "bar",
			wantStderr:    "- Creating alias for foo: bar\n✓ Added alias foo\n",
		},
		{
			name: "creates alias",
			opts: &SetOptions{
				Name:      "foo",
				Expansion: "bar",
			},
			wantExpansion: "bar",
		},
		{
+ 183 more lines · read full file
pkg/cmd/alias/set/set_test.go:312pkg/cmd/alias/set/set_test::TestGetExpansion · Go · 44 lines
func TestGetExpansion(t *testing.T) {
	tests := []struct {
		name         string
		want         string
		expansionArg string
		stdin        string
	}{
		{
			name:         "co",
			want:         "pr checkout",
			expansionArg: "pr checkout",
		},
		{
			name:         "co",
			want:         "pr checkout",
			expansionArg: "pr checkout",
			stdin:        "api graphql -F name=\"$1\"",
		},
		{
			name:         "stdin",
			expansionArg: "-",
			want:         "api graphql -F name=\"$1\"",
			stdin:        "api graphql -F name=\"$1\"",
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, stdin, _, _ := iostreams.Test()
			ios.SetStdinTTY(false)
+ 14 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh alias set
short: Define a word that will expand to a full gh command when invoked.
long: |-
    The expansion may specify additional arguments and flags. If the expansion includes
    positional placeholders such as `$1`, extra arguments that follow the alias will be
    inserted appropriately. Otherwise, extra arguments will be appended to the expanded
    command.

    Use `-` as expansion argument to read the expansion string from standard input. This
    is useful to avoid quoting issues when defining expansions.

    If the expansion starts with `!` or if `--shell` was given, the expansion is a shell
DOCS
gh_alias_set.md:32Markdown · 7 words
TESTS
pkg/cmd/alias/set/set_test.go:18pkg/cmd/alias/set/set_test::TestNewCmdSet · Go · 79 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  SetOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "accepts 2 arg(s), received 0",
		},
		{
			name:    "only one argument",
			input:   "name",
			wantErr: true,
			errMsg:  "accepts 2 arg(s), received 1",
		},
		{
			name:  "name and expansion",
			input: "alias-name alias-expansion",
			output: SetOptions{
				Name:      "alias-name",
				Expansion: "alias-expansion",
			},
		},
		{
			name:  "shell flag",
+ 49 more lines · read full file
pkg/cmd/alias/set/set_test.go:98pkg/cmd/alias/set/set_test::TestSetRun · Go · 213 lines
func TestSetRun(t *testing.T) {
	tests := []struct {
		name          string
		tty           bool
		opts          *SetOptions
		stdin         string
		wantExpansion string
		wantStdout    string
		wantStderr    string
		wantErrMsg    string
	}{
		{
			name: "creates alias tty",
			tty:  true,
			opts: &SetOptions{
				Name:      "foo",
				Expansion: "bar",
			},
			wantExpansion: "bar",
			wantStderr:    "- Creating alias for foo: bar\n✓ Added alias foo\n",
		},
		{
			name: "creates alias",
			opts: &SetOptions{
				Name:      "foo",
				Expansion: "bar",
			},
			wantExpansion: "bar",
		},
		{
+ 183 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh alias set
short: Define a word that will expand to a full gh command when invoked.
long: |-
    The expansion may specify additional arguments and flags. If the expansion includes
    positional placeholders such as `$1`, extra arguments that follow the alias will be
    inserted appropriately. Otherwise, extra arguments will be appended to the expanded
    command.

    Use `-` as expansion argument to read the expansion string from standard input. This
    is useful to avoid quoting issues when defining expansions.

    If the expansion starts with `!` or if `--shell` was given, the expansion is a shell
DOCS
gh_alias_set.md:33Markdown · 10 words
TESTS
pkg/cmd/alias/set/set_test.go:18pkg/cmd/alias/set/set_test::TestNewCmdSet · Go · 79 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  SetOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "accepts 2 arg(s), received 0",
		},
		{
			name:    "only one argument",
			input:   "name",
			wantErr: true,
			errMsg:  "accepts 2 arg(s), received 1",
		},
		{
			name:  "name and expansion",
			input: "alias-name alias-expansion",
			output: SetOptions{
				Name:      "alias-name",
				Expansion: "alias-expansion",
			},
		},
		{
			name:  "shell flag",
+ 49 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
TESTS
pkg/cmd/api/api_test.go:30pkg/cmd/api/api_test::Test_NewCmdApi · Go · 380 lines
func Test_NewCmdApi(t *testing.T) {
	f := &cmdutil.Factory{}

	tests := []struct {
		name     string
		cli      string
		wants    ApiOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "graphql",
			wants: ApiOptions{
				Hostname:            "",
				RequestMethod:       "GET",
				RequestMethodPassed: false,
				RequestPath:         "graphql",
				RequestInputFile:    "",
				RawFields:           []string(nil),
				MagicFields:         []string(nil),
				RequestHeaders:      []string(nil),
				ShowResponseHeaders: false,
				Paginate:            false,
				Silent:              false,
				CacheTTL:            0,
				Template:            "",
				FilterOutput:        "",
				Verbose:             false,
			},
			wantsErr: false,
+ 350 more lines · read full file
pkg/cmd/api/api_test.go:411pkg/cmd/api/api_test::Test_NewCmdApi_WindowsAbsPath · Go · 13 lines
func Test_NewCmdApi_WindowsAbsPath(t *testing.T) {
	if runtime.GOOS != "windows" {
		t.SkipNow()
	}

	cmd := NewCmdApi(&cmdutil.Factory{}, func(opts *ApiOptions) error {
		return nil
	})

	cmd.SetArgs([]string{`C:\users\repos`})
	_, err := cmd.ExecuteC()
	assert.EqualError(t, err, `invalid API endpoint: "C:\users\repos". Your shell might be rewriting URL paths as filesystem paths. To avoid this, omit the leading slash from the endpoint argument`)
}
pkg/cmd/api/api_test.go:425pkg/cmd/api/api_test::Test_apiRun · Go · 266 lines
func Test_apiRun(t *testing.T) {
	tests := []struct {
		name         string
		options      ApiOptions
		httpResponse *http.Response
		err          error
		stdout       string
		stderr       string
		isatty       bool
	}{
		{
			name: "success",
			httpResponse: &http.Response{
				StatusCode: 200,
				Body:       io.NopCloser(bytes.NewBufferString(`bam!`)),
			},
			err:    nil,
			stdout: `bam!`,
			stderr: ``,
			isatty: false,
		},
		{
			name: "show response headers",
			options: ApiOptions{
				ShowResponseHeaders: true,
			},
			httpResponse: &http.Response{
				Proto:      "HTTP/1.1",
				Status:     "200 Okey-dokey",
				StatusCode: 200,
+ 236 more lines · read full file
+ 17 more tests · open all in source
EXAMPLES
gh_api.md:8Markdown
gh_api.md:96Markdown
CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:75Markdown · 7 words
TESTS
pkg/cmd/api/api_test.go:30pkg/cmd/api/api_test::Test_NewCmdApi · Go · 380 lines
func Test_NewCmdApi(t *testing.T) {
	f := &cmdutil.Factory{}

	tests := []struct {
		name     string
		cli      string
		wants    ApiOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "graphql",
			wants: ApiOptions{
				Hostname:            "",
				RequestMethod:       "GET",
				RequestMethodPassed: false,
				RequestPath:         "graphql",
				RequestInputFile:    "",
				RawFields:           []string(nil),
				MagicFields:         []string(nil),
				RequestHeaders:      []string(nil),
				ShowResponseHeaders: false,
				Paginate:            false,
				Silent:              false,
				CacheTTL:            0,
				Template:            "",
				FilterOutput:        "",
				Verbose:             false,
			},
			wantsErr: false,
+ 350 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:76Markdown · 18 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:77Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:78Markdown · 8 words
TESTS
pkg/cmd/api/api_test.go:30pkg/cmd/api/api_test::Test_NewCmdApi · Go · 380 lines
func Test_NewCmdApi(t *testing.T) {
	f := &cmdutil.Factory{}

	tests := []struct {
		name     string
		cli      string
		wants    ApiOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "graphql",
			wants: ApiOptions{
				Hostname:            "",
				RequestMethod:       "GET",
				RequestMethodPassed: false,
				RequestPath:         "graphql",
				RequestInputFile:    "",
				RawFields:           []string(nil),
				MagicFields:         []string(nil),
				RequestHeaders:      []string(nil),
				ShowResponseHeaders: false,
				Paginate:            false,
				Silent:              false,
				CacheTTL:            0,
				Template:            "",
				FilterOutput:        "",
				Verbose:             false,
			},
			wantsErr: false,
+ 350 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:79Markdown · 10 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:80Markdown · 17 words
TESTS
pkg/cmd/api/api_test.go:30pkg/cmd/api/api_test::Test_NewCmdApi · Go · 380 lines
func Test_NewCmdApi(t *testing.T) {
	f := &cmdutil.Factory{}

	tests := []struct {
		name     string
		cli      string
		wants    ApiOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "graphql",
			wants: ApiOptions{
				Hostname:            "",
				RequestMethod:       "GET",
				RequestMethodPassed: false,
				RequestPath:         "graphql",
				RequestInputFile:    "",
				RawFields:           []string(nil),
				MagicFields:         []string(nil),
				RequestHeaders:      []string(nil),
				ShowResponseHeaders: false,
				Paginate:            false,
				Silent:              false,
				CacheTTL:            0,
				Template:            "",
				FilterOutput:        "",
				Verbose:             false,
			},
			wantsErr: false,
+ 350 more lines · read full file
EXAMPLES
gh_api.md:96Markdown
WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
TESTS
pkg/cmd/api/api_test.go:30pkg/cmd/api/api_test::Test_NewCmdApi · Go · 380 lines
func Test_NewCmdApi(t *testing.T) {
	f := &cmdutil.Factory{}

	tests := []struct {
		name     string
		cli      string
		wants    ApiOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "graphql",
			wants: ApiOptions{
				Hostname:            "",
				RequestMethod:       "GET",
				RequestMethodPassed: false,
				RequestPath:         "graphql",
				RequestInputFile:    "",
				RawFields:           []string(nil),
				MagicFields:         []string(nil),
				RequestHeaders:      []string(nil),
				ShowResponseHeaders: false,
				Paginate:            false,
				Silent:              false,
				CacheTTL:            0,
				Template:            "",
				FilterOutput:        "",
				Verbose:             false,
			},
			wantsErr: false,
+ 350 more lines · read full file
EXAMPLES
gh_api.md:96Markdown
WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:82Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:83Markdown · 10 words
TESTS
pkg/cmd/api/api_test.go:30pkg/cmd/api/api_test::Test_NewCmdApi · Go · 380 lines
func Test_NewCmdApi(t *testing.T) {
	f := &cmdutil.Factory{}

	tests := []struct {
		name     string
		cli      string
		wants    ApiOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "graphql",
			wants: ApiOptions{
				Hostname:            "",
				RequestMethod:       "GET",
				RequestMethodPassed: false,
				RequestPath:         "graphql",
				RequestInputFile:    "",
				RawFields:           []string(nil),
				MagicFields:         []string(nil),
				RequestHeaders:      []string(nil),
				ShowResponseHeaders: false,
				Paginate:            false,
				Silent:              false,
				CacheTTL:            0,
				Template:            "",
				FilterOutput:        "",
				Verbose:             false,
			},
			wantsErr: false,
+ 350 more lines · read full file
EXAMPLES
gh_api.md:96Markdown
WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:84Markdown · 9 words
TESTS

N/A

EXAMPLES
gh_api.md:96Markdown
WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:85Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:86Markdown · 6 words
TESTS
pkg/cmd/api/api_test.go:30pkg/cmd/api/api_test::Test_NewCmdApi · Go · 380 lines
func Test_NewCmdApi(t *testing.T) {
	f := &cmdutil.Factory{}

	tests := []struct {
		name     string
		cli      string
		wants    ApiOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "graphql",
			wants: ApiOptions{
				Hostname:            "",
				RequestMethod:       "GET",
				RequestMethodPassed: false,
				RequestPath:         "graphql",
				RequestInputFile:    "",
				RawFields:           []string(nil),
				MagicFields:         []string(nil),
				RequestHeaders:      []string(nil),
				ShowResponseHeaders: false,
				Paginate:            false,
				Silent:              false,
				CacheTTL:            0,
				Template:            "",
				FilterOutput:        "",
				Verbose:             false,
			},
			wantsErr: false,
+ 350 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:87Markdown · 16 words
TESTS
pkg/cmd/api/api_test.go:30pkg/cmd/api/api_test::Test_NewCmdApi · Go · 380 lines
func Test_NewCmdApi(t *testing.T) {
	f := &cmdutil.Factory{}

	tests := []struct {
		name     string
		cli      string
		wants    ApiOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "graphql",
			wants: ApiOptions{
				Hostname:            "",
				RequestMethod:       "GET",
				RequestMethodPassed: false,
				RequestPath:         "graphql",
				RequestInputFile:    "",
				RawFields:           []string(nil),
				MagicFields:         []string(nil),
				RequestHeaders:      []string(nil),
				ShowResponseHeaders: false,
				Paginate:            false,
				Silent:              false,
				CacheTTL:            0,
				Template:            "",
				FilterOutput:        "",
				Verbose:             false,
			},
			wantsErr: false,
+ 350 more lines · read full file
EXAMPLES
gh_api.md:96Markdown
WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:88Markdown · 11 words
TESTS
pkg/cmd/api/api_test.go:30pkg/cmd/api/api_test::Test_NewCmdApi · Go · 380 lines
func Test_NewCmdApi(t *testing.T) {
	f := &cmdutil.Factory{}

	tests := []struct {
		name     string
		cli      string
		wants    ApiOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "graphql",
			wants: ApiOptions{
				Hostname:            "",
				RequestMethod:       "GET",
				RequestMethodPassed: false,
				RequestPath:         "graphql",
				RequestInputFile:    "",
				RawFields:           []string(nil),
				MagicFields:         []string(nil),
				RequestHeaders:      []string(nil),
				ShowResponseHeaders: false,
				Paginate:            false,
				Silent:              false,
				CacheTTL:            0,
				Template:            "",
				FilterOutput:        "",
				Verbose:             false,
			},
			wantsErr: false,
+ 350 more lines · read full file
EXAMPLES
gh_api.md:96Markdown
WORKFLOWS

N/A

CONTRACT
command: gh api
short: Makes an authenticated HTTP request to the GitHub API and prints the response.
long: |-
    The endpoint argument should either be a path of a GitHub API v3 endpoint, or
    `graphql` to access the GitHub API v4.

    Placeholder values `{owner}`, `{repo}`, and `{branch}` in the endpoint
DOCS
gh_api.md:89Markdown · 9 words
TESTS
pkg/cmd/api/api_test.go:30pkg/cmd/api/api_test::Test_NewCmdApi · Go · 380 lines
func Test_NewCmdApi(t *testing.T) {
	f := &cmdutil.Factory{}

	tests := []struct {
		name     string
		cli      string
		wants    ApiOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "graphql",
			wants: ApiOptions{
				Hostname:            "",
				RequestMethod:       "GET",
				RequestMethodPassed: false,
				RequestPath:         "graphql",
				RequestInputFile:    "",
				RawFields:           []string(nil),
				MagicFields:         []string(nil),
				RequestHeaders:      []string(nil),
				ShowResponseHeaders: false,
				Paginate:            false,
				Silent:              false,
				CacheTTL:            0,
				Template:            "",
				FilterOutput:        "",
				Verbose:             false,
			},
			wantsErr: false,
+ 350 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation
short: Download and verify artifact attestations.
pname: gh
plink: gh.yaml
TESTS
pkg/cmd/attestation/verification/attestation_test.go:16pkg/cmd/attestation/verification/attestation_test::TestLoadBundlesFromJSONLinesFile · Go · 28 lines
func TestLoadBundlesFromJSONLinesFile(t *testing.T) {
	t.Run("with original file", func(t *testing.T) {
		path := "../test/data/sigstore-js-2.1.0_with_2_bundles.jsonl"
		attestations, err := loadBundlesFromJSONLinesFile(path)
		require.NoError(t, err)
		require.Len(t, attestations, 2)
	})

	t.Run("with extra lines", func(t *testing.T) {
		// Create a temporary file with extra lines
		tempDir := t.TempDir()
		tempFile := filepath.Join(tempDir, "test_with_extra_lines.jsonl")

		originalContent, err := os.ReadFile("../test/data/sigstore-js-2.1.0_with_2_bundles.jsonl")
		require.NoError(t, err)

		extraLines := []byte("\n\n")
		newContent := append(originalContent, extraLines...)

		err = os.WriteFile(tempFile, newContent, 0644)
		require.NoError(t, err)

		// Test the function with the new file
		attestations, err := loadBundlesFromJSONLinesFile(tempFile)
		require.NoError(t, err)
		require.Len(t, attestations, 2, "Should still load 2 valid attestations")
	})
}
pkg/cmd/attestation/verification/attestation_test.go:17pkg/cmd/attestation/verification/attestation_test::with original file · Go · 6 lines
t.Run("with original file", func(t *testing.T) {
	path := "../test/data/sigstore-js-2.1.0_with_2_bundles.jsonl"
	attestations, err := loadBundlesFromJSONLinesFile(path)
	require.NoError(t, err)
	require.Len(t, attestations, 2)
})
pkg/cmd/attestation/verification/attestation_test.go:24pkg/cmd/attestation/verification/attestation_test::with extra lines · Go · 19 lines
t.Run("with extra lines", func(t *testing.T) {
	// Create a temporary file with extra lines
	tempDir := t.TempDir()
	tempFile := filepath.Join(tempDir, "test_with_extra_lines.jsonl")

	originalContent, err := os.ReadFile("../test/data/sigstore-js-2.1.0_with_2_bundles.jsonl")
	require.NoError(t, err)

	extraLines := []byte("\n\n")
	newContent := append(originalContent, extraLines...)

	err = os.WriteFile(tempFile, newContent, 0644)
	require.NoError(t, err)

	// Test the function with the new file
	attestations, err := loadBundlesFromJSONLinesFile(tempFile)
	require.NoError(t, err)
	require.Len(t, attestations, 2, "Should still load 2 valid attestations")
})
+ 14 more tests · open all in source
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation download
short: '### NOTE: This feature is currently in public preview, and subject to change.'
long: Download attestations associated with an artifact for offline use.
pname: gh attestation
plink: gh_attestation.yaml
options:
    - option: digest-alg
      shorthand: d
      value_type: string
      description: 'The algorithm used to compute a digest of the artifact: {sha256|sha512} (default "sha256")'
TESTS
pkg/cmd/attestation/download/download_test.go:36pkg/cmd/attestation/download/download_test::TestNewDownloadCmd · Go · 154 lines
func TestNewDownloadCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			return nil, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	store := &LiveStore{
		outputPath: t.TempDir(),
	}

	testcases := []struct {
		name     string
		cli      string
		wants    Options
		wantsErr bool
	}{
		{
			name: "Invalid digest-alg flag",
			cli:  fmt.Sprintf("%s --owner sigstore --digest-alg sha384", artifactPath),
			wants: Options{
				ArtifactPath:    artifactPath,
				APIClient:       api.NewTestClient(),
				OCIClient:       oci.MockClient{},
				DigestAlgorithm: "sha384",
+ 124 more lines · read full file
pkg/cmd/attestation/download/download_test.go:191pkg/cmd/attestation/download/download_test::TestRunDownload · Go · 138 lines
func TestRunDownload(t *testing.T) {
	tempDir := t.TempDir()
	store := &LiveStore{
		outputPath: tempDir,
	}

	baseOpts := Options{
		ArtifactPath:    artifactPath,
		APIClient:       api.NewTestClient(),
		OCIClient:       oci.MockClient{},
		DigestAlgorithm: "sha512",
		Owner:           "sigstore",
		Store:           store,
		Limit:           30,
		Logger:          io.NewTestHandler(),
	}

	t.Run("fetch and store attestations successfully with owner", func(t *testing.T) {
		err := runDownload(&baseOpts)
		require.NoError(t, err)

		artifact, err := artifact.NewDigestedArtifact(baseOpts.OCIClient, baseOpts.ArtifactPath, baseOpts.DigestAlgorithm)
		require.NoError(t, err)

		expectedFilePath := expectedFilePath(tempDir, artifact.DigestWithAlg())
		require.FileExists(t, expectedFilePath)

		actualLineCount, err := countLines(expectedFilePath)
		require.NoError(t, err)
+ 109 more lines · read full file
pkg/cmd/attestation/download/download_test.go:208pkg/cmd/attestation/download/download_test::fetch and store attestations successfully with owner · Go · 16 lines
t.Run("fetch and store attestations successfully with owner", func(t *testing.T) {
	err := runDownload(&baseOpts)
	require.NoError(t, err)

	artifact, err := artifact.NewDigestedArtifact(baseOpts.OCIClient, baseOpts.ArtifactPath, baseOpts.DigestAlgorithm)
	require.NoError(t, err)

	expectedFilePath := expectedFilePath(tempDir, artifact.DigestWithAlg())
	require.FileExists(t, expectedFilePath)

	actualLineCount, err := countLines(expectedFilePath)
	require.NoError(t, err)

	expectedLineCount := 2
	require.Equal(t, expectedLineCount, actualLineCount)
})
+ 8 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh attestation download
short: '### NOTE: This feature is currently in public preview, and subject to change.'
long: Download attestations associated with an artifact for offline use.
pname: gh attestation
plink: gh_attestation.yaml
options:
    - option: digest-alg
      shorthand: d
      value_type: string
      description: 'The algorithm used to compute a digest of the artifact: {sha256|sha512} (default "sha256")'
DOCS
gh_attestation_download.md:47Markdown · 11 words
TESTS
pkg/cmd/attestation/download/download_test.go:36pkg/cmd/attestation/download/download_test::TestNewDownloadCmd · Go · 154 lines
func TestNewDownloadCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			return nil, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	store := &LiveStore{
		outputPath: t.TempDir(),
	}

	testcases := []struct {
		name     string
		cli      string
		wants    Options
		wantsErr bool
	}{
		{
			name: "Invalid digest-alg flag",
			cli:  fmt.Sprintf("%s --owner sigstore --digest-alg sha384", artifactPath),
			wants: Options{
				ArtifactPath:    artifactPath,
				APIClient:       api.NewTestClient(),
				OCIClient:       oci.MockClient{},
				DigestAlgorithm: "sha384",
+ 124 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation download
short: '### NOTE: This feature is currently in public preview, and subject to change.'
long: Download attestations associated with an artifact for offline use.
pname: gh attestation
plink: gh_attestation.yaml
options:
    - option: digest-alg
      shorthand: d
      value_type: string
      description: 'The algorithm used to compute a digest of the artifact: {sha256|sha512} (default "sha256")'
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation download
short: '### NOTE: This feature is currently in public preview, and subject to change.'
long: Download attestations associated with an artifact for offline use.
pname: gh attestation
plink: gh_attestation.yaml
options:
    - option: digest-alg
      shorthand: d
      value_type: string
      description: 'The algorithm used to compute a digest of the artifact: {sha256|sha512} (default "sha256")'
DOCS
TESTS
pkg/cmd/attestation/download/download_test.go:36pkg/cmd/attestation/download/download_test::TestNewDownloadCmd · Go · 154 lines
func TestNewDownloadCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			return nil, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	store := &LiveStore{
		outputPath: t.TempDir(),
	}

	testcases := []struct {
		name     string
		cli      string
		wants    Options
		wantsErr bool
	}{
		{
			name: "Invalid digest-alg flag",
			cli:  fmt.Sprintf("%s --owner sigstore --digest-alg sha384", artifactPath),
			wants: Options{
				ArtifactPath:    artifactPath,
				APIClient:       api.NewTestClient(),
				OCIClient:       oci.MockClient{},
				DigestAlgorithm: "sha384",
+ 124 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation download
short: '### NOTE: This feature is currently in public preview, and subject to change.'
long: Download attestations associated with an artifact for offline use.
pname: gh attestation
plink: gh_attestation.yaml
options:
    - option: digest-alg
      shorthand: d
      value_type: string
      description: 'The algorithm used to compute a digest of the artifact: {sha256|sha512} (default "sha256")'
DOCS
TESTS
pkg/cmd/attestation/download/download_test.go:36pkg/cmd/attestation/download/download_test::TestNewDownloadCmd · Go · 154 lines
func TestNewDownloadCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			return nil, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	store := &LiveStore{
		outputPath: t.TempDir(),
	}

	testcases := []struct {
		name     string
		cli      string
		wants    Options
		wantsErr bool
	}{
		{
			name: "Invalid digest-alg flag",
			cli:  fmt.Sprintf("%s --owner sigstore --digest-alg sha384", artifactPath),
			wants: Options{
				ArtifactPath:    artifactPath,
				APIClient:       api.NewTestClient(),
				OCIClient:       oci.MockClient{},
				DigestAlgorithm: "sha384",
+ 124 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh attestation download
short: '### NOTE: This feature is currently in public preview, and subject to change.'
long: Download attestations associated with an artifact for offline use.
pname: gh attestation
plink: gh_attestation.yaml
options:
    - option: digest-alg
      shorthand: d
      value_type: string
      description: 'The algorithm used to compute a digest of the artifact: {sha256|sha512} (default "sha256")'
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation download
short: '### NOTE: This feature is currently in public preview, and subject to change.'
long: Download attestations associated with an artifact for offline use.
pname: gh attestation
plink: gh_attestation.yaml
options:
    - option: digest-alg
      shorthand: d
      value_type: string
      description: 'The algorithm used to compute a digest of the artifact: {sha256|sha512} (default "sha256")'
DOCS
TESTS
pkg/cmd/attestation/download/download_test.go:36pkg/cmd/attestation/download/download_test::TestNewDownloadCmd · Go · 154 lines
func TestNewDownloadCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			return nil, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	store := &LiveStore{
		outputPath: t.TempDir(),
	}

	testcases := []struct {
		name     string
		cli      string
		wants    Options
		wantsErr bool
	}{
		{
			name: "Invalid digest-alg flag",
			cli:  fmt.Sprintf("%s --owner sigstore --digest-alg sha384", artifactPath),
			wants: Options{
				ArtifactPath:    artifactPath,
				APIClient:       api.NewTestClient(),
				OCIClient:       oci.MockClient{},
				DigestAlgorithm: "sha384",
+ 124 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh attestation trusted-root
short: Output contents for a trusted_root.jsonl file, likely for offline verification.
long: |-
    When using `gh attestation verify`, if your machine is on the internet,
    this will happen automatically. But to do offline verification, you need to
    supply a trusted root file with `--custom-trusted-root`; this command
    will help you fetch a `trusted_root.jsonl` file for that purpose.

    You can call this command without any flags to get a trusted root file covering
    the Sigstore Public Good Instance as well as GitHub's Sigstore instance.

    Otherwise you can use `--tuf-url` to specify the URL of a custom TUF
TESTS
pkg/cmd/attestation/trustedroot/trustedroot_test.go:24pkg/cmd/attestation/trustedroot/trustedroot_test::TestNewTrustedRootCmd · Go · 68 lines
func TestNewTrustedRootCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	f := &cmdutil.Factory{
		IOStreams: testIO,
		Config: func() (gh.Config, error) {
			return &ghmock.ConfigMock{}, nil
		},
		HttpClient: func() (*http.Client, error) {
			reg := &httpmock.Registry{}
			client := &http.Client{}
			httpmock.ReplaceTripper(client, reg)
			return client, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	testcases := []struct {
		name     string
		cli      string
		wantsErr bool
	}{
		{
			name:     "Happy path",
			cli:      "",
			wantsErr: false,
		},
		{
			name:     "Happy path",
+ 38 more lines · read full file
pkg/cmd/attestation/trustedroot/trustedroot_test.go:93pkg/cmd/attestation/trustedroot/trustedroot_test::TestNewTrustedRootWithTenancy · Go · 83 lines
func TestNewTrustedRootWithTenancy(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	var testReg httpmock.Registry
	var metaResp = api.MetaResponse{
		Domains: api.Domain{
			ArtifactAttestations: api.ArtifactAttestations{
				TrustDomain: "foo",
			},
		},
	}
	testReg.Register(httpmock.REST(http.MethodGet, "meta"),
		httpmock.StatusJSONResponse(200, &metaResp))

	httpClientFunc := func() (*http.Client, error) {
		reg := &testReg
		client := &http.Client{}
		httpmock.ReplaceTripper(client, reg)
		return client, nil
	}

	cli := "--hostname foo-bar.ghe.com"

	t.Run("Host with NO auth configured", func(t *testing.T) {
		f := &cmdutil.Factory{
			IOStreams: testIO,
			Config: func() (gh.Config, error) {
				return &ghmock.ConfigMock{
					AuthenticationFunc: func() gh.AuthConfig {
						return &stubAuthConfig{hasActiveToken: false}
					},
+ 53 more lines · read full file
pkg/cmd/attestation/trustedroot/trustedroot_test.go:181pkg/cmd/attestation/trustedroot/trustedroot_test::TestGetTrustedRoot · Go · 27 lines
func TestGetTrustedRoot(t *testing.T) {
	mirror := "https://tuf-repo.github.com"
	root := test.NormalizeRelativePath("../verification/embed/tuf-repo.github.com/root.json")

	opts := &Options{
		TufUrl:      mirror,
		TufRootPath: root,
	}

	reg := &httpmock.Registry{}
	client := &http.Client{}
	httpmock.ReplaceTripper(client, reg)

	t.Run("failed to create TUF root", func(t *testing.T) {
		err := getTrustedRoot(newTUFErrClient, opts, client)
		require.Error(t, err)
		require.ErrorContains(t, err, "failed to create TUF client")
	})

	t.Run("fails because the root cannot be found", func(t *testing.T) {
		opts.TufRootPath = test.NormalizeRelativePath("./does/not/exist/root.json")
		err := getTrustedRoot(tuf.New, opts, client)
		require.Error(t, err)
		require.ErrorContains(t, err, "failed to read root file")
	})

}
WORKFLOWS

N/A

CONTRACT
command: gh attestation trusted-root
short: Output contents for a trusted_root.jsonl file, likely for offline verification.
long: |-
    When using `gh attestation verify`, if your machine is on the internet,
    this will happen automatically. But to do offline verification, you need to
    supply a trusted root file with `--custom-trusted-root`; this command
    will help you fetch a `trusted_root.jsonl` file for that purpose.

    You can call this command without any flags to get a trusted root file covering
    the Sigstore Public Good Instance as well as GitHub's Sigstore instance.

    Otherwise you can use `--tuf-url` to specify the URL of a custom TUF
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation trusted-root
short: Output contents for a trusted_root.jsonl file, likely for offline verification.
long: |-
    When using `gh attestation verify`, if your machine is on the internet,
    this will happen automatically. But to do offline verification, you need to
    supply a trusted root file with `--custom-trusted-root`; this command
    will help you fetch a `trusted_root.jsonl` file for that purpose.

    You can call this command without any flags to get a trusted root file covering
    the Sigstore Public Good Instance as well as GitHub's Sigstore instance.

    Otherwise you can use `--tuf-url` to specify the URL of a custom TUF
DOCS
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation trusted-root
short: Output contents for a trusted_root.jsonl file, likely for offline verification.
long: |-
    When using `gh attestation verify`, if your machine is on the internet,
    this will happen automatically. But to do offline verification, you need to
    supply a trusted root file with `--custom-trusted-root`; this command
    will help you fetch a `trusted_root.jsonl` file for that purpose.

    You can call this command without any flags to get a trusted root file covering
    the Sigstore Public Good Instance as well as GitHub's Sigstore instance.

    Otherwise you can use `--tuf-url` to specify the URL of a custom TUF
DOCS
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation trusted-root
short: Output contents for a trusted_root.jsonl file, likely for offline verification.
long: |-
    When using `gh attestation verify`, if your machine is on the internet,
    this will happen automatically. But to do offline verification, you need to
    supply a trusted root file with `--custom-trusted-root`; this command
    will help you fetch a `trusted_root.jsonl` file for that purpose.

    You can call this command without any flags to get a trusted root file covering
    the Sigstore Public Good Instance as well as GitHub's Sigstore instance.

    Otherwise you can use `--tuf-url` to specify the URL of a custom TUF
DOCS
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
TESTS
pkg/cmd/attestation/verify/verify_test.go:36pkg/cmd/attestation/verify/verify_test::TestNewVerifyCmd · Go · 283 lines
func TestNewVerifyCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	var testReg httpmock.Registry
	var metaResp = api.MetaResponse{
		Domains: api.Domain{
			ArtifactAttestations: api.ArtifactAttestations{
				TrustDomain: "foo",
			},
		},
	}
	testReg.Register(httpmock.REST(http.MethodGet, "meta"),
		httpmock.StatusJSONResponse(200, &metaResp))

	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			reg := &testReg
			client := &http.Client{}
			httpmock.ReplaceTripper(client, reg)
			return client, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	testcases := []struct {
		name          string
		cli           string
		wants         Options
+ 253 more lines · read full file
pkg/cmd/attestation/verify/verify_test.go:320pkg/cmd/attestation/verify/verify_test::TestVerifyCmdAuthChecks · Go · 29 lines
func TestVerifyCmdAuthChecks(t *testing.T) {
	f := &cmdutil.Factory{}

	t.Run("by default auth check is required", func(t *testing.T) {
		cmd := NewVerifyCmd(f, func(o *Options) error {
			return nil
		})

		// IsAuthCheckEnabled assumes commands under test are subcommands
		parent := &cobra.Command{Use: "root"}
		parent.AddCommand(cmd)

		require.NoError(t, cmd.ParseFlags([]string{}))
		require.True(t, cmdutil.IsAuthCheckEnabled(cmd), "expected auth check to be required")
	})

	t.Run("when --bundle flag is provided, auth check is not required", func(t *testing.T) {
		cmd := NewVerifyCmd(f, func(o *Options) error {
			return nil
		})

		// IsAuthCheckEnabled assumes commands under test are subcommands
		parent := &cobra.Command{Use: "root"}
		parent.AddCommand(cmd)

		require.NoError(t, cmd.ParseFlags([]string{"--bundle", "not-important"}))
		require.False(t, cmdutil.IsAuthCheckEnabled(cmd), "expected auth check not to be required due to --bundle flag")
	})
}
pkg/cmd/attestation/verify/verify_test.go:323pkg/cmd/attestation/verify/verify_test::by default auth check is required · Go · 12 lines
t.Run("by default auth check is required", func(t *testing.T) {
	cmd := NewVerifyCmd(f, func(o *Options) error {
		return nil
	})

	// IsAuthCheckEnabled assumes commands under test are subcommands
	parent := &cobra.Command{Use: "root"}
	parent.AddCommand(cmd)

	require.NoError(t, cmd.ParseFlags([]string{}))
	require.True(t, cmdutil.IsAuthCheckEnabled(cmd), "expected auth check to be required")
})
+ 23 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
TESTS
pkg/cmd/attestation/verify/verify_test.go:36pkg/cmd/attestation/verify/verify_test::TestNewVerifyCmd · Go · 283 lines
func TestNewVerifyCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	var testReg httpmock.Registry
	var metaResp = api.MetaResponse{
		Domains: api.Domain{
			ArtifactAttestations: api.ArtifactAttestations{
				TrustDomain: "foo",
			},
		},
	}
	testReg.Register(httpmock.REST(http.MethodGet, "meta"),
		httpmock.StatusJSONResponse(200, &metaResp))

	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			reg := &testReg
			client := &http.Client{}
			httpmock.ReplaceTripper(client, reg)
			return client, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	testcases := []struct {
		name          string
		cli           string
		wants         Options
+ 253 more lines · read full file
pkg/cmd/attestation/verify/verify_test.go:320pkg/cmd/attestation/verify/verify_test::TestVerifyCmdAuthChecks · Go · 29 lines
func TestVerifyCmdAuthChecks(t *testing.T) {
	f := &cmdutil.Factory{}

	t.Run("by default auth check is required", func(t *testing.T) {
		cmd := NewVerifyCmd(f, func(o *Options) error {
			return nil
		})

		// IsAuthCheckEnabled assumes commands under test are subcommands
		parent := &cobra.Command{Use: "root"}
		parent.AddCommand(cmd)

		require.NoError(t, cmd.ParseFlags([]string{}))
		require.True(t, cmdutil.IsAuthCheckEnabled(cmd), "expected auth check to be required")
	})

	t.Run("when --bundle flag is provided, auth check is not required", func(t *testing.T) {
		cmd := NewVerifyCmd(f, func(o *Options) error {
			return nil
		})

		// IsAuthCheckEnabled assumes commands under test are subcommands
		parent := &cobra.Command{Use: "root"}
		parent.AddCommand(cmd)

		require.NoError(t, cmd.ParseFlags([]string{"--bundle", "not-important"}))
		require.False(t, cmdutil.IsAuthCheckEnabled(cmd), "expected auth check not to be required due to --bundle flag")
	})
}
pkg/cmd/attestation/verify/verify_test.go:323pkg/cmd/attestation/verify/verify_test::by default auth check is required · Go · 12 lines
t.Run("by default auth check is required", func(t *testing.T) {
	cmd := NewVerifyCmd(f, func(o *Options) error {
		return nil
	})

	// IsAuthCheckEnabled assumes commands under test are subcommands
	parent := &cobra.Command{Use: "root"}
	parent.AddCommand(cmd)

	require.NoError(t, cmd.ParseFlags([]string{}))
	require.True(t, cmdutil.IsAuthCheckEnabled(cmd), "expected auth check to be required")
})
+ 1 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:123Markdown · 17 words
TESTS
pkg/cmd/attestation/verify/verify_test.go:373pkg/cmd/attestation/verify/verify_test::TestRunVerify · Go · 166 lines
func TestRunVerify(t *testing.T) {
	logger := io.NewTestHandler()

	publicGoodOpts := Options{
		ArtifactPath:     artifactPath,
		BundlePath:       bundlePath,
		DigestAlgorithm:  "sha512",
		APIClient:        api.NewTestClient(),
		Logger:           logger,
		OCIClient:        oci.MockClient{},
		OIDCIssuer:       verification.GitHubOIDCIssuer,
		Owner:            "sigstore",
		PredicateType:    verification.SLSAPredicateV1,
		SANRegex:         "^https://github.com/sigstore/",
		SigstoreVerifier: verification.NewMockSigstoreVerifier(t),
	}

	t.Run("with valid artifact and bundle", func(t *testing.T) {
		require.NoError(t, runVerify(&publicGoodOpts))
	})

	t.Run("with failing OCI artifact fetch", func(t *testing.T) {
		opts := publicGoodOpts
		opts.ArtifactPath = "oci://ghcr.io/github/test"
		opts.OCIClient = oci.ReferenceFailClient{}

		err := runVerify(&opts)
		require.Error(t, err)
		require.ErrorContains(t, err, "failed to parse reference")
	})
+ 136 more lines · read full file
pkg/cmd/attestation/verify/verify_test.go:390pkg/cmd/attestation/verify/verify_test::with valid artifact and bundle · Go · 3 lines
t.Run("with valid artifact and bundle", func(t *testing.T) {
	require.NoError(t, runVerify(&publicGoodOpts))
})
pkg/cmd/attestation/verify/verify_test.go:394pkg/cmd/attestation/verify/verify_test::with failing OCI artifact fetch · Go · 9 lines
t.Run("with failing OCI artifact fetch", func(t *testing.T) {
	opts := publicGoodOpts
	opts.ArtifactPath = "oci://ghcr.io/github/test"
	opts.OCIClient = oci.ReferenceFailClient{}

	err := runVerify(&opts)
	require.Error(t, err)
	require.ErrorContains(t, err, "failed to parse reference")
})
+ 15 more tests · open all in source
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:124Markdown · 10 words
TESTS
pkg/cmd/attestation/verify/verify_test.go:36pkg/cmd/attestation/verify/verify_test::TestNewVerifyCmd · Go · 283 lines
func TestNewVerifyCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	var testReg httpmock.Registry
	var metaResp = api.MetaResponse{
		Domains: api.Domain{
			ArtifactAttestations: api.ArtifactAttestations{
				TrustDomain: "foo",
			},
		},
	}
	testReg.Register(httpmock.REST(http.MethodGet, "meta"),
		httpmock.StatusJSONResponse(200, &metaResp))

	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			reg := &testReg
			client := &http.Client{}
			httpmock.ReplaceTripper(client, reg)
			return client, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	testcases := []struct {
		name          string
		cli           string
		wants         Options
+ 253 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:125Markdown · 9 words
TESTS
pkg/cmd/attestation/verify/verify_test.go:36pkg/cmd/attestation/verify/verify_test::TestNewVerifyCmd · Go · 283 lines
func TestNewVerifyCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	var testReg httpmock.Registry
	var metaResp = api.MetaResponse{
		Domains: api.Domain{
			ArtifactAttestations: api.ArtifactAttestations{
				TrustDomain: "foo",
			},
		},
	}
	testReg.Register(httpmock.REST(http.MethodGet, "meta"),
		httpmock.StatusJSONResponse(200, &metaResp))

	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			reg := &testReg
			client := &http.Client{}
			httpmock.ReplaceTripper(client, reg)
			return client, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	testcases := []struct {
		name          string
		cli           string
		wants         Options
+ 253 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:126Markdown · 12 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:128Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:129Markdown · 11 words
TESTS
pkg/cmd/attestation/verify/verify_test.go:36pkg/cmd/attestation/verify/verify_test::TestNewVerifyCmd · Go · 283 lines
func TestNewVerifyCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	var testReg httpmock.Registry
	var metaResp = api.MetaResponse{
		Domains: api.Domain{
			ArtifactAttestations: api.ArtifactAttestations{
				TrustDomain: "foo",
			},
		},
	}
	testReg.Register(httpmock.REST(http.MethodGet, "meta"),
		httpmock.StatusJSONResponse(200, &metaResp))

	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			reg := &testReg
			client := &http.Client{}
			httpmock.ReplaceTripper(client, reg)
			return client, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	testcases := []struct {
		name          string
		cli           string
		wants         Options
+ 253 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:130Markdown · 3 words
TESTS
pkg/cmd/attestation/verify/verify_test.go:36pkg/cmd/attestation/verify/verify_test::TestNewVerifyCmd · Go · 283 lines
func TestNewVerifyCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	var testReg httpmock.Registry
	var metaResp = api.MetaResponse{
		Domains: api.Domain{
			ArtifactAttestations: api.ArtifactAttestations{
				TrustDomain: "foo",
			},
		},
	}
	testReg.Register(httpmock.REST(http.MethodGet, "meta"),
		httpmock.StatusJSONResponse(200, &metaResp))

	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			reg := &testReg
			client := &http.Client{}
			httpmock.ReplaceTripper(client, reg)
			return client, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	testcases := []struct {
		name          string
		cli           string
		wants         Options
+ 253 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:131Markdown · 4 words
TESTS
pkg/cmd/attestation/verify/verify_test.go:36pkg/cmd/attestation/verify/verify_test::TestNewVerifyCmd · Go · 283 lines
func TestNewVerifyCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	var testReg httpmock.Registry
	var metaResp = api.MetaResponse{
		Domains: api.Domain{
			ArtifactAttestations: api.ArtifactAttestations{
				TrustDomain: "foo",
			},
		},
	}
	testReg.Register(httpmock.REST(http.MethodGet, "meta"),
		httpmock.StatusJSONResponse(200, &metaResp))

	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			reg := &testReg
			client := &http.Client{}
			httpmock.ReplaceTripper(client, reg)
			return client, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	testcases := []struct {
		name          string
		cli           string
		wants         Options
+ 253 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:132Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:133Markdown · 6 words
TESTS
pkg/cmd/attestation/verify/verify_test.go:36pkg/cmd/attestation/verify/verify_test::TestNewVerifyCmd · Go · 283 lines
func TestNewVerifyCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	var testReg httpmock.Registry
	var metaResp = api.MetaResponse{
		Domains: api.Domain{
			ArtifactAttestations: api.ArtifactAttestations{
				TrustDomain: "foo",
			},
		},
	}
	testReg.Register(httpmock.REST(http.MethodGet, "meta"),
		httpmock.StatusJSONResponse(200, &metaResp))

	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			reg := &testReg
			client := &http.Client{}
			httpmock.ReplaceTripper(client, reg)
			return client, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	testcases := []struct {
		name          string
		cli           string
		wants         Options
+ 253 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:134Markdown · 10 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:135Markdown · 7 words
TESTS
pkg/cmd/attestation/verify/verify_test.go:36pkg/cmd/attestation/verify/verify_test::TestNewVerifyCmd · Go · 283 lines
func TestNewVerifyCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	var testReg httpmock.Registry
	var metaResp = api.MetaResponse{
		Domains: api.Domain{
			ArtifactAttestations: api.ArtifactAttestations{
				TrustDomain: "foo",
			},
		},
	}
	testReg.Register(httpmock.REST(http.MethodGet, "meta"),
		httpmock.StatusJSONResponse(200, &metaResp))

	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			reg := &testReg
			client := &http.Client{}
			httpmock.ReplaceTripper(client, reg)
			return client, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	testcases := []struct {
		name          string
		cli           string
		wants         Options
+ 253 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:136Markdown · 10 words
TESTS
pkg/cmd/attestation/verify/verify_test.go:36pkg/cmd/attestation/verify/verify_test::TestNewVerifyCmd · Go · 283 lines
func TestNewVerifyCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	var testReg httpmock.Registry
	var metaResp = api.MetaResponse{
		Domains: api.Domain{
			ArtifactAttestations: api.ArtifactAttestations{
				TrustDomain: "foo",
			},
		},
	}
	testReg.Register(httpmock.REST(http.MethodGet, "meta"),
		httpmock.StatusJSONResponse(200, &metaResp))

	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			reg := &testReg
			client := &http.Client{}
			httpmock.ReplaceTripper(client, reg)
			return client, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	testcases := []struct {
		name          string
		cli           string
		wants         Options
+ 253 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:137Markdown · 6 words
TESTS
pkg/cmd/attestation/verify/verify_test.go:36pkg/cmd/attestation/verify/verify_test::TestNewVerifyCmd · Go · 283 lines
func TestNewVerifyCmd(t *testing.T) {
	testIO, _, _, _ := iostreams.Test()
	var testReg httpmock.Registry
	var metaResp = api.MetaResponse{
		Domains: api.Domain{
			ArtifactAttestations: api.ArtifactAttestations{
				TrustDomain: "foo",
			},
		},
	}
	testReg.Register(httpmock.REST(http.MethodGet, "meta"),
		httpmock.StatusJSONResponse(200, &metaResp))

	f := &cmdutil.Factory{
		IOStreams: testIO,
		HttpClient: func() (*http.Client, error) {
			reg := &testReg
			client := &http.Client{}
			httpmock.ReplaceTripper(client, reg)
			return client, nil
		},
		ExternalHttpClient: func() (*http.Client, error) {
			return nil, nil
		},
	}

	testcases := []struct {
		name          string
		cli           string
		wants         Options
+ 253 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:138Markdown · 13 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:141Markdown · 13 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:142Markdown · 14 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh attestation verify
short: Verify the integrity and provenance of an artifact using its associated
long: |-
    cryptographically signed attestations.

    ## Understanding Verification

    An attestation is a claim (i.e. a provenance statement) made by an actor
DOCS
gh_attestation_verify.md:143Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh auth
short: Authenticate gh and git with GitHub
pname: gh
plink: gh.yaml
TESTS

N/A

EXAMPLES

N/A

CONTRACT
command: gh auth login
short: Authenticate with a GitHub host.
long: |-
    The default hostname is `github.com`. This can be overridden using the `--hostname`
    flag.

    The default authentication mode is a web-based browser flow. After completion, an
    authentication token will be stored securely in the system credential store.
    If a credential store is not found or there is an issue using it gh will fallback
    to writing the token to a plain text file. See `gh auth status` for its
    stored location.
TESTS
pkg/cmd/auth/login/login_test.go:36pkg/cmd/auth/login/login_test::Test_NewCmdLogin · Go · 264 lines
func Test_NewCmdLogin(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		stdin       string
		stdinTTY    bool
		defaultHost string
		wants       LoginOptions
		wantsErr    bool
	}{
		{
			name:  "nontty, with-token",
			stdin: "abc123\n",
			cli:   "--with-token",
			wants: LoginOptions{
				Hostname: "github.com",
				Token:    "abc123",
			},
		},
		{
			name:        "nontty, with-token, enterprise default host",
			stdin:       "abc123\n",
			cli:         "--with-token",
			defaultHost: "git.example.com",
			wants: LoginOptions{
				Hostname: "git.example.com",
				Token:    "abc123",
			},
		},
		{
+ 234 more lines · read full file
pkg/cmd/auth/login/login_test.go:301pkg/cmd/auth/login/login_test::Test_loginRun_nontty · Go · 218 lines
func Test_loginRun_nontty(t *testing.T) {
	tests := []struct {
		name            string
		opts            *LoginOptions
		env             map[string]string
		httpStubs       func(*httpmock.Registry)
		cfgStubs        func(*testing.T, gh.Config)
		wantHosts       string
		wantErr         string
		wantStderr      string
		wantSecureToken string
	}{
		{
			name: "insecure with token",
			opts: &LoginOptions{
				Hostname:        "github.com",
				Token:           "abc123",
				InsecureStorage: true,
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.REST("GET", ""), httpmock.ScopesResponder("repo,read:org"))
				reg.Register(
					httpmock.GraphQL(`query UserCurrent\b`),
					httpmock.StringResponse(`{"data":{"viewer":{"login":"monalisa"}}}`))
			},
			wantHosts: "github.com:\n    users:\n        monalisa:\n            oauth_token: abc123\n    oauth_token: abc123\n    user: monalisa\n",
		},
		{
			name: "insecure with token and https git-protocol",
			opts: &LoginOptions{
+ 188 more lines · read full file
pkg/cmd/auth/login/login_test.go:520pkg/cmd/auth/login/login_test::Test_loginRun_Survey · Go · 314 lines
func Test_loginRun_Survey(t *testing.T) {
	stubHomeDir(t, t.TempDir())

	tests := []struct {
		name            string
		opts            *LoginOptions
		httpStubs       func(*httpmock.Registry)
		prompterStubs   func(*prompter.PrompterMock)
		runStubs        func(*run.CommandStubber)
		cfgStubs        func(*testing.T, gh.Config)
		wantHosts       string
		wantErrOut      *regexp.Regexp
		wantSecureToken string
	}{
		{
			name: "hostname set",
			opts: &LoginOptions{
				Hostname:        "rebecca.chambers",
				Interactive:     true,
				InsecureStorage: true,
			},
			wantHosts: heredoc.Doc(`
                rebecca.chambers:
                    users:
                        jillv:
                            oauth_token: def456
                    git_protocol: https
                    oauth_token: def456
                    user: jillv
            `),
+ 284 more lines · read full file
+ 1 more tests · open all in source
EXAMPLES
CONTRACT
command: gh auth login
short: Authenticate with a GitHub host.
long: |-
    The default hostname is `github.com`. This can be overridden using the `--hostname`
    flag.

    The default authentication mode is a web-based browser flow. After completion, an
    authentication token will be stored securely in the system credential store.
    If a credential store is not found or there is an issue using it gh will fallback
    to writing the token to a plain text file. See `gh auth status` for its
    stored location.
DOCS
gh_auth_login.md:52Markdown · 7 words
TESTS
pkg/cmd/auth/login/login_test.go:36pkg/cmd/auth/login/login_test::Test_NewCmdLogin · Go · 264 lines
func Test_NewCmdLogin(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		stdin       string
		stdinTTY    bool
		defaultHost string
		wants       LoginOptions
		wantsErr    bool
	}{
		{
			name:  "nontty, with-token",
			stdin: "abc123\n",
			cli:   "--with-token",
			wants: LoginOptions{
				Hostname: "github.com",
				Token:    "abc123",
			},
		},
		{
			name:        "nontty, with-token, enterprise default host",
			stdin:       "abc123\n",
			cli:         "--with-token",
			defaultHost: "git.example.com",
			wants: LoginOptions{
				Hostname: "git.example.com",
				Token:    "abc123",
			},
		},
		{
+ 234 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth login
short: Authenticate with a GitHub host.
long: |-
    The default hostname is `github.com`. This can be overridden using the `--hostname`
    flag.

    The default authentication mode is a web-based browser flow. After completion, an
    authentication token will be stored securely in the system credential store.
    If a credential store is not found or there is an issue using it gh will fallback
    to writing the token to a plain text file. See `gh auth status` for its
    stored location.
DOCS
gh_auth_login.md:53Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh auth login
short: Authenticate with a GitHub host.
long: |-
    The default hostname is `github.com`. This can be overridden using the `--hostname`
    flag.

    The default authentication mode is a web-based browser flow. After completion, an
    authentication token will be stored securely in the system credential store.
    If a credential store is not found or there is an issue using it gh will fallback
    to writing the token to a plain text file. See `gh auth status` for its
    stored location.
DOCS
gh_auth_login.md:54Markdown · 9 words
TESTS
pkg/cmd/auth/login/login_test.go:36pkg/cmd/auth/login/login_test::Test_NewCmdLogin · Go · 264 lines
func Test_NewCmdLogin(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		stdin       string
		stdinTTY    bool
		defaultHost string
		wants       LoginOptions
		wantsErr    bool
	}{
		{
			name:  "nontty, with-token",
			stdin: "abc123\n",
			cli:   "--with-token",
			wants: LoginOptions{
				Hostname: "github.com",
				Token:    "abc123",
			},
		},
		{
			name:        "nontty, with-token, enterprise default host",
			stdin:       "abc123\n",
			cli:         "--with-token",
			defaultHost: "git.example.com",
			wants: LoginOptions{
				Hostname: "git.example.com",
				Token:    "abc123",
			},
		},
		{
+ 234 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth login
short: Authenticate with a GitHub host.
long: |-
    The default hostname is `github.com`. This can be overridden using the `--hostname`
    flag.

    The default authentication mode is a web-based browser flow. After completion, an
    authentication token will be stored securely in the system credential store.
    If a credential store is not found or there is an issue using it gh will fallback
    to writing the token to a plain text file. See `gh auth status` for its
    stored location.
DOCS
gh_auth_login.md:55Markdown · 10 words
TESTS
pkg/cmd/auth/login/login_test.go:36pkg/cmd/auth/login/login_test::Test_NewCmdLogin · Go · 264 lines
func Test_NewCmdLogin(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		stdin       string
		stdinTTY    bool
		defaultHost string
		wants       LoginOptions
		wantsErr    bool
	}{
		{
			name:  "nontty, with-token",
			stdin: "abc123\n",
			cli:   "--with-token",
			wants: LoginOptions{
				Hostname: "github.com",
				Token:    "abc123",
			},
		},
		{
			name:        "nontty, with-token, enterprise default host",
			stdin:       "abc123\n",
			cli:         "--with-token",
			defaultHost: "git.example.com",
			wants: LoginOptions{
				Hostname: "git.example.com",
				Token:    "abc123",
			},
		},
		{
+ 234 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh auth login
short: Authenticate with a GitHub host.
long: |-
    The default hostname is `github.com`. This can be overridden using the `--hostname`
    flag.

    The default authentication mode is a web-based browser flow. After completion, an
    authentication token will be stored securely in the system credential store.
    If a credential store is not found or there is an issue using it gh will fallback
    to writing the token to a plain text file. See `gh auth status` for its
    stored location.
DOCS
gh_auth_login.md:56Markdown · 5 words
TESTS
pkg/cmd/auth/login/login_test.go:36pkg/cmd/auth/login/login_test::Test_NewCmdLogin · Go · 264 lines
func Test_NewCmdLogin(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		stdin       string
		stdinTTY    bool
		defaultHost string
		wants       LoginOptions
		wantsErr    bool
	}{
		{
			name:  "nontty, with-token",
			stdin: "abc123\n",
			cli:   "--with-token",
			wants: LoginOptions{
				Hostname: "github.com",
				Token:    "abc123",
			},
		},
		{
			name:        "nontty, with-token, enterprise default host",
			stdin:       "abc123\n",
			cli:         "--with-token",
			defaultHost: "git.example.com",
			wants: LoginOptions{
				Hostname: "git.example.com",
				Token:    "abc123",
			},
		},
		{
+ 234 more lines · read full file
EXAMPLES

N/A

CONTRACT
command: gh auth login
short: Authenticate with a GitHub host.
long: |-
    The default hostname is `github.com`. This can be overridden using the `--hostname`
    flag.

    The default authentication mode is a web-based browser flow. After completion, an
    authentication token will be stored securely in the system credential store.
    If a credential store is not found or there is an issue using it gh will fallback
    to writing the token to a plain text file. See `gh auth status` for its
    stored location.
DOCS
gh_auth_login.md:57Markdown · 5 words
TESTS
pkg/cmd/auth/login/login_test.go:36pkg/cmd/auth/login/login_test::Test_NewCmdLogin · Go · 264 lines
func Test_NewCmdLogin(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		stdin       string
		stdinTTY    bool
		defaultHost string
		wants       LoginOptions
		wantsErr    bool
	}{
		{
			name:  "nontty, with-token",
			stdin: "abc123\n",
			cli:   "--with-token",
			wants: LoginOptions{
				Hostname: "github.com",
				Token:    "abc123",
			},
		},
		{
			name:        "nontty, with-token, enterprise default host",
			stdin:       "abc123\n",
			cli:         "--with-token",
			defaultHost: "git.example.com",
			wants: LoginOptions{
				Hostname: "git.example.com",
				Token:    "abc123",
			},
		},
		{
+ 234 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh auth login
short: Authenticate with a GitHub host.
long: |-
    The default hostname is `github.com`. This can be overridden using the `--hostname`
    flag.

    The default authentication mode is a web-based browser flow. After completion, an
    authentication token will be stored securely in the system credential store.
    If a credential store is not found or there is an issue using it gh will fallback
    to writing the token to a plain text file. See `gh auth status` for its
    stored location.
DOCS
gh_auth_login.md:58Markdown · 5 words
TESTS
pkg/cmd/auth/login/login_test.go:36pkg/cmd/auth/login/login_test::Test_NewCmdLogin · Go · 264 lines
func Test_NewCmdLogin(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		stdin       string
		stdinTTY    bool
		defaultHost string
		wants       LoginOptions
		wantsErr    bool
	}{
		{
			name:  "nontty, with-token",
			stdin: "abc123\n",
			cli:   "--with-token",
			wants: LoginOptions{
				Hostname: "github.com",
				Token:    "abc123",
			},
		},
		{
			name:        "nontty, with-token, enterprise default host",
			stdin:       "abc123\n",
			cli:         "--with-token",
			defaultHost: "git.example.com",
			wants: LoginOptions{
				Hostname: "git.example.com",
				Token:    "abc123",
			},
		},
		{
+ 234 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth login
short: Authenticate with a GitHub host.
long: |-
    The default hostname is `github.com`. This can be overridden using the `--hostname`
    flag.

    The default authentication mode is a web-based browser flow. After completion, an
    authentication token will be stored securely in the system credential store.
    If a credential store is not found or there is an issue using it gh will fallback
    to writing the token to a plain text file. See `gh auth status` for its
    stored location.
DOCS
gh_auth_login.md:59Markdown · 5 words
TESTS
pkg/cmd/auth/login/login_test.go:36pkg/cmd/auth/login/login_test::Test_NewCmdLogin · Go · 264 lines
func Test_NewCmdLogin(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		stdin       string
		stdinTTY    bool
		defaultHost string
		wants       LoginOptions
		wantsErr    bool
	}{
		{
			name:  "nontty, with-token",
			stdin: "abc123\n",
			cli:   "--with-token",
			wants: LoginOptions{
				Hostname: "github.com",
				Token:    "abc123",
			},
		},
		{
			name:        "nontty, with-token, enterprise default host",
			stdin:       "abc123\n",
			cli:         "--with-token",
			defaultHost: "git.example.com",
			wants: LoginOptions{
				Hostname: "git.example.com",
				Token:    "abc123",
			},
		},
		{
+ 234 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth logout
short: Remove authentication for a GitHub account.
long: |-
    This command removes the stored authentication configuration
    for an account. The authentication configuration is only
    removed locally.

    This command does not revoke authentication tokens.
pname: gh auth
plink: gh_auth.yaml
options:
    - option: hostname
DOCS
gh_auth_logout.md:1Markdown · 97 words
TESTS
pkg/cmd/auth/logout/logout_test.go:18pkg/cmd/auth/logout/logout_test::Test_NewCmdLogout · Go · 99 lines
func Test_NewCmdLogout(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants LogoutOptions
		tty   bool
	}{
		{
			name:  "nontty no arguments",
			cli:   "",
			wants: LogoutOptions{},
		},
		{
			name:  "tty no arguments",
			tty:   true,
			cli:   "",
			wants: LogoutOptions{},
		},
		{
			name: "tty with hostname",
			tty:  true,
			cli:  "--hostname github.com",
			wants: LogoutOptions{
				Hostname: "github.com",
			},
		},
		{
			name: "nontty with hostname",
			cli:  "--hostname github.com",
			wants: LogoutOptions{
+ 69 more lines · read full file
pkg/cmd/auth/logout/logout_test.go:130pkg/cmd/auth/logout/logout_test::Test_logoutRun_tty · Go · 236 lines
func Test_logoutRun_tty(t *testing.T) {
	tests := []struct {
		name          string
		opts          *LogoutOptions
		prompterStubs func(*prompter.PrompterMock)
		cfgHosts      []hostUsers
		secureStorage bool
		wantHosts     string
		assertToken   tokenAssertion
		wantErrOut    *regexp.Regexp
		wantErr       string
	}{
		{
			name: "logs out prompted user when multiple known hosts with one user each",
			opts: &LogoutOptions{},
			cfgHosts: []hostUsers{
				{"ghe.io", []user{
					{"monalisa-ghe", "abc123"},
				}},
				{"github.com", []user{
					{"monalisa", "abc123"},
				}},
			},
			prompterStubs: func(pm *prompter.PrompterMock) {
				pm.SelectFunc = func(_, _ string, opts []string) (int, error) {
					return prompter.IndexFor(opts, "monalisa (github.com)")
				}
			},
			assertToken: hasNoToken("github.com"),
			wantHosts:   "ghe.io:\n    users:\n        monalisa-ghe:\n            oauth_token: abc123\n    git_protocol: ssh\n    oauth_token: abc123\n    user: monalisa-ghe\n",
+ 206 more lines · read full file
pkg/cmd/auth/logout/logout_test.go:367pkg/cmd/auth/logout/logout_test::Test_logoutRun_nontty · Go · 187 lines
func Test_logoutRun_nontty(t *testing.T) {
	tests := []struct {
		name          string
		opts          *LogoutOptions
		cfgHosts      []hostUsers
		secureStorage bool
		wantHosts     string
		assertToken   tokenAssertion
		wantErrOut    *regexp.Regexp
		wantErr       string
	}{
		{
			name: "logs out specified user when one known host",
			opts: &LogoutOptions{
				Hostname: "github.com",
				Username: "monalisa",
			},
			cfgHosts: []hostUsers{
				{"github.com", []user{
					{"monalisa", "abc123"},
				}},
			},
			wantHosts:   "{}\n",
			assertToken: hasNoToken("github.com"),
			wantErrOut:  regexp.MustCompile(`Logged out of github.com account monalisa`),
		},
		{
			name: "logs out specified user when multiple known hosts",
			opts: &LogoutOptions{
				Hostname: "github.com",
+ 157 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth logout
short: Remove authentication for a GitHub account.
long: |-
    This command removes the stored authentication configuration
    for an account. The authentication configuration is only
    removed locally.

    This command does not revoke authentication tokens.
pname: gh auth
plink: gh_auth.yaml
options:
    - option: hostname
DOCS
gh_auth_logout.md:39Markdown · 10 words
TESTS
pkg/cmd/auth/logout/logout_test.go:18pkg/cmd/auth/logout/logout_test::Test_NewCmdLogout · Go · 99 lines
func Test_NewCmdLogout(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants LogoutOptions
		tty   bool
	}{
		{
			name:  "nontty no arguments",
			cli:   "",
			wants: LogoutOptions{},
		},
		{
			name:  "tty no arguments",
			tty:   true,
			cli:   "",
			wants: LogoutOptions{},
		},
		{
			name: "tty with hostname",
			tty:  true,
			cli:  "--hostname github.com",
			wants: LogoutOptions{
				Hostname: "github.com",
			},
		},
		{
			name: "nontty with hostname",
			cli:  "--hostname github.com",
			wants: LogoutOptions{
+ 69 more lines · read full file
pkg/cmd/auth/logout/logout_test.go:367pkg/cmd/auth/logout/logout_test::Test_logoutRun_nontty · Go · 187 lines
func Test_logoutRun_nontty(t *testing.T) {
	tests := []struct {
		name          string
		opts          *LogoutOptions
		cfgHosts      []hostUsers
		secureStorage bool
		wantHosts     string
		assertToken   tokenAssertion
		wantErrOut    *regexp.Regexp
		wantErr       string
	}{
		{
			name: "logs out specified user when one known host",
			opts: &LogoutOptions{
				Hostname: "github.com",
				Username: "monalisa",
			},
			cfgHosts: []hostUsers{
				{"github.com", []user{
					{"monalisa", "abc123"},
				}},
			},
			wantHosts:   "{}\n",
			assertToken: hasNoToken("github.com"),
			wantErrOut:  regexp.MustCompile(`Logged out of github.com account monalisa`),
		},
		{
			name: "logs out specified user when multiple known hosts",
			opts: &LogoutOptions{
				Hostname: "github.com",
+ 157 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth logout
short: Remove authentication for a GitHub account.
long: |-
    This command removes the stored authentication configuration
    for an account. The authentication configuration is only
    removed locally.

    This command does not revoke authentication tokens.
pname: gh auth
plink: gh_auth.yaml
options:
    - option: hostname
DOCS
gh_auth_logout.md:40Markdown · 6 words
TESTS
pkg/cmd/auth/logout/logout_test.go:18pkg/cmd/auth/logout/logout_test::Test_NewCmdLogout · Go · 99 lines
func Test_NewCmdLogout(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants LogoutOptions
		tty   bool
	}{
		{
			name:  "nontty no arguments",
			cli:   "",
			wants: LogoutOptions{},
		},
		{
			name:  "tty no arguments",
			tty:   true,
			cli:   "",
			wants: LogoutOptions{},
		},
		{
			name: "tty with hostname",
			tty:  true,
			cli:  "--hostname github.com",
			wants: LogoutOptions{
				Hostname: "github.com",
			},
		},
		{
			name: "nontty with hostname",
			cli:  "--hostname github.com",
			wants: LogoutOptions{
+ 69 more lines · read full file
pkg/cmd/auth/logout/logout_test.go:367pkg/cmd/auth/logout/logout_test::Test_logoutRun_nontty · Go · 187 lines
func Test_logoutRun_nontty(t *testing.T) {
	tests := []struct {
		name          string
		opts          *LogoutOptions
		cfgHosts      []hostUsers
		secureStorage bool
		wantHosts     string
		assertToken   tokenAssertion
		wantErrOut    *regexp.Regexp
		wantErr       string
	}{
		{
			name: "logs out specified user when one known host",
			opts: &LogoutOptions{
				Hostname: "github.com",
				Username: "monalisa",
			},
			cfgHosts: []hostUsers{
				{"github.com", []user{
					{"monalisa", "abc123"},
				}},
			},
			wantHosts:   "{}\n",
			assertToken: hasNoToken("github.com"),
			wantErrOut:  regexp.MustCompile(`Logged out of github.com account monalisa`),
		},
		{
			name: "logs out specified user when multiple known hosts",
			opts: &LogoutOptions{
				Hostname: "github.com",
+ 157 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth refresh
short: Expand or fix the permission scopes for stored credentials for active account.
long: |-
    The `--scopes` flag accepts a comma separated list of scopes you want
    your gh credentials to have. If no scopes are provided, the command
    maintains previously added scopes.

    The `--remove-scopes` flag accepts a comma separated list of scopes you
    want to remove from your gh credentials. Scope removal is idempotent.
    The minimum set of scopes (`repo`, `read:org`, and `gist`) cannot be removed.
DOCS
gh_auth_refresh.md:1Markdown · 155 words
TESTS
pkg/cmd/auth/refresh/refresh_test.go:20pkg/cmd/auth/refresh/refresh_test::Test_NewCmdRefresh · Go · 179 lines
func Test_NewCmdRefresh(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		wants       RefreshOptions
		wantsErr    bool
		tty         bool
		neverPrompt bool
	}{
		{
			name: "tty no arguments",
			tty:  true,
			wants: RefreshOptions{
				Hostname: "",
			},
		},
		{
			name: "tty clipboard",
			tty:  true,
			cli:  "-c",
			wants: RefreshOptions{
				Hostname:  "",
				Clipboard: true,
			},
		},
		{
			name:     "nontty no arguments",
			wantsErr: true,
		},
		{
+ 149 more lines · read full file
pkg/cmd/auth/refresh/refresh_test.go:214pkg/cmd/auth/refresh/refresh_test::Test_refreshRun · Go · 334 lines
func Test_refreshRun(t *testing.T) {
	tests := []struct {
		name          string
		opts          *RefreshOptions
		prompterStubs func(*prompter.PrompterMock)
		cfgHosts      []string
		authOut       authOut
		oldScopes     string
		wantErr       string
		nontty        bool
		wantAuthArgs  authArgs
	}{
		{
			name:    "no hosts configured",
			opts:    &RefreshOptions{},
			wantErr: `not logged in to any hosts`,
		},
		{
			name: "hostname given but not previously authenticated with it",
			cfgHosts: []string{
				"github.com",
				"aline.cedrac",
			},
			opts: &RefreshOptions{
				Hostname: "obed.morton",
			},
			wantErr: `not logged in to obed.morton`,
		},
		{
			name: "hostname provided and is configured",
+ 304 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth refresh
short: Expand or fix the permission scopes for stored credentials for active account.
long: |-
    The `--scopes` flag accepts a comma separated list of scopes you want
    your gh credentials to have. If no scopes are provided, the command
    maintains previously added scopes.

    The `--remove-scopes` flag accepts a comma separated list of scopes you
    want to remove from your gh credentials. Scope removal is idempotent.
    The minimum set of scopes (`repo`, `read:org`, and `gist`) cannot be removed.
DOCS
gh_auth_refresh.md:38Markdown · 7 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth refresh
short: Expand or fix the permission scopes for stored credentials for active account.
long: |-
    The `--scopes` flag accepts a comma separated list of scopes you want
    your gh credentials to have. If no scopes are provided, the command
    maintains previously added scopes.

    The `--remove-scopes` flag accepts a comma separated list of scopes you
    want to remove from your gh credentials. Scope removal is idempotent.
    The minimum set of scopes (`repo`, `read:org`, and `gist`) cannot be removed.
DOCS
gh_auth_refresh.md:39Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh auth refresh
short: Expand or fix the permission scopes for stored credentials for active account.
long: |-
    The `--scopes` flag accepts a comma separated list of scopes you want
    your gh credentials to have. If no scopes are provided, the command
    maintains previously added scopes.

    The `--remove-scopes` flag accepts a comma separated list of scopes you
    want to remove from your gh credentials. Scope removal is idempotent.
    The minimum set of scopes (`repo`, `read:org`, and `gist`) cannot be removed.
DOCS
gh_auth_refresh.md:40Markdown · 10 words
TESTS
pkg/cmd/auth/refresh/refresh_test.go:20pkg/cmd/auth/refresh/refresh_test::Test_NewCmdRefresh · Go · 179 lines
func Test_NewCmdRefresh(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		wants       RefreshOptions
		wantsErr    bool
		tty         bool
		neverPrompt bool
	}{
		{
			name: "tty no arguments",
			tty:  true,
			wants: RefreshOptions{
				Hostname: "",
			},
		},
		{
			name: "tty clipboard",
			tty:  true,
			cli:  "-c",
			wants: RefreshOptions{
				Hostname:  "",
				Clipboard: true,
			},
		},
		{
			name:     "nontty no arguments",
			wantsErr: true,
		},
		{
+ 149 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh auth refresh
short: Expand or fix the permission scopes for stored credentials for active account.
long: |-
    The `--scopes` flag accepts a comma separated list of scopes you want
    your gh credentials to have. If no scopes are provided, the command
    maintains previously added scopes.

    The `--remove-scopes` flag accepts a comma separated list of scopes you
    want to remove from your gh credentials. Scope removal is idempotent.
    The minimum set of scopes (`repo`, `read:org`, and `gist`) cannot be removed.
DOCS
gh_auth_refresh.md:41Markdown · 6 words
TESTS
pkg/cmd/auth/refresh/refresh_test.go:20pkg/cmd/auth/refresh/refresh_test::Test_NewCmdRefresh · Go · 179 lines
func Test_NewCmdRefresh(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		wants       RefreshOptions
		wantsErr    bool
		tty         bool
		neverPrompt bool
	}{
		{
			name: "tty no arguments",
			tty:  true,
			wants: RefreshOptions{
				Hostname: "",
			},
		},
		{
			name: "tty clipboard",
			tty:  true,
			cli:  "-c",
			wants: RefreshOptions{
				Hostname:  "",
				Clipboard: true,
			},
		},
		{
			name:     "nontty no arguments",
			wantsErr: true,
		},
		{
+ 149 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth refresh
short: Expand or fix the permission scopes for stored credentials for active account.
long: |-
    The `--scopes` flag accepts a comma separated list of scopes you want
    your gh credentials to have. If no scopes are provided, the command
    maintains previously added scopes.

    The `--remove-scopes` flag accepts a comma separated list of scopes you
    want to remove from your gh credentials. Scope removal is idempotent.
    The minimum set of scopes (`repo`, `read:org`, and `gist`) cannot be removed.
DOCS
gh_auth_refresh.md:42Markdown · 10 words
TESTS
pkg/cmd/auth/refresh/refresh_test.go:20pkg/cmd/auth/refresh/refresh_test::Test_NewCmdRefresh · Go · 179 lines
func Test_NewCmdRefresh(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		wants       RefreshOptions
		wantsErr    bool
		tty         bool
		neverPrompt bool
	}{
		{
			name: "tty no arguments",
			tty:  true,
			wants: RefreshOptions{
				Hostname: "",
			},
		},
		{
			name: "tty clipboard",
			tty:  true,
			cli:  "-c",
			wants: RefreshOptions{
				Hostname:  "",
				Clipboard: true,
			},
		},
		{
			name:     "nontty no arguments",
			wantsErr: true,
		},
		{
+ 149 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth refresh
short: Expand or fix the permission scopes for stored credentials for active account.
long: |-
    The `--scopes` flag accepts a comma separated list of scopes you want
    your gh credentials to have. If no scopes are provided, the command
    maintains previously added scopes.

    The `--remove-scopes` flag accepts a comma separated list of scopes you
    want to remove from your gh credentials. Scope removal is idempotent.
    The minimum set of scopes (`repo`, `read:org`, and `gist`) cannot be removed.
DOCS
gh_auth_refresh.md:43Markdown · 7 words
TESTS
pkg/cmd/auth/refresh/refresh_test.go:20pkg/cmd/auth/refresh/refresh_test::Test_NewCmdRefresh · Go · 179 lines
func Test_NewCmdRefresh(t *testing.T) {
	tests := []struct {
		name        string
		cli         string
		wants       RefreshOptions
		wantsErr    bool
		tty         bool
		neverPrompt bool
	}{
		{
			name: "tty no arguments",
			tty:  true,
			wants: RefreshOptions{
				Hostname: "",
			},
		},
		{
			name: "tty clipboard",
			tty:  true,
			cli:  "-c",
			wants: RefreshOptions{
				Hostname:  "",
				Clipboard: true,
			},
		},
		{
			name:     "nontty no arguments",
			wantsErr: true,
		},
		{
+ 149 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth setup-git
short: This command configures `git` to use GitHub CLI as a credential helper.
pname: gh auth
plink: gh_auth.yaml
options:
    - option: force
      shorthand: f
      value_type: string
      description: Force setup even if the host is not known. Must be used in conjunction with --hostname
    - option: hostname
      shorthand: h
      value_type: string
DOCS
gh_auth_setup-git.md:1Markdown · 85 words
TESTS
pkg/cmd/auth/setupgit/setupgit_test.go:28pkg/cmd/auth/setupgit/setupgit_test::TestNewCmdSetupGit · Go · 49 lines
func TestNewCmdSetupGit(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wantsErr bool
		errMsg   string
	}{
		{
			name:     "--force without hostname",
			cli:      "--force",
			wantsErr: true,
			errMsg:   "`--force` must be used in conjunction with `--hostname`",
		},
		{
			name:     "no error when --force used with hostname",
			cli:      "--force --hostname ghe.io",
			wantsErr: false,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			f := &cmdutil.Factory{}

			argv, err := shlex.Split(tt.cli)
			require.NoError(t, err)

			cmd := NewCmdSetupGit(f, func(opts *SetupGitOptions) error {
				return nil
			})
+ 20 more lines · read full file
pkg/cmd/auth/setupgit/setupgit_test.go:77pkg/cmd/auth/setupgit/setupgit_test::Test_setupGitRun · Go · 124 lines
func Test_setupGitRun(t *testing.T) {
	tests := []struct {
		name               string
		opts               *SetupGitOptions
		setupErr           error
		cfgStubs           func(*testing.T, gh.Config)
		expectedHostsSetup []string
		expectedErr        error
		expectedErrOut     string
	}{
		{
			name: "opts.Config returns an error",
			opts: &SetupGitOptions{
				Config: func() (gh.Config, error) {
					return nil, fmt.Errorf("oops")
				},
			},
			expectedErr: errors.New("oops"),
		},
		{
			name: "when an unknown hostname is provided without forcing, return an error",
			opts: &SetupGitOptions{
				Hostname: "ghe.io",
			},
			cfgStubs: func(t *testing.T, cfg gh.Config) {
				login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", false)
			},
			expectedErr: errors.New("You are not logged into the GitHub host \"ghe.io\". Run gh auth login -h ghe.io to authenticate or provide `--force`"),
		},
		{
+ 94 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh auth setup-git
short: This command configures `git` to use GitHub CLI as a credential helper.
pname: gh auth
plink: gh_auth.yaml
options:
    - option: force
      shorthand: f
      value_type: string
      description: Force setup even if the host is not known. Must be used in conjunction with --hostname
    - option: hostname
      shorthand: h
      value_type: string
DOCS
gh_auth_setup-git.md:28Markdown · 16 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh auth setup-git
short: This command configures `git` to use GitHub CLI as a credential helper.
pname: gh auth
plink: gh_auth.yaml
options:
    - option: force
      shorthand: f
      value_type: string
      description: Force setup even if the host is not known. Must be used in conjunction with --hostname
    - option: hostname
      shorthand: h
      value_type: string
DOCS
gh_auth_setup-git.md:29Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth status
short: Display active account and authentication state on each known GitHub host.
long: |-
    For each host, the authentication state of each known account is tested and any issues are included in the output.
    Each host section will indicate the active account, which will be used when targeting that host.

    If an account on any host (or only the one given via `--hostname`) has authentication issues,
DOCS
gh_auth_status.md:1Markdown · 123 words
TESTS
pkg/cmd/auth/status/status_test.go:24pkg/cmd/auth/status/status_test::Test_NewCmdStatus · Go · 64 lines
func Test_NewCmdStatus(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants StatusOptions
	}{
		{
			name:  "no arguments",
			cli:   "",
			wants: StatusOptions{},
		},
		{
			name: "hostname set",
			cli:  "--hostname ellie.williams",
			wants: StatusOptions{
				Hostname: "ellie.williams",
			},
		},
		{
			name: "show token",
			cli:  "--show-token",
			wants: StatusOptions{
				ShowToken: true,
			},
		},
		{
			name: "active",
			cli:  "--active",
			wants: StatusOptions{
				Active: true,
+ 34 more lines · read full file
pkg/cmd/auth/status/status_test.go:89pkg/cmd/auth/status/status_test::TestJSONFields · Go · 5 lines
func TestJSONFields(t *testing.T) {
	jsonfieldstest.ExpectCommandToSupportJSONFields(t, NewCmdStatus, []string{
		"hosts",
	})
}
pkg/cmd/auth/status/status_test.go:95pkg/cmd/auth/status/status_test::Test_statusRun · Go · 668 lines
func Test_statusRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       StatusOptions
		jsonFields []string
		env        map[string]string
		httpStubs  func(*httpmock.Registry)
		cfgStubs   func(*testing.T, gh.Config)
		wantErr    error
		wantOut    string
		wantErrOut string
	}{
		{
			name: "timeout error",
			opts: StatusOptions{
				Hostname: "github.com",
			},
			cfgStubs: func(t *testing.T, c gh.Config) {
				login(t, c, "github.com", "monalisa", "abc123", "https")
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.REST("GET", ""), func(req *http.Request) (*http.Response, error) {
					// timeout error
					return nil, context.DeadlineExceeded
				})
			},
			wantErr: cmdutil.SilentError,
			wantErrOut: heredoc.Doc(`
				github.com
				  X Timeout trying to log in to github.com account monalisa (GH_CONFIG_DIR/hosts.yml)
+ 638 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth status
short: Display active account and authentication state on each known GitHub host.
long: |-
    For each host, the authentication state of each known account is tested and any issues are included in the output.
    Each host section will indicate the active account, which will be used when targeting that host.

    If an account on any host (or only the one given via `--hostname`) has authentication issues,
DOCS
gh_auth_status.md:29Markdown · 5 words
TESTS
pkg/cmd/auth/status/status_test.go:24pkg/cmd/auth/status/status_test::Test_NewCmdStatus · Go · 64 lines
func Test_NewCmdStatus(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants StatusOptions
	}{
		{
			name:  "no arguments",
			cli:   "",
			wants: StatusOptions{},
		},
		{
			name: "hostname set",
			cli:  "--hostname ellie.williams",
			wants: StatusOptions{
				Hostname: "ellie.williams",
			},
		},
		{
			name: "show token",
			cli:  "--show-token",
			wants: StatusOptions{
				ShowToken: true,
			},
		},
		{
			name: "active",
			cli:  "--active",
			wants: StatusOptions{
				Active: true,
+ 34 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth status
short: Display active account and authentication state on each known GitHub host.
long: |-
    For each host, the authentication state of each known account is tested and any issues are included in the output.
    Each host section will indicate the active account, which will be used when targeting that host.

    If an account on any host (or only the one given via `--hostname`) has authentication issues,
DOCS
gh_auth_status.md:30Markdown · 7 words
TESTS
pkg/cmd/auth/status/status_test.go:24pkg/cmd/auth/status/status_test::Test_NewCmdStatus · Go · 64 lines
func Test_NewCmdStatus(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants StatusOptions
	}{
		{
			name:  "no arguments",
			cli:   "",
			wants: StatusOptions{},
		},
		{
			name: "hostname set",
			cli:  "--hostname ellie.williams",
			wants: StatusOptions{
				Hostname: "ellie.williams",
			},
		},
		{
			name: "show token",
			cli:  "--show-token",
			wants: StatusOptions{
				ShowToken: true,
			},
		},
		{
			name: "active",
			cli:  "--active",
			wants: StatusOptions{
				Active: true,
+ 34 more lines · read full file
pkg/cmd/auth/status/status_test.go:95pkg/cmd/auth/status/status_test::Test_statusRun · Go · 668 lines
func Test_statusRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       StatusOptions
		jsonFields []string
		env        map[string]string
		httpStubs  func(*httpmock.Registry)
		cfgStubs   func(*testing.T, gh.Config)
		wantErr    error
		wantOut    string
		wantErrOut string
	}{
		{
			name: "timeout error",
			opts: StatusOptions{
				Hostname: "github.com",
			},
			cfgStubs: func(t *testing.T, c gh.Config) {
				login(t, c, "github.com", "monalisa", "abc123", "https")
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.REST("GET", ""), func(req *http.Request) (*http.Response, error) {
					// timeout error
					return nil, context.DeadlineExceeded
				})
			},
			wantErr: cmdutil.SilentError,
			wantErrOut: heredoc.Doc(`
				github.com
				  X Timeout trying to log in to github.com account monalisa (GH_CONFIG_DIR/hosts.yml)
+ 638 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth status
short: Display active account and authentication state on each known GitHub host.
long: |-
    For each host, the authentication state of each known account is tested and any issues are included in the output.
    Each host section will indicate the active account, which will be used when targeting that host.

    If an account on any host (or only the one given via `--hostname`) has authentication issues,
DOCS
gh_auth_status.md:31Markdown · 7 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth status
short: Display active account and authentication state on each known GitHub host.
long: |-
    For each host, the authentication state of each known account is tested and any issues are included in the output.
    Each host section will indicate the active account, which will be used when targeting that host.

    If an account on any host (or only the one given via `--hostname`) has authentication issues,
DOCS
gh_auth_status.md:32Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth status
short: Display active account and authentication state on each known GitHub host.
long: |-
    For each host, the authentication state of each known account is tested and any issues are included in the output.
    Each host section will indicate the active account, which will be used when targeting that host.

    If an account on any host (or only the one given via `--hostname`) has authentication issues,
DOCS
gh_auth_status.md:33Markdown · 4 words
TESTS
pkg/cmd/auth/status/status_test.go:24pkg/cmd/auth/status/status_test::Test_NewCmdStatus · Go · 64 lines
func Test_NewCmdStatus(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants StatusOptions
	}{
		{
			name:  "no arguments",
			cli:   "",
			wants: StatusOptions{},
		},
		{
			name: "hostname set",
			cli:  "--hostname ellie.williams",
			wants: StatusOptions{
				Hostname: "ellie.williams",
			},
		},
		{
			name: "show token",
			cli:  "--show-token",
			wants: StatusOptions{
				ShowToken: true,
			},
		},
		{
			name: "active",
			cli:  "--active",
			wants: StatusOptions{
				Active: true,
+ 34 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth status
short: Display active account and authentication state on each known GitHub host.
long: |-
    For each host, the authentication state of each known account is tested and any issues are included in the output.
    Each host section will indicate the active account, which will be used when targeting that host.

    If an account on any host (or only the one given via `--hostname`) has authentication issues,
DOCS
gh_auth_status.md:34Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh auth switch
short: Switch the active account for a GitHub host.
long: |-
    This command changes the authentication configuration that will
    be used when running commands targeting the specified GitHub host.

    If the specified host has two accounts, the active account will be switched
    automatically. If there are more than two accounts, disambiguation will be
    required either through the `--user` flag or an interactive prompt.

    For a list of authenticated accounts you can run `gh auth status`.
pname: gh auth
DOCS
gh_auth_switch.md:1Markdown · 82 words
TESTS
pkg/cmd/auth/switch/switch_test.go:20pkg/cmd/auth/switch/switch_test::TestNewCmdSwitch · Go · 65 lines
func TestNewCmdSwitch(t *testing.T) {
	tests := []struct {
		name           string
		input          string
		expectedOpts   SwitchOptions
		expectedErrMsg string
	}{
		{
			name:         "no flags",
			input:        "",
			expectedOpts: SwitchOptions{},
		},
		{
			name:  "hostname flag",
			input: "--hostname github.com",
			expectedOpts: SwitchOptions{
				Hostname: "github.com",
			},
		},
		{
			name:  "user flag",
			input: "--user monalisa",
			expectedOpts: SwitchOptions{
				Username: "monalisa",
			},
		},
		{
			name:           "positional args is an error",
			input:          "some-positional-arg",
			expectedErrMsg: "accepts 0 arg(s), received 1",
+ 35 more lines · read full file
pkg/cmd/auth/switch/switch_test.go:86pkg/cmd/auth/switch/switch_test::TestSwitchRun · Go · 355 lines
func TestSwitchRun(t *testing.T) {
	type user struct {
		name  string
		token string
	}

	type hostUsers struct {
		host  string
		users []user
	}

	type successfulExpectation struct {
		switchedHost string
		activeUser   string
		activeToken  string
		hostsCfg     string
		stderr       string
	}

	type failedExpectation struct {
		err    error
		stderr string
	}

	userWithMissingToken := "user-that-is-broken-by-the-test"

	tests := []struct {
		name     string
		opts     SwitchOptions
		cfgHosts []hostUsers
+ 325 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth switch
short: Switch the active account for a GitHub host.
long: |-
    This command changes the authentication configuration that will
    be used when running commands targeting the specified GitHub host.

    If the specified host has two accounts, the active account will be switched
    automatically. If there are more than two accounts, disambiguation will be
    required either through the `--user` flag or an interactive prompt.

    For a list of authenticated accounts you can run `gh auth status`.
pname: gh auth
DOCS
gh_auth_switch.md:29Markdown · 10 words
TESTS
pkg/cmd/auth/switch/switch_test.go:20pkg/cmd/auth/switch/switch_test::TestNewCmdSwitch · Go · 65 lines
func TestNewCmdSwitch(t *testing.T) {
	tests := []struct {
		name           string
		input          string
		expectedOpts   SwitchOptions
		expectedErrMsg string
	}{
		{
			name:         "no flags",
			input:        "",
			expectedOpts: SwitchOptions{},
		},
		{
			name:  "hostname flag",
			input: "--hostname github.com",
			expectedOpts: SwitchOptions{
				Hostname: "github.com",
			},
		},
		{
			name:  "user flag",
			input: "--user monalisa",
			expectedOpts: SwitchOptions{
				Username: "monalisa",
			},
		},
		{
			name:           "positional args is an error",
			input:          "some-positional-arg",
			expectedErrMsg: "accepts 0 arg(s), received 1",
+ 35 more lines · read full file
pkg/cmd/auth/switch/switch_test.go:86pkg/cmd/auth/switch/switch_test::TestSwitchRun · Go · 355 lines
func TestSwitchRun(t *testing.T) {
	type user struct {
		name  string
		token string
	}

	type hostUsers struct {
		host  string
		users []user
	}

	type successfulExpectation struct {
		switchedHost string
		activeUser   string
		activeToken  string
		hostsCfg     string
		stderr       string
	}

	type failedExpectation struct {
		err    error
		stderr string
	}

	userWithMissingToken := "user-that-is-broken-by-the-test"

	tests := []struct {
		name     string
		opts     SwitchOptions
		cfgHosts []hostUsers
+ 325 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth switch
short: Switch the active account for a GitHub host.
long: |-
    This command changes the authentication configuration that will
    be used when running commands targeting the specified GitHub host.

    If the specified host has two accounts, the active account will be switched
    automatically. If there are more than two accounts, disambiguation will be
    required either through the `--user` flag or an interactive prompt.

    For a list of authenticated accounts you can run `gh auth status`.
pname: gh auth
DOCS
gh_auth_switch.md:30Markdown · 5 words
TESTS
pkg/cmd/auth/switch/switch_test.go:20pkg/cmd/auth/switch/switch_test::TestNewCmdSwitch · Go · 65 lines
func TestNewCmdSwitch(t *testing.T) {
	tests := []struct {
		name           string
		input          string
		expectedOpts   SwitchOptions
		expectedErrMsg string
	}{
		{
			name:         "no flags",
			input:        "",
			expectedOpts: SwitchOptions{},
		},
		{
			name:  "hostname flag",
			input: "--hostname github.com",
			expectedOpts: SwitchOptions{
				Hostname: "github.com",
			},
		},
		{
			name:  "user flag",
			input: "--user monalisa",
			expectedOpts: SwitchOptions{
				Username: "monalisa",
			},
		},
		{
			name:           "positional args is an error",
			input:          "some-positional-arg",
			expectedErrMsg: "accepts 0 arg(s), received 1",
+ 35 more lines · read full file
pkg/cmd/auth/switch/switch_test.go:86pkg/cmd/auth/switch/switch_test::TestSwitchRun · Go · 355 lines
func TestSwitchRun(t *testing.T) {
	type user struct {
		name  string
		token string
	}

	type hostUsers struct {
		host  string
		users []user
	}

	type successfulExpectation struct {
		switchedHost string
		activeUser   string
		activeToken  string
		hostsCfg     string
		stderr       string
	}

	type failedExpectation struct {
		err    error
		stderr string
	}

	userWithMissingToken := "user-that-is-broken-by-the-test"

	tests := []struct {
		name     string
		opts     SwitchOptions
		cfgHosts []hostUsers
+ 325 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth token
short: This command outputs the authentication token for an account on a given GitHub host.
long: |-
    Without the `--hostname` flag, the default host is chosen.

    Without the `--user` flag, the active account for the host is chosen.
pname: gh auth
plink: gh_auth.yaml
options:
    - option: hostname
      shorthand: h
      value_type: string
DOCS
gh_auth_token.md:1Markdown · 44 words
TESTS
pkg/cmd/auth/token/token_test.go:15pkg/cmd/auth/token/token_test::TestNewCmdToken · Go · 79 lines
func TestNewCmdToken(t *testing.T) {
	tests := []struct {
		name       string
		input      string
		output     TokenOptions
		wantErr    bool
		wantErrMsg string
	}{
		{
			name:   "no flags",
			input:  "",
			output: TokenOptions{},
		},
		{
			name:   "with hostname",
			input:  "--hostname github.mycompany.com",
			output: TokenOptions{Hostname: "github.mycompany.com"},
		},
		{
			name:   "with user",
			input:  "--user test-user",
			output: TokenOptions{Username: "test-user"},
		},
		{
			name:   "with shorthand user",
			input:  "-u test-user",
			output: TokenOptions{Username: "test-user"},
		},
		{
			name:   "with shorthand hostname",
+ 49 more lines · read full file
pkg/cmd/auth/token/token_test.go:95pkg/cmd/auth/token/token_test::TestTokenRun · Go · 97 lines
func TestTokenRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       TokenOptions
		env        map[string]string
		cfgStubs   func(*testing.T, gh.Config)
		wantStdout string
		wantErr    bool
		wantErrMsg string
	}{
		{
			name: "token",
			opts: TokenOptions{},
			cfgStubs: func(t *testing.T, cfg gh.Config) {
				login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", false)
			},
			wantStdout: "gho_ABCDEFG\n",
		},
		{
			name: "token by hostname",
			opts: TokenOptions{
				Hostname: "github.mycompany.com",
			},
			cfgStubs: func(t *testing.T, cfg gh.Config) {
				login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", false)
				login(t, cfg, "github.mycompany.com", "test-user", "gho_1234567", "https", false)
			},
			wantStdout: "gho_1234567\n",
		},
		{
+ 67 more lines · read full file
pkg/cmd/auth/token/token_test.go:193pkg/cmd/auth/token/token_test::TestTokenRunSecureStorage · Go · 82 lines
func TestTokenRunSecureStorage(t *testing.T) {
	tests := []struct {
		name       string
		opts       TokenOptions
		cfgStubs   func(*testing.T, gh.Config)
		wantStdout string
		wantErr    bool
		wantErrMsg string
	}{
		{
			name: "token",
			opts: TokenOptions{},
			cfgStubs: func(t *testing.T, cfg gh.Config) {
				login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", true)
			},
			wantStdout: "gho_ABCDEFG\n",
		},
		{
			name: "token by hostname",
			opts: TokenOptions{
				Hostname: "mycompany.com",
			},
			cfgStubs: func(t *testing.T, cfg gh.Config) {
				login(t, cfg, "mycompany.com", "test-user", "gho_1234567", "https", true)
			},
			wantStdout: "gho_1234567\n",
		},
		{
			name:       "no token",
			opts:       TokenOptions{},
+ 52 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh auth token
short: This command outputs the authentication token for an account on a given GitHub host.
long: |-
    Without the `--hostname` flag, the default host is chosen.

    Without the `--user` flag, the active account for the host is chosen.
pname: gh auth
plink: gh_auth.yaml
options:
    - option: hostname
      shorthand: h
      value_type: string
DOCS
gh_auth_token.md:24Markdown · 8 words
TESTS
pkg/cmd/auth/token/token_test.go:15pkg/cmd/auth/token/token_test::TestNewCmdToken · Go · 79 lines
func TestNewCmdToken(t *testing.T) {
	tests := []struct {
		name       string
		input      string
		output     TokenOptions
		wantErr    bool
		wantErrMsg string
	}{
		{
			name:   "no flags",
			input:  "",
			output: TokenOptions{},
		},
		{
			name:   "with hostname",
			input:  "--hostname github.mycompany.com",
			output: TokenOptions{Hostname: "github.mycompany.com"},
		},
		{
			name:   "with user",
			input:  "--user test-user",
			output: TokenOptions{Username: "test-user"},
		},
		{
			name:   "with shorthand user",
			input:  "-u test-user",
			output: TokenOptions{Username: "test-user"},
		},
		{
			name:   "with shorthand hostname",
+ 49 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh auth token
short: This command outputs the authentication token for an account on a given GitHub host.
long: |-
    Without the `--hostname` flag, the default host is chosen.

    Without the `--user` flag, the active account for the host is chosen.
pname: gh auth
plink: gh_auth.yaml
options:
    - option: hostname
      shorthand: h
      value_type: string
DOCS
gh_auth_token.md:25Markdown · 7 words
TESTS
pkg/cmd/auth/token/token_test.go:15pkg/cmd/auth/token/token_test::TestNewCmdToken · Go · 79 lines
func TestNewCmdToken(t *testing.T) {
	tests := []struct {
		name       string
		input      string
		output     TokenOptions
		wantErr    bool
		wantErrMsg string
	}{
		{
			name:   "no flags",
			input:  "",
			output: TokenOptions{},
		},
		{
			name:   "with hostname",
			input:  "--hostname github.mycompany.com",
			output: TokenOptions{Hostname: "github.mycompany.com"},
		},
		{
			name:   "with user",
			input:  "--user test-user",
			output: TokenOptions{Username: "test-user"},
		},
		{
			name:   "with shorthand user",
			input:  "-u test-user",
			output: TokenOptions{Username: "test-user"},
		},
		{
			name:   "with shorthand hostname",
+ 49 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh browse
pname: gh
plink: gh.yaml
options:
    - option: actions
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Open repository actions
    - option: blame
      value_type: bool
      default_value: "false"
DOCS
gh_browse.md:1Markdown · 36 words
TESTS
pkg/cmd/browse/browse_test.go:21pkg/cmd/browse/browse_test::TestNewCmdBrowse · Go · 248 lines
func TestNewCmdBrowse(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		factory  func(*cmdutil.Factory) *cmdutil.Factory
		wants    BrowseOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: false,
		},
		{
			name: "settings flag",
			cli:  "--settings",
			wants: BrowseOptions{
				SettingsFlag: true,
			},
			wantsErr: false,
		},
		{
			name: "projects flag",
			cli:  "--projects",
			wants: BrowseOptions{
				ProjectsFlag: true,
			},
			wantsErr: false,
		},
		{
+ 218 more lines · read full file
pkg/cmd/browse/browse_test.go:276pkg/cmd/browse/browse_test::Test_runBrowse · Go · 450 lines
func Test_runBrowse(t *testing.T) {
	s := string(os.PathSeparator)
	t.Setenv("GIT_DIR", "../../../git/fixtures/simple.git")
	tests := []struct {
		name          string
		opts          BrowseOptions
		httpStub      func(*httpmock.Registry)
		baseRepo      ghrepo.Interface
		defaultBranch string
		expectedURL   string
		wantsErr      bool
	}{
		{
			name: "no arguments",
			opts: BrowseOptions{
				SelectorArg: "",
			},
			baseRepo:    ghrepo.New("jlsestak", "cli"),
			expectedURL: "https://github.com/jlsestak/cli",
		},
		{
			name: "settings flag",
			opts: BrowseOptions{
				SettingsFlag: true,
			},
			baseRepo:    ghrepo.New("bchadwic", "ObscuredByClouds"),
			expectedURL: "https://github.com/bchadwic/ObscuredByClouds/settings",
		},
		{
			name: "projects flag",
+ 420 more lines · read full file
pkg/cmd/browse/browse_test.go:727pkg/cmd/browse/browse_test::Test_parsePathFromFileArg · Go · 99 lines
func Test_parsePathFromFileArg(t *testing.T) {
	tests := []struct {
		name         string
		currentDir   string
		fileArg      string
		expectedPath string
	}{
		{
			name:         "empty paths",
			currentDir:   "",
			fileArg:      "",
			expectedPath: "",
		},
		{
			name:         "root directory",
			currentDir:   "",
			fileArg:      ".",
			expectedPath: "",
		},
		{
			name:         "relative path",
			currentDir:   "",
			fileArg:      filepath.FromSlash("foo/bar.py"),
			expectedPath: "foo/bar.py",
		},
		{
			name:         "go to parent folder",
			currentDir:   "pkg/cmd/browse/",
			fileArg:      filepath.FromSlash("../"),
			expectedPath: "pkg/cmd",
+ 69 more lines · read full file
+ 4 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh browse
pname: gh
plink: gh.yaml
options:
    - option: actions
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Open repository actions
    - option: blame
      value_type: bool
      default_value: "false"
DOCS
gh_browse.md:26Markdown · 3 words
TESTS
pkg/cmd/browse/browse_test.go:21pkg/cmd/browse/browse_test::TestNewCmdBrowse · Go · 248 lines
func TestNewCmdBrowse(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		factory  func(*cmdutil.Factory) *cmdutil.Factory
		wants    BrowseOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: false,
		},
		{
			name: "settings flag",
			cli:  "--settings",
			wants: BrowseOptions{
				SettingsFlag: true,
			},
			wantsErr: false,
		},
		{
			name: "projects flag",
			cli:  "--projects",
			wants: BrowseOptions{
				ProjectsFlag: true,
			},
			wantsErr: false,
		},
		{
+ 218 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh browse
pname: gh
plink: gh.yaml
options:
    - option: actions
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Open repository actions
    - option: blame
      value_type: bool
      default_value: "false"
DOCS
gh_browse.md:27Markdown · 6 words
TESTS
pkg/cmd/browse/browse_test.go:21pkg/cmd/browse/browse_test::TestNewCmdBrowse · Go · 248 lines
func TestNewCmdBrowse(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		factory  func(*cmdutil.Factory) *cmdutil.Factory
		wants    BrowseOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: false,
		},
		{
			name: "settings flag",
			cli:  "--settings",
			wants: BrowseOptions{
				SettingsFlag: true,
			},
			wantsErr: false,
		},
		{
			name: "projects flag",
			cli:  "--projects",
			wants: BrowseOptions{
				ProjectsFlag: true,
			},
			wantsErr: false,
		},
		{
+ 218 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh browse
pname: gh
plink: gh.yaml
options:
    - option: actions
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Open repository actions
    - option: blame
      value_type: bool
      default_value: "false"
DOCS
gh_browse.md:28Markdown · 9 words
TESTS
pkg/cmd/browse/browse_test.go:21pkg/cmd/browse/browse_test::TestNewCmdBrowse · Go · 248 lines
func TestNewCmdBrowse(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		factory  func(*cmdutil.Factory) *cmdutil.Factory
		wants    BrowseOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: false,
		},
		{
			name: "settings flag",
			cli:  "--settings",
			wants: BrowseOptions{
				SettingsFlag: true,
			},
			wantsErr: false,
		},
		{
			name: "projects flag",
			cli:  "--projects",
			wants: BrowseOptions{
				ProjectsFlag: true,
			},
			wantsErr: false,
		},
		{
+ 218 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh browse
pname: gh
plink: gh.yaml
options:
    - option: actions
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Open repository actions
    - option: blame
      value_type: bool
      default_value: "false"
DOCS
gh_browse.md:29Markdown · 14 words
TESTS
pkg/cmd/browse/browse_test.go:21pkg/cmd/browse/browse_test::TestNewCmdBrowse · Go · 248 lines
func TestNewCmdBrowse(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		factory  func(*cmdutil.Factory) *cmdutil.Factory
		wants    BrowseOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: false,
		},
		{
			name: "settings flag",
			cli:  "--settings",
			wants: BrowseOptions{
				SettingsFlag: true,
			},
			wantsErr: false,
		},
		{
			name: "projects flag",
			cli:  "--projects",
			wants: BrowseOptions{
				ProjectsFlag: true,
			},
			wantsErr: false,
		},
		{
+ 218 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh browse
pname: gh
plink: gh.yaml
options:
    - option: actions
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Open repository actions
    - option: blame
      value_type: bool
      default_value: "false"
DOCS
gh_browse.md:30Markdown · 8 words
TESTS
pkg/cmd/browse/browse_test.go:21pkg/cmd/browse/browse_test::TestNewCmdBrowse · Go · 248 lines
func TestNewCmdBrowse(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		factory  func(*cmdutil.Factory) *cmdutil.Factory
		wants    BrowseOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: false,
		},
		{
			name: "settings flag",
			cli:  "--settings",
			wants: BrowseOptions{
				SettingsFlag: true,
			},
			wantsErr: false,
		},
		{
			name: "projects flag",
			cli:  "--projects",
			wants: BrowseOptions{
				ProjectsFlag: true,
			},
			wantsErr: false,
		},
		{
+ 218 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh browse
pname: gh
plink: gh.yaml
options:
    - option: actions
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Open repository actions
    - option: blame
      value_type: bool
      default_value: "false"
DOCS
gh_browse.md:31Markdown · 3 words
TESTS
pkg/cmd/browse/browse_test.go:21pkg/cmd/browse/browse_test::TestNewCmdBrowse · Go · 248 lines
func TestNewCmdBrowse(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		factory  func(*cmdutil.Factory) *cmdutil.Factory
		wants    BrowseOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: false,
		},
		{
			name: "settings flag",
			cli:  "--settings",
			wants: BrowseOptions{
				SettingsFlag: true,
			},
			wantsErr: false,
		},
		{
			name: "projects flag",
			cli:  "--projects",
			wants: BrowseOptions{
				ProjectsFlag: true,
			},
			wantsErr: false,
		},
		{
+ 218 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh browse
pname: gh
plink: gh.yaml
options:
    - option: actions
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Open repository actions
    - option: blame
      value_type: bool
      default_value: "false"
DOCS
gh_browse.md:32Markdown · 3 words
TESTS
pkg/cmd/browse/browse_test.go:21pkg/cmd/browse/browse_test::TestNewCmdBrowse · Go · 248 lines
func TestNewCmdBrowse(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		factory  func(*cmdutil.Factory) *cmdutil.Factory
		wants    BrowseOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: false,
		},
		{
			name: "settings flag",
			cli:  "--settings",
			wants: BrowseOptions{
				SettingsFlag: true,
			},
			wantsErr: false,
		},
		{
			name: "projects flag",
			cli:  "--projects",
			wants: BrowseOptions{
				ProjectsFlag: true,
			},
			wantsErr: false,
		},
		{
+ 218 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh browse
pname: gh
plink: gh.yaml
options:
    - option: actions
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Open repository actions
    - option: blame
      value_type: bool
      default_value: "false"
DOCS
gh_browse.md:33Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh browse
pname: gh
plink: gh.yaml
options:
    - option: actions
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Open repository actions
    - option: blame
      value_type: bool
      default_value: "false"
DOCS
gh_browse.md:34Markdown · 3 words
TESTS
pkg/cmd/browse/browse_test.go:21pkg/cmd/browse/browse_test::TestNewCmdBrowse · Go · 248 lines
func TestNewCmdBrowse(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		factory  func(*cmdutil.Factory) *cmdutil.Factory
		wants    BrowseOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: false,
		},
		{
			name: "settings flag",
			cli:  "--settings",
			wants: BrowseOptions{
				SettingsFlag: true,
			},
			wantsErr: false,
		},
		{
			name: "projects flag",
			cli:  "--projects",
			wants: BrowseOptions{
				ProjectsFlag: true,
			},
			wantsErr: false,
		},
		{
+ 218 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh browse
pname: gh
plink: gh.yaml
options:
    - option: actions
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Open repository actions
    - option: blame
      value_type: bool
      default_value: "false"
DOCS
gh_browse.md:35Markdown · 3 words
TESTS
pkg/cmd/browse/browse_test.go:21pkg/cmd/browse/browse_test::TestNewCmdBrowse · Go · 248 lines
func TestNewCmdBrowse(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		factory  func(*cmdutil.Factory) *cmdutil.Factory
		wants    BrowseOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: false,
		},
		{
			name: "settings flag",
			cli:  "--settings",
			wants: BrowseOptions{
				SettingsFlag: true,
			},
			wantsErr: false,
		},
		{
			name: "projects flag",
			cli:  "--projects",
			wants: BrowseOptions{
				ProjectsFlag: true,
			},
			wantsErr: false,
		},
		{
+ 218 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh cache
short: Work with GitHub Actions caches.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh cache
short: Work with GitHub Actions caches.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_cache.md:21Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh cache delete
short: Delete GitHub Actions caches.
long: Deletion requires authorization with the `repo` scope.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: all
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Delete all caches, can be used with --ref to delete all caches for a specific ref
    - option: ref
TESTS
pkg/cmd/cache/delete/delete_test.go:19pkg/cmd/cache/delete/delete_test::TestNewCmdDelete · Go · 102 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    DeleteOptions
		wantsErr string
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: "must provide either cache id, cache key, or use --all",
		},
		{
			name:  "id argument",
			cli:   "123",
			wants: DeleteOptions{Identifier: "123"},
		},
		{
			name:  "key argument",
			cli:   "A-Cache-Key",
			wants: DeleteOptions{Identifier: "A-Cache-Key"},
		},
		{
			name:  "delete all flag",
			cli:   "--all",
			wants: DeleteOptions{DeleteAll: true},
		},
		{
			name:  "delete all and succeed-on-no-caches flags",
			cli:   "--all --succeed-on-no-caches",
+ 72 more lines · read full file
pkg/cmd/cache/delete/delete_test.go:122pkg/cmd/cache/delete/delete_test::TestDeleteRun · Go · 367 lines
func TestDeleteRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       DeleteOptions
		stubs      func(*httpmock.Registry)
		tty        bool
		wantErr    bool
		wantErrMsg string
		wantStderr string
		wantStdout string
	}{
		{
			name: "deletes cache tty",
			opts: DeleteOptions{Identifier: "123"},
			stubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("DELETE", "repos/OWNER/REPO/actions/caches/123"),
					httpmock.StatusStringResponse(204, ""),
				)
			},
			tty:        true,
			wantStdout: "✓ Deleted 1 cache from OWNER/REPO\n",
		},
		{
			name: "deletes cache notty",
			opts: DeleteOptions{Identifier: "123"},
			stubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("DELETE", "repos/OWNER/REPO/actions/caches/123"),
					httpmock.StatusStringResponse(204, ""),
+ 337 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh cache delete
short: Delete GitHub Actions caches.
long: Deletion requires authorization with the `repo` scope.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: all
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Delete all caches, can be used with --ref to delete all caches for a specific ref
    - option: ref
DOCS
gh_cache_delete.md:22Markdown · 16 words
TESTS
pkg/cmd/cache/delete/delete_test.go:19pkg/cmd/cache/delete/delete_test::TestNewCmdDelete · Go · 102 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    DeleteOptions
		wantsErr string
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: "must provide either cache id, cache key, or use --all",
		},
		{
			name:  "id argument",
			cli:   "123",
			wants: DeleteOptions{Identifier: "123"},
		},
		{
			name:  "key argument",
			cli:   "A-Cache-Key",
			wants: DeleteOptions{Identifier: "A-Cache-Key"},
		},
		{
			name:  "delete all flag",
			cli:   "--all",
			wants: DeleteOptions{DeleteAll: true},
		},
		{
			name:  "delete all and succeed-on-no-caches flags",
			cli:   "--all --succeed-on-no-caches",
+ 72 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh cache delete
short: Delete GitHub Actions caches.
long: Deletion requires authorization with the `repo` scope.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: all
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Delete all caches, can be used with --ref to delete all caches for a specific ref
    - option: ref
DOCS
gh_cache_delete.md:23Markdown · 12 words
TESTS
pkg/cmd/cache/delete/delete_test.go:19pkg/cmd/cache/delete/delete_test::TestNewCmdDelete · Go · 102 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    DeleteOptions
		wantsErr string
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: "must provide either cache id, cache key, or use --all",
		},
		{
			name:  "id argument",
			cli:   "123",
			wants: DeleteOptions{Identifier: "123"},
		},
		{
			name:  "key argument",
			cli:   "A-Cache-Key",
			wants: DeleteOptions{Identifier: "A-Cache-Key"},
		},
		{
			name:  "delete all flag",
			cli:   "--all",
			wants: DeleteOptions{DeleteAll: true},
		},
		{
			name:  "delete all and succeed-on-no-caches flags",
			cli:   "--all --succeed-on-no-caches",
+ 72 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh cache delete
short: Delete GitHub Actions caches.
long: Deletion requires authorization with the `repo` scope.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: all
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Delete all caches, can be used with --ref to delete all caches for a specific ref
    - option: ref
DOCS
gh_cache_delete.md:24Markdown · 15 words
TESTS
pkg/cmd/cache/delete/delete_test.go:19pkg/cmd/cache/delete/delete_test::TestNewCmdDelete · Go · 102 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    DeleteOptions
		wantsErr string
	}{
		{
			name:     "no arguments",
			cli:      "",
			wantsErr: "must provide either cache id, cache key, or use --all",
		},
		{
			name:  "id argument",
			cli:   "123",
			wants: DeleteOptions{Identifier: "123"},
		},
		{
			name:  "key argument",
			cli:   "A-Cache-Key",
			wants: DeleteOptions{Identifier: "A-Cache-Key"},
		},
		{
			name:  "delete all flag",
			cli:   "--all",
			wants: DeleteOptions{DeleteAll: true},
		},
		{
			name:  "delete all and succeed-on-no-caches flags",
			cli:   "--all --succeed-on-no-caches",
+ 72 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh cache list
short: List GitHub Actions caches
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_cache_list.md:1Markdown · 32 words
TESTS
pkg/cmd/cache/list/list_test.go:20pkg/cmd/cache/list/list_test::TestNewCmdList · Go · 108 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		wants    ListOptions
		wantsErr string
	}{
		{
			name:  "no arguments",
			input: "",
			wants: ListOptions{
				Limit: 30,
				Order: "desc",
				Sort:  "last_accessed_at",
				Key:   "",
				Ref:   "",
			},
		},
		{
			name:  "with limit",
			input: "--limit 100",
			wants: ListOptions{
				Limit: 100,
				Order: "desc",
				Sort:  "last_accessed_at",
				Key:   "",
				Ref:   "",
			},
		},
		{
+ 78 more lines · read full file
pkg/cmd/cache/list/list_test.go:129pkg/cmd/cache/list/list_test::TestListRun · Go · 222 lines
func TestListRun(t *testing.T) {
	var now = time.Date(2023, 1, 1, 1, 1, 1, 1, time.UTC)
	tests := []struct {
		name       string
		opts       ListOptions
		stubs      func(*httpmock.Registry)
		tty        bool
		wantErr    bool
		wantErrMsg string
		wantStderr string
		wantStdout string
	}{
		{
			name: "displays results tty",
			tty:  true,
			stubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/caches"),
					httpmock.JSONResponse(shared.CachePayload{
						ActionsCaches: []shared.Cache{
							{
								Id:             1,
								Key:            "foo",
								CreatedAt:      time.Date(2021, 1, 1, 1, 1, 1, 1, time.UTC),
								LastAccessedAt: time.Date(2022, 1, 1, 1, 1, 1, 1, time.UTC),
								SizeInBytes:    100,
							},
							{
								Id:             2,
								Key:            "bar",
+ 192 more lines · read full file
pkg/cmd/cache/list/list_test.go:368pkg/cmd/cache/list/list_test::Test_humanFileSize · Go · 60 lines
func Test_humanFileSize(t *testing.T) {
	tests := []struct {
		name string
		size int64
		want string
	}{
		{
			name: "min bytes",
			size: 1,
			want: "1 B",
		},
		{
			name: "max bytes",
			size: 1023,
			want: "1023 B",
		},
		{
			name: "min kibibytes",
			size: 1024,
			want: "1.00 KiB",
		},
		{
			name: "max kibibytes",
			size: 1024*1024 - 1,
			want: "1023.99 KiB",
		},
		{
			name: "min mibibytes",
			size: 1024 * 1024,
			want: "1.00 MiB",
+ 30 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh cache list
short: List GitHub Actions caches
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_cache_list.md:19Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh cache list
short: List GitHub Actions caches
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_cache_list.md:20Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh cache list
short: List GitHub Actions caches
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_cache_list.md:21Markdown · 5 words
TESTS
pkg/cmd/cache/list/list_test.go:20pkg/cmd/cache/list/list_test::TestNewCmdList · Go · 108 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		wants    ListOptions
		wantsErr string
	}{
		{
			name:  "no arguments",
			input: "",
			wants: ListOptions{
				Limit: 30,
				Order: "desc",
				Sort:  "last_accessed_at",
				Key:   "",
				Ref:   "",
			},
		},
		{
			name:  "with limit",
			input: "--limit 100",
			wants: ListOptions{
				Limit: 100,
				Order: "desc",
				Sort:  "last_accessed_at",
				Key:   "",
				Ref:   "",
			},
		},
		{
+ 78 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh cache list
short: List GitHub Actions caches
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_cache_list.md:22Markdown · 6 words
TESTS
pkg/cmd/cache/list/list_test.go:20pkg/cmd/cache/list/list_test::TestNewCmdList · Go · 108 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		wants    ListOptions
		wantsErr string
	}{
		{
			name:  "no arguments",
			input: "",
			wants: ListOptions{
				Limit: 30,
				Order: "desc",
				Sort:  "last_accessed_at",
				Key:   "",
				Ref:   "",
			},
		},
		{
			name:  "with limit",
			input: "--limit 100",
			wants: ListOptions{
				Limit: 100,
				Order: "desc",
				Sort:  "last_accessed_at",
				Key:   "",
				Ref:   "",
			},
		},
		{
+ 78 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh cache list
short: List GitHub Actions caches
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_cache_list.md:23Markdown · 5 words
TESTS
pkg/cmd/cache/list/list_test.go:20pkg/cmd/cache/list/list_test::TestNewCmdList · Go · 108 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		wants    ListOptions
		wantsErr string
	}{
		{
			name:  "no arguments",
			input: "",
			wants: ListOptions{
				Limit: 30,
				Order: "desc",
				Sort:  "last_accessed_at",
				Key:   "",
				Ref:   "",
			},
		},
		{
			name:  "with limit",
			input: "--limit 100",
			wants: ListOptions{
				Limit: 100,
				Order: "desc",
				Sort:  "last_accessed_at",
				Key:   "",
				Ref:   "",
			},
		},
		{
+ 78 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh cache list
short: List GitHub Actions caches
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_cache_list.md:24Markdown · 9 words
TESTS
pkg/cmd/cache/list/list_test.go:20pkg/cmd/cache/list/list_test::TestNewCmdList · Go · 108 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		wants    ListOptions
		wantsErr string
	}{
		{
			name:  "no arguments",
			input: "",
			wants: ListOptions{
				Limit: 30,
				Order: "desc",
				Sort:  "last_accessed_at",
				Key:   "",
				Ref:   "",
			},
		},
		{
			name:  "with limit",
			input: "--limit 100",
			wants: ListOptions{
				Limit: 100,
				Order: "desc",
				Sort:  "last_accessed_at",
				Key:   "",
				Ref:   "",
			},
		},
		{
+ 78 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh cache list
short: List GitHub Actions caches
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_cache_list.md:25Markdown · 4 words
TESTS
pkg/cmd/cache/list/list_test.go:20pkg/cmd/cache/list/list_test::TestNewCmdList · Go · 108 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		wants    ListOptions
		wantsErr string
	}{
		{
			name:  "no arguments",
			input: "",
			wants: ListOptions{
				Limit: 30,
				Order: "desc",
				Sort:  "last_accessed_at",
				Key:   "",
				Ref:   "",
			},
		},
		{
			name:  "with limit",
			input: "--limit 100",
			wants: ListOptions{
				Limit: 100,
				Order: "desc",
				Sort:  "last_accessed_at",
				Key:   "",
				Ref:   "",
			},
		},
		{
+ 78 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh cache list
short: List GitHub Actions caches
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh cache
plink: gh_cache.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_cache_list.md:26Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh co
short: Check out a pull request in git
pname: gh
plink: gh.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Local branch name to use (default [the name of the head branch])
DOCS

N/A

TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh co
short: Check out a pull request in git
pname: gh
plink: gh.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Local branch name to use (default [the name of the head branch])
DOCS

N/A

TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh co
short: Check out a pull request in git
pname: gh
plink: gh.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Local branch name to use (default [the name of the head branch])
DOCS

N/A

TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh co
short: Check out a pull request in git
pname: gh
plink: gh.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Local branch name to use (default [the name of the head branch])
DOCS

N/A

TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh co
short: Check out a pull request in git
pname: gh
plink: gh.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Local branch name to use (default [the name of the head branch])
DOCS

N/A

TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace
short: Connect to and manage codespaces
pname: gh
plink: gh.yaml
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace code
short: Open a codespace in Visual Studio Code
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: insiders
      value_type: bool
      default_value: "false"
TESTS
pkg/cmd/codespace/code_test.go:12pkg/cmd/codespace/code_test::TestApp_VSCode · Go · 75 lines
func TestApp_VSCode(t *testing.T) {
	type args struct {
		codespaceName string
		useInsiders   bool
		useWeb        bool
	}
	tests := []struct {
		name    string
		args    args
		wantErr bool
		wantURL string
	}{
		{
			name: "open VS Code",
			args: args{
				codespaceName: "monalisa-cli-cli-abcdef",
				useInsiders:   false,
			},
			wantErr: false,
			wantURL: "vscode://github.codespaces/connect?name=monalisa-cli-cli-abcdef&windowId=_blank",
		},
		{
			name: "open VS Code Insiders",
			args: args{
				codespaceName: "monalisa-cli-cli-abcdef",
				useInsiders:   true,
			},
			wantErr: false,
			wantURL: "vscode-insiders://github.codespaces/connect?name=monalisa-cli-cli-abcdef&windowId=_blank",
		},
+ 45 more lines · read full file
pkg/cmd/codespace/code_test.go:88pkg/cmd/codespace/code_test::TestPendingOperationDisallowsCode · Go · 12 lines
func TestPendingOperationDisallowsCode(t *testing.T) {
	app := testingCodeApp()
	selector := &CodespaceSelector{api: app.apiClient, codespaceName: "disabledCodespace"}

	if err := app.VSCode(context.Background(), selector, false, false); err != nil {
		if err.Error() != "codespace is disabled while it has a pending operation: Some pending operation" {
			t.Errorf("expected pending operation error, but got: %v", err)
		}
	} else {
		t.Error("expected pending operation error, but got nothing")
	}
}
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace code
short: Open a codespace in Visual Studio Code
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: insiders
      value_type: bool
      default_value: "false"
DOCS
gh_codespace_code.md:19Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace code
short: Open a codespace in Visual Studio Code
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: insiders
      value_type: bool
      default_value: "false"
DOCS
gh_codespace_code.md:20Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace code
short: Open a codespace in Visual Studio Code
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: insiders
      value_type: bool
      default_value: "false"
DOCS
gh_codespace_code.md:21Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace code
short: Open a codespace in Visual Studio Code
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: insiders
      value_type: bool
      default_value: "false"
DOCS
gh_codespace_code.md:22Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace code
short: Open a codespace in Visual Studio Code
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: insiders
      value_type: bool
      default_value: "false"
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace cp
short: The `cp` command copies files between the local and remote file systems.
long: |-
    As with the UNIX `cp` command, the first argument specifies the source and the last
    specifies the destination; additional sources may be specified after the first,
    if the destination is a directory.

    The `--recursive` flag is required if any source is a directory.

    A `remote:` prefix on any file name argument indicates that it refers to
    the file system of the remote (Codespace) machine. It is resolved relative
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace cp
short: The `cp` command copies files between the local and remote file systems.
long: |-
    As with the UNIX `cp` command, the first argument specifies the source and the last
    specifies the destination; additional sources may be specified after the first,
    if the destination is a directory.

    The `--recursive` flag is required if any source is a directory.

    A `remote:` prefix on any file name argument indicates that it refers to
    the file system of the remote (Codespace) machine. It is resolved relative
DOCS
gh_codespace_cp.md:39Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace cp
short: The `cp` command copies files between the local and remote file systems.
long: |-
    As with the UNIX `cp` command, the first argument specifies the source and the last
    specifies the destination; additional sources may be specified after the first,
    if the destination is a directory.

    The `--recursive` flag is required if any source is a directory.

    A `remote:` prefix on any file name argument indicates that it refers to
    the file system of the remote (Codespace) machine. It is resolved relative
DOCS
gh_codespace_cp.md:40Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace cp
short: The `cp` command copies files between the local and remote file systems.
long: |-
    As with the UNIX `cp` command, the first argument specifies the source and the last
    specifies the destination; additional sources may be specified after the first,
    if the destination is a directory.

    The `--recursive` flag is required if any source is a directory.

    A `remote:` prefix on any file name argument indicates that it refers to
    the file system of the remote (Codespace) machine. It is resolved relative
DOCS
gh_codespace_cp.md:41Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace cp
short: The `cp` command copies files between the local and remote file systems.
long: |-
    As with the UNIX `cp` command, the first argument specifies the source and the last
    specifies the destination; additional sources may be specified after the first,
    if the destination is a directory.

    The `--recursive` flag is required if any source is a directory.

    A `remote:` prefix on any file name argument indicates that it refers to
    the file system of the remote (Codespace) machine. It is resolved relative
DOCS
gh_codespace_cp.md:42Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace cp
short: The `cp` command copies files between the local and remote file systems.
long: |-
    As with the UNIX `cp` command, the first argument specifies the source and the last
    specifies the destination; additional sources may be specified after the first,
    if the destination is a directory.

    The `--recursive` flag is required if any source is a directory.

    A `remote:` prefix on any file name argument indicates that it refers to
    the file system of the remote (Codespace) machine. It is resolved relative
DOCS
gh_codespace_cp.md:43Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace cp
short: The `cp` command copies files between the local and remote file systems.
long: |-
    As with the UNIX `cp` command, the first argument specifies the source and the last
    specifies the destination; additional sources may be specified after the first,
    if the destination is a directory.

    The `--recursive` flag is required if any source is a directory.

    A `remote:` prefix on any file name argument indicates that it refers to
    the file system of the remote (Codespace) machine. It is resolved relative
DOCS
gh_codespace_cp.md:44Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace create
short: Create a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Repository branch
    - option: default-permissions
      value_type: bool
      default_value: "false"
TESTS
pkg/cmd/codespace/create_test.go:19pkg/cmd/codespace/create_test::TestCreateCmdFlagError · Go · 39 lines
func TestCreateCmdFlagError(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantsErr error
	}{
		{
			name:     "return error when using web flag with display-name, idle-timeout, or retention-period flags",
			args:     "--web --display-name foo --idle-timeout 30m",
			wantsErr: fmt.Errorf("using --web with --display-name, --idle-timeout, or --retention-period is not supported"),
		},
		{
			name:     "return error when using web flag with one of display-name, idle-timeout or retention-period flags",
			args:     "--web --idle-timeout 30m",
			wantsErr: fmt.Errorf("using --web with --display-name, --idle-timeout, or --retention-period is not supported"),
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			a := &App{
				io: ios,
			}
			cmd := newCreateCmd(a)

			args, _ := shlex.Split(tt.args)
			cmd.SetArgs(args)
			cmd.SetIn(&bytes.Buffer{})
			cmd.SetOut(&bytes.Buffer{})
+ 9 more lines · read full file
pkg/cmd/codespace/create_test.go:59pkg/cmd/codespace/create_test::TestApp_Create · Go · 609 lines
func TestApp_Create(t *testing.T) {
	type fields struct {
		apiClient apiClient
	}
	tests := []struct {
		name       string
		fields     fields
		opts       createOptions
		wantErr    error
		wantStdout string
		wantStderr string
		wantURL    string
		isTTY      bool
	}{
		{
			name: "create codespace with default branch and 30m idle timeout",
			fields: fields{
				apiClient: apiCreateDefaults(&apiClientMock{
					CreateCodespaceFunc: func(ctx context.Context, params *api.CreateCodespaceParams) (*api.Codespace, error) {
						if params.Branch != "main" {
							return nil, fmt.Errorf("got branch %q, want %q", params.Branch, "main")
						}
						if params.IdleTimeoutMinutes != 30 {
							return nil, fmt.Errorf("idle timeout minutes was %v", params.IdleTimeoutMinutes)
						}
						if *params.RetentionPeriodMinutes != 2880 {
							return nil, fmt.Errorf("retention period minutes expected 2880, was %v", params.RetentionPeriodMinutes)
						}
						if params.DisplayName != "" {
							return nil, fmt.Errorf("display name was %q, expected empty", params.DisplayName)
+ 579 more lines · read full file
pkg/cmd/codespace/create_test.go:669pkg/cmd/codespace/create_test::TestBuildDisplayName · Go · 37 lines
func TestBuildDisplayName(t *testing.T) {
	tests := []struct {
		name                 string
		prebuildAvailability string
		expectedDisplayName  string
	}{
		{
			name:                 "prebuild availability is none",
			prebuildAvailability: "none",
			expectedDisplayName:  "4 cores, 8 GB RAM, 32 GB storage",
		},
		{
			name:                 "prebuild availability is empty",
			prebuildAvailability: "",
			expectedDisplayName:  "4 cores, 8 GB RAM, 32 GB storage",
		},
		{
			name:                 "prebuild availability is ready",
			prebuildAvailability: "ready",
			expectedDisplayName:  "4 cores, 8 GB RAM, 32 GB storage (Prebuild ready)",
		},
		{
			name:                 "prebuild availability is in_progress",
			prebuildAvailability: "in_progress",
			expectedDisplayName:  "4 cores, 8 GB RAM, 32 GB storage (Prebuild in progress)",
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			displayName := buildDisplayName("4 cores, 8 GB RAM, 32 GB storage", tt.prebuildAvailability)
+ 7 more lines · read full file
+ 1 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace create
short: Create a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Repository branch
    - option: default-permissions
      value_type: bool
      default_value: "false"
DOCS
gh_codespace_create.md:19Markdown · 2 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace create
short: Create a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Repository branch
    - option: default-permissions
      value_type: bool
      default_value: "false"
DOCS
gh_codespace_create.md:20Markdown · 11 words
TESTS
pkg/cmd/codespace/create_test.go:59pkg/cmd/codespace/create_test::TestApp_Create · Go · 609 lines
func TestApp_Create(t *testing.T) {
	type fields struct {
		apiClient apiClient
	}
	tests := []struct {
		name       string
		fields     fields
		opts       createOptions
		wantErr    error
		wantStdout string
		wantStderr string
		wantURL    string
		isTTY      bool
	}{
		{
			name: "create codespace with default branch and 30m idle timeout",
			fields: fields{
				apiClient: apiCreateDefaults(&apiClientMock{
					CreateCodespaceFunc: func(ctx context.Context, params *api.CreateCodespaceParams) (*api.Codespace, error) {
						if params.Branch != "main" {
							return nil, fmt.Errorf("got branch %q, want %q", params.Branch, "main")
						}
						if params.IdleTimeoutMinutes != 30 {
							return nil, fmt.Errorf("idle timeout minutes was %v", params.IdleTimeoutMinutes)
						}
						if *params.RetentionPeriodMinutes != 2880 {
							return nil, fmt.Errorf("retention period minutes expected 2880, was %v", params.RetentionPeriodMinutes)
						}
						if params.DisplayName != "" {
							return nil, fmt.Errorf("display name was %q, expected empty", params.DisplayName)
+ 579 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace create
short: Create a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Repository branch
    - option: default-permissions
      value_type: bool
      default_value: "false"
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace create
short: Create a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Repository branch
    - option: default-permissions
      value_type: bool
      default_value: "false"
DOCS
gh_codespace_create.md:22Markdown · 9 words
TESTS
pkg/cmd/codespace/create_test.go:19pkg/cmd/codespace/create_test::TestCreateCmdFlagError · Go · 39 lines
func TestCreateCmdFlagError(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantsErr error
	}{
		{
			name:     "return error when using web flag with display-name, idle-timeout, or retention-period flags",
			args:     "--web --display-name foo --idle-timeout 30m",
			wantsErr: fmt.Errorf("using --web with --display-name, --idle-timeout, or --retention-period is not supported"),
		},
		{
			name:     "return error when using web flag with one of display-name, idle-timeout or retention-period flags",
			args:     "--web --idle-timeout 30m",
			wantsErr: fmt.Errorf("using --web with --display-name, --idle-timeout, or --retention-period is not supported"),
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			a := &App{
				io: ios,
			}
			cmd := newCreateCmd(a)

			args, _ := shlex.Split(tt.args)
			cmd.SetArgs(args)
			cmd.SetIn(&bytes.Buffer{})
			cmd.SetOut(&bytes.Buffer{})
+ 9 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace create
short: Create a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Repository branch
    - option: default-permissions
      value_type: bool
      default_value: "false"
TESTS
pkg/cmd/codespace/create_test.go:19pkg/cmd/codespace/create_test::TestCreateCmdFlagError · Go · 39 lines
func TestCreateCmdFlagError(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantsErr error
	}{
		{
			name:     "return error when using web flag with display-name, idle-timeout, or retention-period flags",
			args:     "--web --display-name foo --idle-timeout 30m",
			wantsErr: fmt.Errorf("using --web with --display-name, --idle-timeout, or --retention-period is not supported"),
		},
		{
			name:     "return error when using web flag with one of display-name, idle-timeout or retention-period flags",
			args:     "--web --idle-timeout 30m",
			wantsErr: fmt.Errorf("using --web with --display-name, --idle-timeout, or --retention-period is not supported"),
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			a := &App{
				io: ios,
			}
			cmd := newCreateCmd(a)

			args, _ := shlex.Split(tt.args)
			cmd.SetArgs(args)
			cmd.SetIn(&bytes.Buffer{})
			cmd.SetOut(&bytes.Buffer{})
+ 9 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace create
short: Create a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Repository branch
    - option: default-permissions
      value_type: bool
      default_value: "false"
DOCS
gh_codespace_create.md:24Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace create
short: Create a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Repository branch
    - option: default-permissions
      value_type: bool
      default_value: "false"
DOCS
gh_codespace_create.md:25Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace create
short: Create a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Repository branch
    - option: default-permissions
      value_type: bool
      default_value: "false"
DOCS
gh_codespace_create.md:26Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace create
short: Create a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Repository branch
    - option: default-permissions
      value_type: bool
      default_value: "false"
TESTS
pkg/cmd/codespace/create_test.go:19pkg/cmd/codespace/create_test::TestCreateCmdFlagError · Go · 39 lines
func TestCreateCmdFlagError(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantsErr error
	}{
		{
			name:     "return error when using web flag with display-name, idle-timeout, or retention-period flags",
			args:     "--web --display-name foo --idle-timeout 30m",
			wantsErr: fmt.Errorf("using --web with --display-name, --idle-timeout, or --retention-period is not supported"),
		},
		{
			name:     "return error when using web flag with one of display-name, idle-timeout or retention-period flags",
			args:     "--web --idle-timeout 30m",
			wantsErr: fmt.Errorf("using --web with --display-name, --idle-timeout, or --retention-period is not supported"),
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			a := &App{
				io: ios,
			}
			cmd := newCreateCmd(a)

			args, _ := shlex.Split(tt.args)
			cmd.SetArgs(args)
			cmd.SetIn(&bytes.Buffer{})
			cmd.SetOut(&bytes.Buffer{})
+ 9 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace create
short: Create a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Repository branch
    - option: default-permissions
      value_type: bool
      default_value: "false"
DOCS
gh_codespace_create.md:28Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace create
short: Create a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Repository branch
    - option: default-permissions
      value_type: bool
      default_value: "false"
DOCS
gh_codespace_create.md:29Markdown · 12 words
TESTS
pkg/cmd/codespace/create_test.go:19pkg/cmd/codespace/create_test::TestCreateCmdFlagError · Go · 39 lines
func TestCreateCmdFlagError(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantsErr error
	}{
		{
			name:     "return error when using web flag with display-name, idle-timeout, or retention-period flags",
			args:     "--web --display-name foo --idle-timeout 30m",
			wantsErr: fmt.Errorf("using --web with --display-name, --idle-timeout, or --retention-period is not supported"),
		},
		{
			name:     "return error when using web flag with one of display-name, idle-timeout or retention-period flags",
			args:     "--web --idle-timeout 30m",
			wantsErr: fmt.Errorf("using --web with --display-name, --idle-timeout, or --retention-period is not supported"),
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			a := &App{
				io: ios,
			}
			cmd := newCreateCmd(a)

			args, _ := shlex.Split(tt.args)
			cmd.SetArgs(args)
			cmd.SetIn(&bytes.Buffer{})
			cmd.SetOut(&bytes.Buffer{})
+ 9 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace delete
short: Delete codespaces based on selection criteria.
long: |-
    All codespaces for the authenticated user can be deleted, as well as codespaces for a
    specific repository. Alternatively, only codespaces older than N days can be deleted.

    Organization administrators may delete any codespace billed to the organization.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: all
      value_type: bool
TESTS
pkg/cmd/codespace/delete_test.go:18pkg/cmd/codespace/delete_test::TestDelete · Go · 320 lines
func TestDelete(t *testing.T) {
	now, _ := time.Parse(time.RFC3339, "2021-09-22T00:00:00Z")
	daysAgo := func(n int) string {
		return now.Add(time.Hour * -time.Duration(24*n)).Format(time.RFC3339)
	}

	tests := []struct {
		name        string
		opts        deleteOptions
		codespaces  []*api.Codespace
		confirms    map[string]bool
		deleteErr   error
		wantErr     string
		wantDeleted []string
		wantStdout  string
		wantStderr  string
	}{
		{
			name: "by name",
			opts: deleteOptions{
				codespaceName: "hubot-robawt-abc",
			},
			codespaces: []*api.Codespace{
				{
					Name: "hubot-robawt-abc",
				},
			},
			wantDeleted: []string{"hubot-robawt-abc"},
			wantStderr:  "1 codespace(s) deleted successfully\n",
		},
+ 290 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace delete
short: Delete codespaces based on selection criteria.
long: |-
    All codespaces for the authenticated user can be deleted, as well as codespaces for a
    specific repository. Alternatively, only codespaces older than N days can be deleted.

    Organization administrators may delete any codespace billed to the organization.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: all
      value_type: bool
DOCS
gh_codespace_delete.md:25Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace delete
short: Delete codespaces based on selection criteria.
long: |-
    All codespaces for the authenticated user can be deleted, as well as codespaces for a
    specific repository. Alternatively, only codespaces older than N days can be deleted.

    Organization administrators may delete any codespace billed to the organization.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: all
      value_type: bool
DOCS
gh_codespace_delete.md:26Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace delete
short: Delete codespaces based on selection criteria.
long: |-
    All codespaces for the authenticated user can be deleted, as well as codespaces for a
    specific repository. Alternatively, only codespaces older than N days can be deleted.

    Organization administrators may delete any codespace billed to the organization.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: all
      value_type: bool
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace delete
short: Delete codespaces based on selection criteria.
long: |-
    All codespaces for the authenticated user can be deleted, as well as codespaces for a
    specific repository. Alternatively, only codespaces older than N days can be deleted.

    Organization administrators may delete any codespace billed to the organization.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: all
      value_type: bool
DOCS
gh_codespace_delete.md:28Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace delete
short: Delete codespaces based on selection criteria.
long: |-
    All codespaces for the authenticated user can be deleted, as well as codespaces for a
    specific repository. Alternatively, only codespaces older than N days can be deleted.

    Organization administrators may delete any codespace billed to the organization.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: all
      value_type: bool
DOCS
gh_codespace_delete.md:29Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace delete
short: Delete codespaces based on selection criteria.
long: |-
    All codespaces for the authenticated user can be deleted, as well as codespaces for a
    specific repository. Alternatively, only codespaces older than N days can be deleted.

    Organization administrators may delete any codespace billed to the organization.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: all
      value_type: bool
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace delete
short: Delete codespaces based on selection criteria.
long: |-
    All codespaces for the authenticated user can be deleted, as well as codespaces for a
    specific repository. Alternatively, only codespaces older than N days can be deleted.

    Organization administrators may delete any codespace billed to the organization.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: all
      value_type: bool
DOCS
gh_codespace_delete.md:31Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace delete
short: Delete codespaces based on selection criteria.
long: |-
    All codespaces for the authenticated user can be deleted, as well as codespaces for a
    specific repository. Alternatively, only codespaces older than N days can be deleted.

    Organization administrators may delete any codespace billed to the organization.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: all
      value_type: bool
DOCS
gh_codespace_delete.md:32Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace edit
short: Edit a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: display-name
      shorthand: d
      value_type: string
TESTS
pkg/cmd/codespace/edit_test.go:11pkg/cmd/codespace/edit_test::TestEdit · Go · 134 lines
func TestEdit(t *testing.T) {
	tests := []struct {
		name          string
		opts          editOptions
		cliArgs       []string // alternative to opts; will test command dispatcher
		wantEdits     *api.EditCodespaceParams
		mockCodespace *api.Codespace
		wantStdout    string
		wantStderr    string
		wantErr       bool
		errMsg        string
	}{
		{
			name: "edit codespace display name",
			opts: editOptions{
				selector:    &CodespaceSelector{codespaceName: "hubot"},
				displayName: "hubot-changed",
				machine:     "",
			},
			wantEdits: &api.EditCodespaceParams{
				DisplayName: "hubot-changed",
			},
			mockCodespace: &api.Codespace{
				Name:        "hubot",
				DisplayName: "hubot-changed",
			},
			wantStdout: "",
			wantErr:    false,
		},
		{
+ 104 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace edit
short: Edit a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: display-name
      shorthand: d
      value_type: string
DOCS
gh_codespace_edit.md:19Markdown · 4 words
TESTS
pkg/cmd/codespace/edit_test.go:11pkg/cmd/codespace/edit_test::TestEdit · Go · 134 lines
func TestEdit(t *testing.T) {
	tests := []struct {
		name          string
		opts          editOptions
		cliArgs       []string // alternative to opts; will test command dispatcher
		wantEdits     *api.EditCodespaceParams
		mockCodespace *api.Codespace
		wantStdout    string
		wantStderr    string
		wantErr       bool
		errMsg        string
	}{
		{
			name: "edit codespace display name",
			opts: editOptions{
				selector:    &CodespaceSelector{codespaceName: "hubot"},
				displayName: "hubot-changed",
				machine:     "",
			},
			wantEdits: &api.EditCodespaceParams{
				DisplayName: "hubot-changed",
			},
			mockCodespace: &api.Codespace{
				Name:        "hubot",
				DisplayName: "hubot-changed",
			},
			wantStdout: "",
			wantErr:    false,
		},
		{
+ 104 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace edit
short: Edit a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: display-name
      shorthand: d
      value_type: string
DOCS
gh_codespace_edit.md:20Markdown · 4 words
TESTS
pkg/cmd/codespace/edit_test.go:11pkg/cmd/codespace/edit_test::TestEdit · Go · 134 lines
func TestEdit(t *testing.T) {
	tests := []struct {
		name          string
		opts          editOptions
		cliArgs       []string // alternative to opts; will test command dispatcher
		wantEdits     *api.EditCodespaceParams
		mockCodespace *api.Codespace
		wantStdout    string
		wantStderr    string
		wantErr       bool
		errMsg        string
	}{
		{
			name: "edit codespace display name",
			opts: editOptions{
				selector:    &CodespaceSelector{codespaceName: "hubot"},
				displayName: "hubot-changed",
				machine:     "",
			},
			wantEdits: &api.EditCodespaceParams{
				DisplayName: "hubot-changed",
			},
			mockCodespace: &api.Codespace{
				Name:        "hubot",
				DisplayName: "hubot-changed",
			},
			wantStdout: "",
			wantErr:    false,
		},
		{
+ 104 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace edit
short: Edit a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: display-name
      shorthand: d
      value_type: string
TESTS
pkg/cmd/codespace/edit_test.go:11pkg/cmd/codespace/edit_test::TestEdit · Go · 134 lines
func TestEdit(t *testing.T) {
	tests := []struct {
		name          string
		opts          editOptions
		cliArgs       []string // alternative to opts; will test command dispatcher
		wantEdits     *api.EditCodespaceParams
		mockCodespace *api.Codespace
		wantStdout    string
		wantStderr    string
		wantErr       bool
		errMsg        string
	}{
		{
			name: "edit codespace display name",
			opts: editOptions{
				selector:    &CodespaceSelector{codespaceName: "hubot"},
				displayName: "hubot-changed",
				machine:     "",
			},
			wantEdits: &api.EditCodespaceParams{
				DisplayName: "hubot-changed",
			},
			mockCodespace: &api.Codespace{
				Name:        "hubot",
				DisplayName: "hubot-changed",
			},
			wantStdout: "",
			wantErr:    false,
		},
		{
+ 104 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace edit
short: Edit a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: display-name
      shorthand: d
      value_type: string
DOCS
gh_codespace_edit.md:22Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace edit
short: Edit a codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: display-name
      shorthand: d
      value_type: string
DOCS
gh_codespace_edit.md:23Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace jupyter
short: Open a codespace in JupyterLab
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: repo
      shorthand: R
      value_type: string
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace jupyter
short: Open a codespace in JupyterLab
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: repo
      shorthand: R
      value_type: string
DOCS
gh_codespace_jupyter.md:19Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace jupyter
short: Open a codespace in JupyterLab
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: repo
      shorthand: R
      value_type: string
DOCS
gh_codespace_jupyter.md:20Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace jupyter
short: Open a codespace in JupyterLab
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: repo
      shorthand: R
      value_type: string
DOCS
gh_codespace_jupyter.md:21Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace list
short: List codespaces of the authenticated user.
long: |-
    Alternatively, organization administrators may list all codespaces billed to the organization.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
TESTS
pkg/cmd/codespace/list_test.go:17pkg/cmd/codespace/list_test::TestListCmdFlagError · Go · 48 lines
func TestListCmdFlagError(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantsErr error
	}{
		{
			name:     "list codespaces,--repo, --org and --user flag",
			args:     "--repo foo/bar --org github --user github",
			wantsErr: fmt.Errorf("using `--org` or `--user` with `--repo` is not allowed"),
		},
		{
			name:     "list codespaces,--web, --org and --user flag",
			args:     "--web --org github --user github",
			wantsErr: fmt.Errorf("using `--web` with `--org` or `--user` is not supported, please use with `--repo` instead"),
		},
		{
			name:     "list codespaces, negative --limit flag",
			args:     "--limit -1",
			wantsErr: fmt.Errorf("invalid limit: -1"),
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			a := &App{
				io: ios,
			}
+ 19 more lines · read full file
pkg/cmd/codespace/list_test.go:66pkg/cmd/codespace/list_test::TestApp_List · Go · 212 lines
func TestApp_List(t *testing.T) {
	type fields struct {
		apiClient apiClient
	}
	tests := []struct {
		name      string
		fields    fields
		opts      *listOptions
		wantError error
		wantURL   string
	}{
		{
			name: "list codespaces, no flags",
			fields: fields{
				apiClient: &apiClientMock{
					ListCodespacesFunc: func(ctx context.Context, opts api.ListCodespacesOptions) ([]*api.Codespace, error) {
						if opts.OrgName != "" {
							return nil, fmt.Errorf("should not be called with an orgName")
						}
						return []*api.Codespace{
							{
								DisplayName: "CS1",
								CreatedAt:   "2023-01-01T00:00:00Z",
							},
						}, nil
					},
				},
			},
			opts: &listOptions{},
		},
+ 182 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace list
short: List codespaces of the authenticated user.
long: |-
    Alternatively, organization administrators may list all codespaces billed to the organization.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
DOCS
gh_codespace_list.md:22Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace list
short: List codespaces of the authenticated user.
long: |-
    Alternatively, organization administrators may list all codespaces billed to the organization.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
DOCS
gh_codespace_list.md:23Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace list
short: List codespaces of the authenticated user.
long: |-
    Alternatively, organization administrators may list all codespaces billed to the organization.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
DOCS
gh_codespace_list.md:24Markdown · 6 words
TESTS
pkg/cmd/codespace/list_test.go:17pkg/cmd/codespace/list_test::TestListCmdFlagError · Go · 48 lines
func TestListCmdFlagError(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantsErr error
	}{
		{
			name:     "list codespaces,--repo, --org and --user flag",
			args:     "--repo foo/bar --org github --user github",
			wantsErr: fmt.Errorf("using `--org` or `--user` with `--repo` is not allowed"),
		},
		{
			name:     "list codespaces,--web, --org and --user flag",
			args:     "--web --org github --user github",
			wantsErr: fmt.Errorf("using `--web` with `--org` or `--user` is not supported, please use with `--repo` instead"),
		},
		{
			name:     "list codespaces, negative --limit flag",
			args:     "--limit -1",
			wantsErr: fmt.Errorf("invalid limit: -1"),
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			a := &App{
				io: ios,
			}
+ 19 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace list
short: List codespaces of the authenticated user.
long: |-
    Alternatively, organization administrators may list all codespaces billed to the organization.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
TESTS
pkg/cmd/codespace/list_test.go:17pkg/cmd/codespace/list_test::TestListCmdFlagError · Go · 48 lines
func TestListCmdFlagError(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantsErr error
	}{
		{
			name:     "list codespaces,--repo, --org and --user flag",
			args:     "--repo foo/bar --org github --user github",
			wantsErr: fmt.Errorf("using `--org` or `--user` with `--repo` is not allowed"),
		},
		{
			name:     "list codespaces,--web, --org and --user flag",
			args:     "--web --org github --user github",
			wantsErr: fmt.Errorf("using `--web` with `--org` or `--user` is not supported, please use with `--repo` instead"),
		},
		{
			name:     "list codespaces, negative --limit flag",
			args:     "--limit -1",
			wantsErr: fmt.Errorf("invalid limit: -1"),
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			a := &App{
				io: ios,
			}
+ 19 more lines · read full file
pkg/cmd/codespace/list_test.go:66pkg/cmd/codespace/list_test::TestApp_List · Go · 212 lines
func TestApp_List(t *testing.T) {
	type fields struct {
		apiClient apiClient
	}
	tests := []struct {
		name      string
		fields    fields
		opts      *listOptions
		wantError error
		wantURL   string
	}{
		{
			name: "list codespaces, no flags",
			fields: fields{
				apiClient: &apiClientMock{
					ListCodespacesFunc: func(ctx context.Context, opts api.ListCodespacesOptions) ([]*api.Codespace, error) {
						if opts.OrgName != "" {
							return nil, fmt.Errorf("should not be called with an orgName")
						}
						return []*api.Codespace{
							{
								DisplayName: "CS1",
								CreatedAt:   "2023-01-01T00:00:00Z",
							},
						}, nil
					},
				},
			},
			opts: &listOptions{},
		},
+ 182 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace list
short: List codespaces of the authenticated user.
long: |-
    Alternatively, organization administrators may list all codespaces billed to the organization.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
DOCS
gh_codespace_list.md:26Markdown · 5 words
TESTS
pkg/cmd/codespace/list_test.go:17pkg/cmd/codespace/list_test::TestListCmdFlagError · Go · 48 lines
func TestListCmdFlagError(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantsErr error
	}{
		{
			name:     "list codespaces,--repo, --org and --user flag",
			args:     "--repo foo/bar --org github --user github",
			wantsErr: fmt.Errorf("using `--org` or `--user` with `--repo` is not allowed"),
		},
		{
			name:     "list codespaces,--web, --org and --user flag",
			args:     "--web --org github --user github",
			wantsErr: fmt.Errorf("using `--web` with `--org` or `--user` is not supported, please use with `--repo` instead"),
		},
		{
			name:     "list codespaces, negative --limit flag",
			args:     "--limit -1",
			wantsErr: fmt.Errorf("invalid limit: -1"),
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			a := &App{
				io: ios,
			}
+ 19 more lines · read full file
pkg/cmd/codespace/list_test.go:66pkg/cmd/codespace/list_test::TestApp_List · Go · 212 lines
func TestApp_List(t *testing.T) {
	type fields struct {
		apiClient apiClient
	}
	tests := []struct {
		name      string
		fields    fields
		opts      *listOptions
		wantError error
		wantURL   string
	}{
		{
			name: "list codespaces, no flags",
			fields: fields{
				apiClient: &apiClientMock{
					ListCodespacesFunc: func(ctx context.Context, opts api.ListCodespacesOptions) ([]*api.Codespace, error) {
						if opts.OrgName != "" {
							return nil, fmt.Errorf("should not be called with an orgName")
						}
						return []*api.Codespace{
							{
								DisplayName: "CS1",
								CreatedAt:   "2023-01-01T00:00:00Z",
							},
						}, nil
					},
				},
			},
			opts: &listOptions{},
		},
+ 182 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace list
short: List codespaces of the authenticated user.
long: |-
    Alternatively, organization administrators may list all codespaces billed to the organization.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
DOCS
gh_codespace_list.md:27Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace list
short: List codespaces of the authenticated user.
long: |-
    Alternatively, organization administrators may list all codespaces billed to the organization.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
TESTS
pkg/cmd/codespace/list_test.go:17pkg/cmd/codespace/list_test::TestListCmdFlagError · Go · 48 lines
func TestListCmdFlagError(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantsErr error
	}{
		{
			name:     "list codespaces,--repo, --org and --user flag",
			args:     "--repo foo/bar --org github --user github",
			wantsErr: fmt.Errorf("using `--org` or `--user` with `--repo` is not allowed"),
		},
		{
			name:     "list codespaces,--web, --org and --user flag",
			args:     "--web --org github --user github",
			wantsErr: fmt.Errorf("using `--web` with `--org` or `--user` is not supported, please use with `--repo` instead"),
		},
		{
			name:     "list codespaces, negative --limit flag",
			args:     "--limit -1",
			wantsErr: fmt.Errorf("invalid limit: -1"),
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			a := &App{
				io: ios,
			}
+ 19 more lines · read full file
pkg/cmd/codespace/list_test.go:66pkg/cmd/codespace/list_test::TestApp_List · Go · 212 lines
func TestApp_List(t *testing.T) {
	type fields struct {
		apiClient apiClient
	}
	tests := []struct {
		name      string
		fields    fields
		opts      *listOptions
		wantError error
		wantURL   string
	}{
		{
			name: "list codespaces, no flags",
			fields: fields{
				apiClient: &apiClientMock{
					ListCodespacesFunc: func(ctx context.Context, opts api.ListCodespacesOptions) ([]*api.Codespace, error) {
						if opts.OrgName != "" {
							return nil, fmt.Errorf("should not be called with an orgName")
						}
						return []*api.Codespace{
							{
								DisplayName: "CS1",
								CreatedAt:   "2023-01-01T00:00:00Z",
							},
						}, nil
					},
				},
			},
			opts: &listOptions{},
		},
+ 182 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace list
short: List codespaces of the authenticated user.
long: |-
    Alternatively, organization administrators may list all codespaces billed to the organization.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
DOCS
gh_codespace_list.md:29Markdown · 13 words
TESTS
pkg/cmd/codespace/list_test.go:17pkg/cmd/codespace/list_test::TestListCmdFlagError · Go · 48 lines
func TestListCmdFlagError(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantsErr error
	}{
		{
			name:     "list codespaces,--repo, --org and --user flag",
			args:     "--repo foo/bar --org github --user github",
			wantsErr: fmt.Errorf("using `--org` or `--user` with `--repo` is not allowed"),
		},
		{
			name:     "list codespaces,--web, --org and --user flag",
			args:     "--web --org github --user github",
			wantsErr: fmt.Errorf("using `--web` with `--org` or `--user` is not supported, please use with `--repo` instead"),
		},
		{
			name:     "list codespaces, negative --limit flag",
			args:     "--limit -1",
			wantsErr: fmt.Errorf("invalid limit: -1"),
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			a := &App{
				io: ios,
			}
+ 19 more lines · read full file
pkg/cmd/codespace/list_test.go:66pkg/cmd/codespace/list_test::TestApp_List · Go · 212 lines
func TestApp_List(t *testing.T) {
	type fields struct {
		apiClient apiClient
	}
	tests := []struct {
		name      string
		fields    fields
		opts      *listOptions
		wantError error
		wantURL   string
	}{
		{
			name: "list codespaces, no flags",
			fields: fields{
				apiClient: &apiClientMock{
					ListCodespacesFunc: func(ctx context.Context, opts api.ListCodespacesOptions) ([]*api.Codespace, error) {
						if opts.OrgName != "" {
							return nil, fmt.Errorf("should not be called with an orgName")
						}
						return []*api.Codespace{
							{
								DisplayName: "CS1",
								CreatedAt:   "2023-01-01T00:00:00Z",
							},
						}, nil
					},
				},
			},
			opts: &listOptions{},
		},
+ 182 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace logs
short: Access codespace logs
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: follow
      shorthand: f
      value_type: bool
TESTS
pkg/cmd/codespace/logs_test.go:11pkg/cmd/codespace/logs_test::TestPendingOperationDisallowsLogs · Go · 12 lines
func TestPendingOperationDisallowsLogs(t *testing.T) {
	app := testingLogsApp()
	selector := &CodespaceSelector{api: app.apiClient, codespaceName: "disabledCodespace"}

	if err := app.Logs(context.Background(), selector, false); err != nil {
		if err.Error() != "codespace is disabled while it has a pending operation: Some pending operation" {
			t.Errorf("expected pending operation error, but got: %v", err)
		}
	} else {
		t.Error("expected pending operation error, but got nothing")
	}
}
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace logs
short: Access codespace logs
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: follow
      shorthand: f
      value_type: bool
DOCS
gh_codespace_logs.md:19Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace logs
short: Access codespace logs
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: follow
      shorthand: f
      value_type: bool
DOCS
gh_codespace_logs.md:20Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace logs
short: Access codespace logs
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: follow
      shorthand: f
      value_type: bool
DOCS
gh_codespace_logs.md:21Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace logs
short: Access codespace logs
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: follow
      shorthand: f
      value_type: bool
DOCS
gh_codespace_logs.md:22Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ports
short: List ports in a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
TESTS
pkg/cmd/codespace/ports_test.go:14pkg/cmd/codespace/ports_test::TestListPorts · Go · 18 lines
func TestListPorts(t *testing.T) {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	mockApi := GetMockApi(false)
	ios, _, _, _ := iostreams.Test()

	a := &App{
		io:        ios,
		apiClient: mockApi,
	}

	selector := &CodespaceSelector{api: a.apiClient, codespaceName: "codespace-name"}
	err := a.ListPorts(ctx, selector, nil)
	if err != nil {
		t.Errorf("unexpected error: %v", err)
	}
}
pkg/cmd/codespace/ports_test.go:33pkg/cmd/codespace/ports_test::TestPortsUpdateVisibilitySuccess · Go · 17 lines
func TestPortsUpdateVisibilitySuccess(t *testing.T) {
	portVisibilities := []portVisibility{
		{
			number:     80,
			visibility: "org",
		},
		{
			number:     9999,
			visibility: "public",
		},
	}

	err := runUpdateVisibilityTest(t, portVisibilities, true)
	if err != nil {
		t.Errorf("unexpected error: %v", err)
	}
}
pkg/cmd/codespace/ports_test.go:51pkg/cmd/codespace/ports_test::TestPortsUpdateVisibilityFailure · Go · 17 lines
func TestPortsUpdateVisibilityFailure(t *testing.T) {
	portVisibilities := []portVisibility{
		{
			number:     9999,
			visibility: "public",
		},
		{
			number:     80,
			visibility: "org",
		},
	}

	err := runUpdateVisibilityTest(t, portVisibilities, false)
	if err == nil {
		t.Fatalf("runUpdateVisibilityTest succeeded unexpectedly")
	}
}
+ 3 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace ports
short: List ports in a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
DOCS
gh_codespace_ports.md:25Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ports
short: List ports in a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
DOCS
gh_codespace_ports.md:26Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ports
short: List ports in a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
DOCS
gh_codespace_ports.md:27Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ports
short: List ports in a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
DOCS
gh_codespace_ports.md:28Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ports
short: List ports in a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
DOCS
gh_codespace_ports.md:29Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ports
short: List ports in a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
DOCS
gh_codespace_ports.md:30Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ports forward
short: Forward ports
pname: gh codespace ports
plink: gh_codespace_ports.yaml
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ports visibility
short: Change the visibility of the forwarded port
pname: gh codespace ports
plink: gh_codespace_ports.yaml
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace rebuild
short: Rebuilding recreates your codespace.
long: |-
    Your code and any current changes will be preserved. Your codespace will be rebuilt using
    your working directory's dev container. A full rebuild also removes cached Docker images.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
TESTS
pkg/cmd/codespace/rebuild_test.go:11pkg/cmd/codespace/rebuild_test::TestAlreadyRebuildingCodespace · Go · 13 lines
func TestAlreadyRebuildingCodespace(t *testing.T) {
	rebuildingCodespace := &api.Codespace{
		Name:  "rebuildingCodespace",
		State: api.CodespaceStateRebuilding,
	}
	app := testingRebuildApp(*rebuildingCodespace)
	selector := &CodespaceSelector{api: app.apiClient, codespaceName: "rebuildingCodespace"}

	err := app.Rebuild(context.Background(), selector, false)
	if err != nil {
		t.Errorf("rebuilding a codespace that was already rebuilding: %v", err)
	}
}
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace rebuild
short: Rebuilding recreates your codespace.
long: |-
    Your code and any current changes will be preserved. Your codespace will be rebuilt using
    your working directory's dev container. A full rebuild also removes cached Docker images.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
DOCS
gh_codespace_rebuild.md:23Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace rebuild
short: Rebuilding recreates your codespace.
long: |-
    Your code and any current changes will be preserved. Your codespace will be rebuilt using
    your working directory's dev container. A full rebuild also removes cached Docker images.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
DOCS
gh_codespace_rebuild.md:24Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace rebuild
short: Rebuilding recreates your codespace.
long: |-
    Your code and any current changes will be preserved. Your codespace will be rebuilt using
    your working directory's dev container. A full rebuild also removes cached Docker images.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
DOCS
gh_codespace_rebuild.md:25Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace rebuild
short: Rebuilding recreates your codespace.
long: |-
    Your code and any current changes will be preserved. Your codespace will be rebuilt using
    your working directory's dev container. A full rebuild also removes cached Docker images.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
DOCS
gh_codespace_rebuild.md:26Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ssh
short: The `ssh` command is used to SSH into a codespace. In its simplest form, you can
long: |-
    run `gh cs ssh`, select a codespace interactively, and connect.

    The `ssh` command will automatically create a public/private ssh key pair in the
    `~/.ssh` directory if you do not have an existing valid key pair. When selecting the
    key pair to use, the preferred order is:

    1. Key specified by `-i` in `<ssh-flags>`
    2. Automatic key, if it already exists
    3. First valid key pair in ssh config (according to `ssh -G`)
TESTS
pkg/cmd/codespace/ssh_test.go:17pkg/cmd/codespace/ssh_test::TestPendingOperationDisallowsSSH · Go · 12 lines
func TestPendingOperationDisallowsSSH(t *testing.T) {
	app := testingSSHApp()
	selector := &CodespaceSelector{api: app.apiClient, codespaceName: "disabledCodespace"}

	if err := app.SSH(context.Background(), []string{}, sshOptions{selector: selector}); err != nil {
		if err.Error() != "codespace is disabled while it has a pending operation: Some pending operation" {
			t.Errorf("expected pending operation error, but got: %v", err)
		}
	} else {
		t.Error("expected pending operation error, but got nothing")
	}
}
pkg/cmd/codespace/ssh_test.go:30pkg/cmd/codespace/ssh_test::TestGenerateAutomaticSSHKeys · Go · 95 lines
func TestGenerateAutomaticSSHKeys(t *testing.T) {
	tests := []struct {
		// These files exist when calling generateAutomaticSSHKeys
		existingFiles []string
		// These files should exist after generateAutomaticSSHKeys finishes
		wantFinalFiles []string
	}{
		// Basic case: no existing keys, they should be created
		{
			nil,
			[]string{automaticPrivateKeyName, automaticPrivateKeyName + ".pub"},
		},
		// Basic case: keys already exist
		{
			[]string{automaticPrivateKeyName, automaticPrivateKeyName + ".pub"},
			[]string{automaticPrivateKeyName, automaticPrivateKeyName + ".pub"},
		},
		// Backward compatibility: both old keys exist, they should be renamed
		{
			[]string{automaticPrivateKeyNameOld, automaticPrivateKeyNameOld + ".pub"},
			[]string{automaticPrivateKeyName, automaticPrivateKeyName + ".pub"},
		},
		// Backward compatibility: old private key exists but not the public key, the new keys should be created
		{
			[]string{automaticPrivateKeyNameOld},
			[]string{automaticPrivateKeyNameOld, automaticPrivateKeyName, automaticPrivateKeyName + ".pub"},
		},
		// Backward compatibility: old public key exists but not the private key, the new keys should be created
		{
			[]string{automaticPrivateKeyNameOld + ".pub"},
+ 65 more lines · read full file
pkg/cmd/codespace/ssh_test.go:126pkg/cmd/codespace/ssh_test::TestSelectSSHKeys · Go · 160 lines
func TestSelectSSHKeys(t *testing.T) {
	// This string will be substituted in sshArgs for test cases
	// This is to work around the temp test ssh dir not being known until the test is executing
	substituteSSHDir := "SUB_SSH_DIR"

	tests := []struct {
		sshDirFiles      []string
		sshConfigKeys    []string
		sshArgs          []string
		profileOpt       string
		wantKeyPair      *ssh.KeyPair
		wantShouldAddArg bool
	}{
		// -i tests
		{
			sshArgs:     []string{"-i", "custom-private-key"},
			wantKeyPair: &ssh.KeyPair{PrivateKeyPath: "custom-private-key", PublicKeyPath: "custom-private-key.pub"},
		},
		{
			sshArgs:     []string{"-i", path.Join(substituteSSHDir, automaticPrivateKeyName)},
			wantKeyPair: &ssh.KeyPair{PrivateKeyPath: automaticPrivateKeyName, PublicKeyPath: automaticPrivateKeyName + ".pub"},
		},
		{
			// Edge case check for missing arg value
			sshArgs: []string{"-i"},
		},

		// Auto key exists tests
		{
			sshDirFiles:      []string{automaticPrivateKeyName, automaticPrivateKeyName + ".pub"},
+ 130 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh codespace ssh
short: The `ssh` command is used to SSH into a codespace. In its simplest form, you can
long: |-
    run `gh cs ssh`, select a codespace interactively, and connect.

    The `ssh` command will automatically create a public/private ssh key pair in the
    `~/.ssh` directory if you do not have an existing valid key pair. When selecting the
    key pair to use, the preferred order is:

    1. Key specified by `-i` in `<ssh-flags>`
    2. Automatic key, if it already exists
    3. First valid key pair in ssh config (according to `ssh -G`)
DOCS
gh_codespace_ssh.md:50Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ssh
short: The `ssh` command is used to SSH into a codespace. In its simplest form, you can
long: |-
    run `gh cs ssh`, select a codespace interactively, and connect.

    The `ssh` command will automatically create a public/private ssh key pair in the
    `~/.ssh` directory if you do not have an existing valid key pair. When selecting the
    key pair to use, the preferred order is:

    1. Key specified by `-i` in `<ssh-flags>`
    2. Automatic key, if it already exists
    3. First valid key pair in ssh config (according to `ssh -G`)
DOCS
gh_codespace_ssh.md:51Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace ssh
short: The `ssh` command is used to SSH into a codespace. In its simplest form, you can
long: |-
    run `gh cs ssh`, select a codespace interactively, and connect.

    The `ssh` command will automatically create a public/private ssh key pair in the
    `~/.ssh` directory if you do not have an existing valid key pair. When selecting the
    key pair to use, the preferred order is:

    1. Key specified by `-i` in `<ssh-flags>`
    2. Automatic key, if it already exists
    3. First valid key pair in ssh config (according to `ssh -G`)
DOCS
gh_codespace_ssh.md:52Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ssh
short: The `ssh` command is used to SSH into a codespace. In its simplest form, you can
long: |-
    run `gh cs ssh`, select a codespace interactively, and connect.

    The `ssh` command will automatically create a public/private ssh key pair in the
    `~/.ssh` directory if you do not have an existing valid key pair. When selecting the
    key pair to use, the preferred order is:

    1. Key specified by `-i` in `<ssh-flags>`
    2. Automatic key, if it already exists
    3. First valid key pair in ssh config (according to `ssh -G`)
DOCS
gh_codespace_ssh.md:53Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ssh
short: The `ssh` command is used to SSH into a codespace. In its simplest form, you can
long: |-
    run `gh cs ssh`, select a codespace interactively, and connect.

    The `ssh` command will automatically create a public/private ssh key pair in the
    `~/.ssh` directory if you do not have an existing valid key pair. When selecting the
    key pair to use, the preferred order is:

    1. Key specified by `-i` in `<ssh-flags>`
    2. Automatic key, if it already exists
    3. First valid key pair in ssh config (according to `ssh -G`)
DOCS
gh_codespace_ssh.md:54Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ssh
short: The `ssh` command is used to SSH into a codespace. In its simplest form, you can
long: |-
    run `gh cs ssh`, select a codespace interactively, and connect.

    The `ssh` command will automatically create a public/private ssh key pair in the
    `~/.ssh` directory if you do not have an existing valid key pair. When selecting the
    key pair to use, the preferred order is:

    1. Key specified by `-i` in `<ssh-flags>`
    2. Automatic key, if it already exists
    3. First valid key pair in ssh config (according to `ssh -G`)
DOCS
gh_codespace_ssh.md:55Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ssh
short: The `ssh` command is used to SSH into a codespace. In its simplest form, you can
long: |-
    run `gh cs ssh`, select a codespace interactively, and connect.

    The `ssh` command will automatically create a public/private ssh key pair in the
    `~/.ssh` directory if you do not have an existing valid key pair. When selecting the
    key pair to use, the preferred order is:

    1. Key specified by `-i` in `<ssh-flags>`
    2. Automatic key, if it already exists
    3. First valid key pair in ssh config (according to `ssh -G`)
DOCS
gh_codespace_ssh.md:56Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace ssh
short: The `ssh` command is used to SSH into a codespace. In its simplest form, you can
long: |-
    run `gh cs ssh`, select a codespace interactively, and connect.

    The `ssh` command will automatically create a public/private ssh key pair in the
    `~/.ssh` directory if you do not have an existing valid key pair. When selecting the
    key pair to use, the preferred order is:

    1. Key specified by `-i` in `<ssh-flags>`
    2. Automatic key, if it already exists
    3. First valid key pair in ssh config (according to `ssh -G`)
DOCS
gh_codespace_ssh.md:57Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace stop
short: Stop a running codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: org
      shorthand: o
      value_type: string
TESTS
pkg/cmd/codespace/stop_test.go:13pkg/cmd/codespace/stop_test::TestApp_StopCodespace · Go · 93 lines
func TestApp_StopCodespace(t *testing.T) {
	type fields struct {
		apiClient apiClient
	}
	tests := []struct {
		name   string
		fields fields
		opts   *stopOptions
	}{
		{
			name: "Stop a codespace I own",
			opts: &stopOptions{
				selector: &CodespaceSelector{codespaceName: "test-codespace"},
			},
			fields: fields{
				apiClient: &apiClientMock{
					GetCodespaceFunc: func(ctx context.Context, name string, includeConnection bool) (*api.Codespace, error) {
						if name != "test-codespace" {
							return nil, fmt.Errorf("got codespace name %s, wanted %s", name, "test-codespace")
						}

						return &api.Codespace{
							State: api.CodespaceStateAvailable,
						}, nil
					},
					StopCodespaceFunc: func(ctx context.Context, name string, orgName string, userName string) error {
						if name != "test-codespace" {
							return fmt.Errorf("got codespace name %s, wanted %s", name, "test-codespace")
						}
+ 64 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace stop
short: Stop a running codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: org
      shorthand: o
      value_type: string
DOCS
gh_codespace_stop.md:19Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace stop
short: Stop a running codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: org
      shorthand: o
      value_type: string
DOCS
gh_codespace_stop.md:20Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace stop
short: Stop a running codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: org
      shorthand: o
      value_type: string
DOCS
gh_codespace_stop.md:21Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace stop
short: Stop a running codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: org
      shorthand: o
      value_type: string
DOCS
gh_codespace_stop.md:22Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace stop
short: Stop a running codespace
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: org
      shorthand: o
      value_type: string
DOCS
gh_codespace_stop.md:23Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace view
short: View details about a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
TESTS
pkg/cmd/codespace/view_test.go:12pkg/cmd/codespace/view_test::Test_NewCmdView · Go · 82 lines
func Test_NewCmdView(t *testing.T) {
	tests := []struct {
		tName         string
		codespaceName string
		opts          *viewOptions
		cliArgs       []string
		wantErr       bool
		wantStdout    string
		errMsg        string
	}{
		{
			tName:   "selector throws because no terminal found",
			opts:    &viewOptions{},
			wantErr: true,
			errMsg:  "choosing codespace: error getting answers: no terminal",
		},
		{
			tName:         "command fails because provided codespace doesn't exist",
			codespaceName: "i-dont-exist",
			opts:          &viewOptions{},
			wantErr:       true,
			errMsg:        "getting full codespace details: codespace not found",
		},
		{
			tName:         "command succeeds because codespace exists (no details)",
			codespaceName: "monalisa-cli-cli-abcdef",
			opts:          &viewOptions{},
			wantErr:       false,
			wantStdout:    "Name\tmonalisa-cli-cli-abcdef\nState\t\nRepository\t\nGit Status\t - 0 commits ahead, 0 commits behind\nDevcontainer Path\t\nMachine Display Name\t\nIdle Timeout\t0 minutes\nCreated At\t\nRetention Period\t\n",
		},
+ 52 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh codespace view
short: View details about a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
DOCS
gh_codespace_view.md:19Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace view
short: View details about a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
DOCS
gh_codespace_view.md:20Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace view
short: View details about a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
DOCS
gh_codespace_view.md:21Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh codespace view
short: View details about a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
DOCS
gh_codespace_view.md:22Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace view
short: View details about a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
DOCS
gh_codespace_view.md:23Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh codespace view
short: View details about a codespace
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh codespace
plink: gh_codespace.yaml
options:
    - option: codespace
      shorthand: c
      value_type: string
      description: Name of the codespace
    - option: jq
      shorthand: q
DOCS
gh_codespace_view.md:24Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh completion
short: Generate shell completion scripts for GitHub CLI commands.
long: |-
    When installing GitHub CLI through a package manager, it's possible that
    no additional shell configuration is necessary to gain completion support. For
    Homebrew, see <https://docs.brew.sh/Shell-Completion>

    If you need to set up completions manually, follow the instructions below. The exact
    config file locations might vary based on your system. Make sure to restart your
    shell before testing whether completions are working.

    ### bash
DOCS
gh_completion.md:1Markdown · 179 words
TESTS
pkg/cmd/completion/completion_test.go:12pkg/cmd/completion/completion_test::TestNewCmdCompletion · Go · 68 lines
func TestNewCmdCompletion(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		wantOut string
		wantErr string
	}{
		{
			name:    "no arguments",
			args:    "completion",
			wantOut: "complete -o default -F __start_gh gh",
		},
		{
			name:    "zsh completion",
			args:    "completion -s zsh",
			wantOut: "#compdef gh",
		},
		{
			name:    "fish completion",
			args:    "completion -s fish",
			wantOut: "complete -c gh ",
		},
		{
			name:    "PowerShell completion",
			args:    "completion -s powershell",
			wantOut: "Register-ArgumentCompleter",
		},
		{
			name:    "unsupported shell",
			args:    "completion -s csh",
+ 38 more lines · read full file
pkg/cmd/pr/shared/completion_test.go:12pkg/cmd/pr/shared/completion_test::TestRequestableReviewersForCompletion · Go · 109 lines
func TestRequestableReviewersForCompletion(t *testing.T) {
	tests := []struct {
		name              string
		expectedReviewers []string
		httpStubs         func(*httpmock.Registry, *testing.T)
	}{
		{
			name:              "when users and teams are both available, both are listed",
			expectedReviewers: []string{"MonaLisa\tMona Display Name", "OWNER/core", "OWNER/robots", "hubot"},
			httpStubs: func(reg *httpmock.Registry, t *testing.T) {
				reg.Register(
					httpmock.GraphQL(`query UserCurrent\b`),
					httpmock.StringResponse(`{"data": {"viewer": {"login": "OWNER"} } }`))
				reg.Register(
					httpmock.GraphQL(`query RepositoryAssignableUsers\b`),
					httpmock.StringResponse(`
						{ "data": { "repository": { "assignableUsers": {
							"nodes": [
								{ "login": "hubot", "id": "HUBOTID", "name": "" },
								{ "login": "MonaLisa", "id": "MONAID", "name": "Mona Display Name" }
							],
							"pageInfo": { "hasNextPage": false }
						} } } }
					`))
				reg.Register(
					httpmock.GraphQL(`query OrganizationTeamList\b`),
					httpmock.StringResponse(`
						{ "data": { "organization": { "teams": {
							"nodes": [
								{ "slug": "core", "id": "COREID" },
+ 79 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh completion
short: Generate shell completion scripts for GitHub CLI commands.
long: |-
    When installing GitHub CLI through a package manager, it's possible that
    no additional shell configuration is necessary to gain completion support. For
    Homebrew, see <https://docs.brew.sh/Shell-Completion>

    If you need to set up completions manually, follow the instructions below. The exact
    config file locations might vary based on your system. Make sure to restart your
    shell before testing whether completions are working.

    ### bash
DOCS
gh_completion.md:66Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh config
short: Display or change configuration settings for gh.
pname: gh
plink: gh.yaml
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh config clear-cache
short: Clear the cli cache
pname: gh config
plink: gh_config.yaml
DOCS
gh_config_clear-cache.md:1Markdown · 13 words
TESTS
pkg/cmd/config/clear-cache/clear_cache_test.go:13pkg/cmd/config/clear-cache/clear_cache_test::TestClearCacheRun · Go · 20 lines
func TestClearCacheRun(t *testing.T) {
	cacheDir := filepath.Join(t.TempDir(), "gh-cli-cache")
	ios, _, stdout, stderr := iostreams.Test()
	opts := &ClearCacheOptions{
		IO:       ios,
		CacheDir: cacheDir,
	}

	if err := os.Mkdir(opts.CacheDir, 0600); err != nil {
		assert.NoError(t, err)
	}

	if err := clearCacheRun(opts); err != nil {
		assert.NoError(t, err)
	}

	assert.NoDirExistsf(t, opts.CacheDir, fmt.Sprintf("Cache dir: %s still exists", opts.CacheDir))
	assert.Equal(t, "✓ Cleared the cache\n", stdout.String())
	assert.Equal(t, "", stderr.String())
}
WORKFLOWS

N/A

CONTRACT
command: gh config get
short: Print the value of a given configuration key
pname: gh config
plink: gh_config.yaml
options:
    - option: host
      shorthand: h
      value_type: string
      description: Get per-host setting
DOCS
gh_config_get.md:1Markdown · 18 words
TESTS
pkg/cmd/config/get/get_test.go:16pkg/cmd/config/get/get_test::TestNewCmdConfigGet · Go · 62 lines
func TestNewCmdConfigGet(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		output   GetOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   GetOptions{},
			wantsErr: true,
		},
		{
			name:     "get key",
			input:    "key",
			output:   GetOptions{Key: "key"},
			wantsErr: false,
		},
		{
			name:     "get key with host",
			input:    "key --host test.com",
			output:   GetOptions{Hostname: "test.com", Key: "key"},
			wantsErr: false,
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			f := &cmdutil.Factory{
+ 32 more lines · read full file
pkg/cmd/config/get/get_test.go:79pkg/cmd/config/get/get_test::Test_getRun · Go · 54 lines
func Test_getRun(t *testing.T) {
	tests := []struct {
		name   string
		input  *GetOptions
		stdout string
		err    error
	}{
		{
			name: "get key",
			input: &GetOptions{
				Key: "editor",
				Config: func() gh.Config {
					cfg := config.NewBlankConfig()
					cfg.Set("", "editor", "ed")
					return cfg
				}(),
			},
			stdout: "ed\n",
		},
		{
			name: "get key scoped by host",
			input: &GetOptions{
				Hostname: "github.com",
				Key:      "editor",
				Config: func() gh.Config {
					cfg := config.NewBlankConfig()
					cfg.Set("", "editor", "ed")
					cfg.Set("github.com", "editor", "vim")
					return cfg
				}(),
+ 24 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh config get
short: Print the value of a given configuration key
pname: gh config
plink: gh_config.yaml
options:
    - option: host
      shorthand: h
      value_type: string
      description: Get per-host setting
DOCS
gh_config_get.md:19Markdown · 3 words
TESTS
pkg/cmd/config/get/get_test.go:16pkg/cmd/config/get/get_test::TestNewCmdConfigGet · Go · 62 lines
func TestNewCmdConfigGet(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		output   GetOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   GetOptions{},
			wantsErr: true,
		},
		{
			name:     "get key",
			input:    "key",
			output:   GetOptions{Key: "key"},
			wantsErr: false,
		},
		{
			name:     "get key with host",
			input:    "key --host test.com",
			output:   GetOptions{Hostname: "test.com", Key: "key"},
			wantsErr: false,
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			f := &cmdutil.Factory{
+ 32 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh config list
short: Print a list of configuration keys and values
pname: gh config
plink: gh_config.yaml
options:
    - option: host
      shorthand: h
      value_type: string
      description: Get per-host configuration
DOCS
gh_config_list.md:1Markdown · 21 words
TESTS
pkg/cmd/config/list/list_test.go:17pkg/cmd/config/list/list_test::TestNewCmdConfigList · Go · 55 lines
func TestNewCmdConfigList(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		output   ListOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   ListOptions{},
			wantsErr: false,
		},
		{
			name:     "list with host",
			input:    "--host HOST.com",
			output:   ListOptions{Hostname: "HOST.com"},
			wantsErr: false,
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			f := &cmdutil.Factory{
				Config: func() (gh.Config, error) {
					return config.NewBlankConfig(), nil
				},
			}

			argv, err := shlex.Split(tt.input)
+ 25 more lines · read full file
pkg/cmd/config/list/list_test.go:73pkg/cmd/config/list/list_test::Test_listRun · Go · 53 lines
func Test_listRun(t *testing.T) {
	tests := []struct {
		name    string
		input   *ListOptions
		config  gh.Config
		stdout  string
		wantErr bool
	}{
		{
			name: "list",
			config: func() gh.Config {
				cfg := config.NewBlankConfig()
				cfg.Set("HOST", "git_protocol", "ssh")
				cfg.Set("HOST", "editor", "/usr/bin/vim")
				cfg.Set("HOST", "prompt", "disabled")
				cfg.Set("HOST", "prefer_editor_prompt", "enabled")
				cfg.Set("HOST", "pager", "less")
				cfg.Set("HOST", "http_unix_socket", "")
				cfg.Set("HOST", "browser", "brave")
				return cfg
			}(),
			input: &ListOptions{Hostname: "HOST"},
			stdout: heredoc.Doc(`
				git_protocol=ssh
				editor=/usr/bin/vim
				prompt=disabled
				prefer_editor_prompt=enabled
				pager=less
				http_unix_socket=
				browser=brave
+ 23 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh config list
short: Print a list of configuration keys and values
pname: gh config
plink: gh_config.yaml
options:
    - option: host
      shorthand: h
      value_type: string
      description: Get per-host configuration
DOCS
gh_config_list.md:19Markdown · 3 words
TESTS
pkg/cmd/config/list/list_test.go:17pkg/cmd/config/list/list_test::TestNewCmdConfigList · Go · 55 lines
func TestNewCmdConfigList(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		output   ListOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   ListOptions{},
			wantsErr: false,
		},
		{
			name:     "list with host",
			input:    "--host HOST.com",
			output:   ListOptions{Hostname: "HOST.com"},
			wantsErr: false,
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			f := &cmdutil.Factory{
				Config: func() (gh.Config, error) {
					return config.NewBlankConfig(), nil
				},
			}

			argv, err := shlex.Split(tt.input)
+ 25 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh config set
short: Update configuration with a value for the given key
pname: gh config
plink: gh_config.yaml
options:
    - option: host
      shorthand: h
      value_type: string
      description: Set per-host setting
TESTS
pkg/cmd/config/set/set_test.go:15pkg/cmd/config/set/set_test::TestNewCmdConfigSet · Go · 71 lines
func TestNewCmdConfigSet(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		output   SetOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   SetOptions{},
			wantsErr: true,
		},
		{
			name:     "no value argument",
			input:    "key",
			output:   SetOptions{},
			wantsErr: true,
		},
		{
			name:     "set key value",
			input:    "key value",
			output:   SetOptions{Key: "key", Value: "value"},
			wantsErr: false,
		},
		{
			name:     "set key value with host",
			input:    "key value --host test.com",
			output:   SetOptions{Hostname: "test.com", Key: "key", Value: "value"},
			wantsErr: false,
+ 41 more lines · read full file
pkg/cmd/config/set/set_test.go:87pkg/cmd/config/set/set_test::Test_setRun · Go · 73 lines
func Test_setRun(t *testing.T) {
	tests := []struct {
		name          string
		input         *SetOptions
		expectedValue string
		stdout        string
		stderr        string
		wantsErr      bool
		errMsg        string
	}{
		{
			name: "set key value",
			input: &SetOptions{
				Config: config.NewBlankConfig(),
				Key:    "editor",
				Value:  "vim",
			},
			expectedValue: "vim",
		},
		{
			name: "set key value scoped by host",
			input: &SetOptions{
				Config:   config.NewBlankConfig(),
				Hostname: "github.com",
				Key:      "editor",
				Value:    "vim",
			},
			expectedValue: "vim",
		},
		{
+ 43 more lines · read full file
pkg/cmd/config/set/set_test.go:161pkg/cmd/config/set/set_test::Test_ValidateValue · Go · 16 lines
func Test_ValidateValue(t *testing.T) {
	err := ValidateValue("git_protocol", "sshpps")
	assert.EqualError(t, err, "invalid value")

	err = ValidateValue("git_protocol", "ssh")
	assert.NoError(t, err)

	err = ValidateValue("editor", "vim")
	assert.NoError(t, err)

	err = ValidateValue("got", "123")
	assert.NoError(t, err)

	err = ValidateValue("http_unix_socket", "really_anything/is/allowed/and/net.Dial\\(...\\)/will/ultimately/validate")
	assert.NoError(t, err)
}
+ 1 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh config set
short: Update configuration with a value for the given key
pname: gh config
plink: gh_config.yaml
options:
    - option: host
      shorthand: h
      value_type: string
      description: Set per-host setting
DOCS
gh_config_set.md:19Markdown · 3 words
TESTS
pkg/cmd/config/set/set_test.go:15pkg/cmd/config/set/set_test::TestNewCmdConfigSet · Go · 71 lines
func TestNewCmdConfigSet(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		output   SetOptions
		wantsErr bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   SetOptions{},
			wantsErr: true,
		},
		{
			name:     "no value argument",
			input:    "key",
			output:   SetOptions{},
			wantsErr: true,
		},
		{
			name:     "set key value",
			input:    "key value",
			output:   SetOptions{Key: "key", Value: "value"},
			wantsErr: false,
		},
		{
			name:     "set key value with host",
			input:    "key value --host test.com",
			output:   SetOptions{Hostname: "test.com", Key: "key", Value: "value"},
			wantsErr: false,
+ 41 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh copilot
short: Runs the GitHub Copilot CLI.
long: |-
    Executing the Copilot CLI through `gh` is currently in preview and subject to change.

    If already installed, `gh` will execute the Copilot CLI found in your `PATH`.
    If the Copilot CLI is not installed, it will be downloaded to /Users/daamanana/.local/share/gh/copilot.

    Use `--remove` to remove the downloaded Copilot CLI.

    This command is only supported on Windows, Linux, and Darwin, on amd64/x64
    or arm64 architectures.
TESTS
pkg/cmd/copilot/copilot_test.go:28pkg/cmd/copilot/copilot_test::TestNewCmdCopilot · Go · 115 lines
func TestNewCmdCopilot(t *testing.T) {
	tests := []struct {
		name          string
		args          string
		wantOpts      CopilotOptions
		wantErrString string
		wantHelp      bool
	}{
		{
			name: "no argument",
			args: "",
			wantOpts: CopilotOptions{
				CopilotArgs: []string{},
			},
			wantErrString: "",
		},
		{
			name: "with arguments",
			args: "some-arg some-other-arg",
			wantOpts: CopilotOptions{
				CopilotArgs: []string{"some-arg", "some-other-arg"},
			},
		},
		{
			name: "with --remove alone",
			args: "--remove",
			wantOpts: CopilotOptions{
				Remove: true,
			},
		},
+ 85 more lines · read full file
pkg/cmd/copilot/copilot_test.go:144pkg/cmd/copilot/copilot_test::TestRemoveCopilot · Go · 24 lines
func TestRemoveCopilot(t *testing.T) {
	t.Run("removes existing install directory", func(t *testing.T) {
		// Create a temporary directory to simulate the install directory
		tmpDir := t.TempDir()
		installDir := filepath.Join(tmpDir, "copilot")
		require.NoError(t, os.MkdirAll(installDir, 0755), "failed to create test directory")
		// Create a dummy file in the directory
		dummyFile := filepath.Join(installDir, "copilot")
		require.NoError(t, os.WriteFile(dummyFile, []byte("test"), 0755), "failed to create test file")

		err := removeCopilot(installDir)
		require.NoError(t, err, "unexpected error")

		_, err = os.Stat(installDir)
		require.True(t, os.IsNotExist(err), "expected install directory to be removed")
	})

	t.Run("handles non-existent directory", func(t *testing.T) {
		tmpDir := t.TempDir()
		installDir := filepath.Join(tmpDir, "copilot")

		require.ErrorContains(t, removeCopilot(installDir), "failed to remove Copilot CLI")
	})
}
pkg/cmd/copilot/copilot_test.go:145pkg/cmd/copilot/copilot_test::removes existing install directory · Go · 15 lines
t.Run("removes existing install directory", func(t *testing.T) {
	// Create a temporary directory to simulate the install directory
	tmpDir := t.TempDir()
	installDir := filepath.Join(tmpDir, "copilot")
	require.NoError(t, os.MkdirAll(installDir, 0755), "failed to create test directory")
	// Create a dummy file in the directory
	dummyFile := filepath.Join(installDir, "copilot")
	require.NoError(t, os.WriteFile(dummyFile, []byte("test"), 0755), "failed to create test file")

	err := removeCopilot(installDir)
	require.NoError(t, err, "unexpected error")

	_, err = os.Stat(installDir)
	require.True(t, os.IsNotExist(err), "expected install directory to be removed")
})
+ 20 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh copilot
short: Runs the GitHub Copilot CLI.
long: |-
    Executing the Copilot CLI through `gh` is currently in preview and subject to change.

    If already installed, `gh` will execute the Copilot CLI found in your `PATH`.
    If the Copilot CLI is not installed, it will be downloaded to /Users/daamanana/.local/share/gh/copilot.

    Use `--remove` to remove the downloaded Copilot CLI.

    This command is only supported on Windows, Linux, and Darwin, on amd64/x64
    or arm64 architectures.
DOCS
gh_copilot.md:35Markdown · 5 words
TESTS
pkg/cmd/copilot/copilot_test.go:28pkg/cmd/copilot/copilot_test::TestNewCmdCopilot · Go · 115 lines
func TestNewCmdCopilot(t *testing.T) {
	tests := []struct {
		name          string
		args          string
		wantOpts      CopilotOptions
		wantErrString string
		wantHelp      bool
	}{
		{
			name: "no argument",
			args: "",
			wantOpts: CopilotOptions{
				CopilotArgs: []string{},
			},
			wantErrString: "",
		},
		{
			name: "with arguments",
			args: "some-arg some-other-arg",
			wantOpts: CopilotOptions{
				CopilotArgs: []string{"some-arg", "some-other-arg"},
			},
		},
		{
			name: "with --remove alone",
			args: "--remove",
			wantOpts: CopilotOptions{
				Remove: true,
			},
		},
+ 85 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh extension
short: GitHub CLI extensions are repositories that provide additional gh commands.
long: |-
    The name of the extension repository must start with `gh-` and it must contain an
    executable of the same name. All arguments passed to the `gh <extname>` invocation
    will be forwarded to the `gh-<extname>` executable of the extension.

    An extension cannot override any of the core gh commands. If an extension name conflicts
    with a core gh command, you can use `gh extension exec <extname>`.

    When an extension is executed, gh will check for new versions once every 24 hours and display
    an upgrade notice. See `gh help environment` for information on disabling extension notices.
TESTS
pkg/cmd/extension/extension_test.go:10pkg/cmd/extension/extension_test::TestUpdateAvailable_IsLocal · Go · 7 lines
func TestUpdateAvailable_IsLocal(t *testing.T) {
	e := &Extension{
		kind: LocalKind,
	}

	assert.False(t, e.UpdateAvailable())
}
pkg/cmd/extension/extension_test.go:18pkg/cmd/extension/extension_test::TestUpdateAvailable_NoCurrentVersion · Go · 7 lines
func TestUpdateAvailable_NoCurrentVersion(t *testing.T) {
	e := &Extension{
		kind: LocalKind,
	}

	assert.False(t, e.UpdateAvailable())
}
pkg/cmd/extension/extension_test.go:26pkg/cmd/extension/extension_test::TestUpdateAvailable_NoLatestVersion · Go · 8 lines
func TestUpdateAvailable_NoLatestVersion(t *testing.T) {
	e := &Extension{
		kind:           BinaryKind,
		currentVersion: "1.0.0",
	}

	assert.False(t, e.UpdateAvailable())
}
+ 14 more tests · open all in source
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension browse
short: This command will take over your terminal and run a fully interactive
long: |-
    interface for browsing, adding, and removing gh extensions. A terminal
    width greater than 100 columns is recommended.

    To learn how to control this interface, press `?` after running to see
    the help text.

    Press `q` to quit.

    Running this command with `--single-column` should make this command
DOCS
gh_extension_browse.md:1Markdown · 106 words
TESTS
pkg/cmd/extension/browse/browse_test.go:25pkg/cmd/extension/browse/browse_test::Test_getSelectedReadme · Go · 42 lines
func Test_getSelectedReadme(t *testing.T) {
	reg := httpmock.Registry{}
	defer reg.Verify(t)

	content := base64.StdEncoding.EncodeToString([]byte("lol"))

	reg.Register(
		httpmock.REST("GET", "repos/cli/gh-cool/readme"),
		httpmock.JSONResponse(view.RepoReadme{Content: content}))

	client := &http.Client{Transport: &reg}

	rg := newReadmeGetter(client, time.Second)
	opts := ExtBrowseOpts{
		Rg: rg,
	}
	readme := tview.NewTextView()
	ui := uiRegistry{
		List: tview.NewList(),
	}
	extEntries := []extEntry{
		{
			Name:        "gh-cool",
			FullName:    "cli/gh-cool",
			Installed:   false,
			Official:    true,
			description: "it's just cool ok",
		},
		{
			Name:        "gh-screensaver",
+ 12 more lines · read full file
pkg/cmd/extension/browse/browse_test.go:68pkg/cmd/extension/browse/browse_test::Test_getExtensionRepos · Go · 124 lines
func Test_getExtensionRepos(t *testing.T) {
	reg := httpmock.Registry{}
	defer reg.Verify(t)

	client := &http.Client{Transport: &reg}

	values := url.Values{
		"page":     []string{"1"},
		"per_page": []string{"100"},
		"q":        []string{"topic:gh-extension"},
	}
	cfg := config.NewBlankConfig()

	cfg.AuthenticationFunc = func() gh.AuthConfig {
		authCfg := &config.AuthConfig{}
		authCfg.SetDefaultHost("github.com", "")
		return authCfg
	}

	reg.Register(
		httpmock.QueryMatcher("GET", "search/repositories", values),
		httpmock.JSONResponse(map[string]interface{}{
			"incomplete_results": false,
			"total_count":        4,
			"items": []interface{}{
				map[string]interface{}{
					"name":        "gh-screensaver",
					"full_name":   "vilmibm/gh-screensaver",
					"description": "terminal animations",
					"owner": map[string]interface{}{
+ 94 more lines · read full file
pkg/cmd/extension/browse/browse_test.go:193pkg/cmd/extension/browse/browse_test::Test_extEntry · Go · 76 lines
func Test_extEntry(t *testing.T) {
	cases := []struct {
		name          string
		ee            extEntry
		expectedTitle string
		expectedDesc  string
	}{
		{
			name: "official",
			ee: extEntry{
				Name:        "gh-cool",
				FullName:    "cli/gh-cool",
				Installed:   false,
				Official:    true,
				description: "it's just cool ok",
			},
			expectedTitle: "cli/gh-cool [yellow](official)",
			expectedDesc:  "it's just cool ok",
		},
		{
			name: "no description",
			ee: extEntry{
				Name:        "gh-nodesc",
				FullName:    "barryburton/gh-nodesc",
				Installed:   false,
				Official:    false,
				description: "",
			},
			expectedTitle: "barryburton/gh-nodesc",
			expectedDesc:  "no description provided",
+ 46 more lines · read full file
+ 1 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh extension browse
short: This command will take over your terminal and run a fully interactive
long: |-
    interface for browsing, adding, and removing gh extensions. A terminal
    width greater than 100 columns is recommended.

    To learn how to control this interface, press `?` after running to see
    the help text.

    Press `q` to quit.

    Running this command with `--single-column` should make this command
DOCS
gh_extension_browse.md:37Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension browse
short: This command will take over your terminal and run a fully interactive
long: |-
    interface for browsing, adding, and removing gh extensions. A terminal
    width greater than 100 columns is recommended.

    To learn how to control this interface, press `?` after running to see
    the help text.

    Press `q` to quit.

    Running this command with `--single-column` should make this command
DOCS
gh_extension_browse.md:38Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension create
short: Create a new extension
pname: gh extension
plink: gh_extension.yaml
options:
    - option: precompiled
      value_type: string
      description: 'Create a precompiled extension. Possible values: go, other'
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension create
short: Create a new extension
pname: gh extension
plink: gh_extension.yaml
options:
    - option: precompiled
      value_type: string
      description: 'Create a precompiled extension. Possible values: go, other'
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh extension install
short: Install a GitHub CLI extension from a GitHub or local repository.
long: |-
    For GitHub repositories, the repository argument can be specified in
    `OWNER/REPO` format or as a full repository URL.
    The URL format is useful when the repository is not hosted on `github.com`.

    For remote repositories, the GitHub CLI first looks for the release artifacts assuming
    that it's a binary extension i.e. prebuilt binaries provided as part of the release.
    In the absence of a release, the repository itself is cloned assuming that it's a
    script extension i.e. prebuilt executable or script exists on its root.
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension install
short: Install a GitHub CLI extension from a GitHub or local repository.
long: |-
    For GitHub repositories, the repository argument can be specified in
    `OWNER/REPO` format or as a full repository URL.
    The URL format is useful when the repository is not hosted on `github.com`.

    For remote repositories, the GitHub CLI first looks for the release artifacts assuming
    that it's a binary extension i.e. prebuilt binaries provided as part of the release.
    In the absence of a release, the repository itself is cloned assuming that it's a
    script extension i.e. prebuilt executable or script exists on its root.
DOCS
gh_extension_install.md:48Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension install
short: Install a GitHub CLI extension from a GitHub or local repository.
long: |-
    For GitHub repositories, the repository argument can be specified in
    `OWNER/REPO` format or as a full repository URL.
    The URL format is useful when the repository is not hosted on `github.com`.

    For remote repositories, the GitHub CLI first looks for the release artifacts assuming
    that it's a binary extension i.e. prebuilt binaries provided as part of the release.
    In the absence of a release, the repository itself is cloned assuming that it's a
    script extension i.e. prebuilt executable or script exists on its root.
DOCS
gh_extension_install.md:49Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension list
short: List installed extension commands
pname: gh extension
plink: gh_extension.yaml
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh extension remove
short: Remove an installed extension
pname: gh extension
plink: gh_extension.yaml
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh extension search
short: Search for gh extensions.
long: |-
    With no arguments, this command prints out the first 30 extensions
    available to install sorted by number of stars. More extensions can
    be fetched by specifying a higher limit with the `--limit` flag.

    When connected to a terminal, this command prints out three columns.
    The first has a ✓ if the extension is already installed locally. The
    second is the full name of the extension repository in `OWNER/REPO`
    format. The third is the extension's description.
DOCS
gh_extension_search.md:1Markdown · 206 words
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension search
short: Search for gh extensions.
long: |-
    With no arguments, this command prints out the first 30 extensions
    available to install sorted by number of stars. More extensions can
    be fetched by specifying a higher limit with the `--limit` flag.

    When connected to a terminal, this command prints out three columns.
    The first has a ✓ if the extension is already installed locally. The
    second is the full name of the extension repository in `OWNER/REPO`
    format. The third is the extension's description.
DOCS
gh_extension_search.md:47Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension search
short: Search for gh extensions.
long: |-
    With no arguments, this command prints out the first 30 extensions
    available to install sorted by number of stars. More extensions can
    be fetched by specifying a higher limit with the `--limit` flag.

    When connected to a terminal, this command prints out three columns.
    The first has a ✓ if the extension is already installed locally. The
    second is the full name of the extension repository in `OWNER/REPO`
    format. The third is the extension's description.
DOCS
gh_extension_search.md:48Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension search
short: Search for gh extensions.
long: |-
    With no arguments, this command prints out the first 30 extensions
    available to install sorted by number of stars. More extensions can
    be fetched by specifying a higher limit with the `--limit` flag.

    When connected to a terminal, this command prints out three columns.
    The first has a ✓ if the extension is already installed locally. The
    second is the full name of the extension repository in `OWNER/REPO`
    format. The third is the extension's description.
DOCS
gh_extension_search.md:49Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh extension search
short: Search for gh extensions.
long: |-
    With no arguments, this command prints out the first 30 extensions
    available to install sorted by number of stars. More extensions can
    be fetched by specifying a higher limit with the `--limit` flag.

    When connected to a terminal, this command prints out three columns.
    The first has a ✓ if the extension is already installed locally. The
    second is the full name of the extension repository in `OWNER/REPO`
    format. The third is the extension's description.
DOCS
gh_extension_search.md:50Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh extension search
short: Search for gh extensions.
long: |-
    With no arguments, this command prints out the first 30 extensions
    available to install sorted by number of stars. More extensions can
    be fetched by specifying a higher limit with the `--limit` flag.

    When connected to a terminal, this command prints out three columns.
    The first has a ✓ if the extension is already installed locally. The
    second is the full name of the extension repository in `OWNER/REPO`
    format. The third is the extension's description.
DOCS
gh_extension_search.md:51Markdown · 11 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh extension search
short: Search for gh extensions.
long: |-
    With no arguments, this command prints out the first 30 extensions
    available to install sorted by number of stars. More extensions can
    be fetched by specifying a higher limit with the `--limit` flag.

    When connected to a terminal, this command prints out three columns.
    The first has a ✓ if the extension is already installed locally. The
    second is the full name of the extension repository in `OWNER/REPO`
    format. The third is the extension's description.
DOCS
gh_extension_search.md:52Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh extension search
short: Search for gh extensions.
long: |-
    With no arguments, this command prints out the first 30 extensions
    available to install sorted by number of stars. More extensions can
    be fetched by specifying a higher limit with the `--limit` flag.

    When connected to a terminal, this command prints out three columns.
    The first has a ✓ if the extension is already installed locally. The
    second is the full name of the extension repository in `OWNER/REPO`
    format. The third is the extension's description.
DOCS
gh_extension_search.md:53Markdown · 4 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh extension search
short: Search for gh extensions.
long: |-
    With no arguments, this command prints out the first 30 extensions
    available to install sorted by number of stars. More extensions can
    be fetched by specifying a higher limit with the `--limit` flag.

    When connected to a terminal, this command prints out three columns.
    The first has a ✓ if the extension is already installed locally. The
    second is the full name of the extension repository in `OWNER/REPO`
    format. The third is the extension's description.
DOCS
gh_extension_search.md:54Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension search
short: Search for gh extensions.
long: |-
    With no arguments, this command prints out the first 30 extensions
    available to install sorted by number of stars. More extensions can
    be fetched by specifying a higher limit with the `--limit` flag.

    When connected to a terminal, this command prints out three columns.
    The first has a ✓ if the extension is already installed locally. The
    second is the full name of the extension repository in `OWNER/REPO`
    format. The third is the extension's description.
DOCS
gh_extension_search.md:55Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension upgrade
short: Upgrade installed extensions
pname: gh extension
plink: gh_extension.yaml
options:
    - option: all
      value_type: bool
      default_value: "false"
      description: Upgrade all extensions
    - option: dry-run
      value_type: bool
      default_value: "false"
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh extension upgrade
short: Upgrade installed extensions
pname: gh extension
plink: gh_extension.yaml
options:
    - option: all
      value_type: bool
      default_value: "false"
      description: Upgrade all extensions
    - option: dry-run
      value_type: bool
      default_value: "false"
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh extension upgrade
short: Upgrade installed extensions
pname: gh extension
plink: gh_extension.yaml
options:
    - option: all
      value_type: bool
      default_value: "false"
      description: Upgrade all extensions
    - option: dry-run
      value_type: bool
      default_value: "false"
DOCS
gh_extension_upgrade.md:20Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh extension upgrade
short: Upgrade installed extensions
pname: gh extension
plink: gh_extension.yaml
options:
    - option: all
      value_type: bool
      default_value: "false"
      description: Upgrade all extensions
    - option: dry-run
      value_type: bool
      default_value: "false"
DOCS
gh_extension_upgrade.md:21Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gist
short: Work with GitHub gists.
pname: gh
plink: gh.yaml
DOCS
gh_gist.md:1Markdown · 40 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gist clone
short: Clone a GitHub gist locally.
pname: gh gist
plink: gh_gist.yaml
DOCS
gh_gist_clone.md:1Markdown · 46 words
TESTS
pkg/cmd/gist/clone/clone_test.go:57pkg/cmd/gist/clone/clone_test::Test_GistClone · Go · 58 lines
func Test_GistClone(t *testing.T) {
	tests := []struct {
		name string
		args string
		want string
	}{
		{
			name: "shorthand",
			args: "GIST",
			want: "git clone https://gist.github.com/GIST.git",
		},
		{
			name: "shorthand with directory",
			args: "GIST target_directory",
			want: "git clone https://gist.github.com/GIST.git target_directory",
		},
		{
			name: "clone arguments",
			args: "GIST -- -o upstream --depth 1",
			want: "git clone -o upstream --depth 1 https://gist.github.com/GIST.git",
		},
		{
			name: "clone arguments with directory",
			args: "GIST target_directory -- -o upstream --depth 1",
			want: "git clone -o upstream --depth 1 https://gist.github.com/GIST.git target_directory",
		},
		{
			name: "HTTPS URL",
			args: "https://gist.github.com/OWNER/GIST",
			want: "git clone https://gist.github.com/OWNER/GIST",
+ 28 more lines · read full file
pkg/cmd/gist/clone/clone_test.go:116pkg/cmd/gist/clone/clone_test::Test_GistClone_flagError · Go · 6 lines
func Test_GistClone_flagError(t *testing.T) {
	_, err := runCloneCommand(nil, "--depth 1 GIST")
	if err == nil || err.Error() != "unknown flag: --depth\nSeparate git clone flags with '--'." {
		t.Errorf("unexpected error %v", err)
	}
}
pkg/cmd/gist/clone/clone_test.go:123pkg/cmd/gist/clone/clone_test::Test_formatRemoteURL · Go · 56 lines
func Test_formatRemoteURL(t *testing.T) {
	type args struct {
		hostname string
		gistID   string
		protocol string
	}
	tests := []struct {
		name string
		args args
		want string
	}{
		{
			name: "github.com HTTPS",
			args: args{
				hostname: "github.com",
				protocol: "https",
				gistID:   "ID",
			},
			want: "https://gist.github.com/ID.git",
		},
		{
			name: "github.com SSH",
			args: args{
				hostname: "github.com",
				protocol: "ssh",
				gistID:   "ID",
			},
			want: "git@gist.github.com:ID.git",
		},
		{
+ 26 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist create
short: Create a new GitHub gist with given contents.
long: |-
    Gists can be created from one or multiple files. Alternatively, pass `-` as
    filename to read from standard input.

    By default, gists are secret; use `--public` to make publicly listed ones.
pname: gh gist
plink: gh_gist.yaml
options:
    - option: desc
      shorthand: d
DOCS
gh_gist_create.md:1Markdown · 53 words
TESTS
pkg/cmd/gist/create/create_test.go:26pkg/cmd/gist/create/create_test::Test_processFiles · Go · 10 lines
func Test_processFiles(t *testing.T) {
	fakeStdin := strings.NewReader("hey cool how is it going")
	files, err := processFiles(io.NopCloser(fakeStdin), "", []string{"-"})
	if err != nil {
		t.Fatalf("unexpected error processing files: %s", err)
	}

	assert.Equal(t, 1, len(files))
	assert.Equal(t, "hey cool how is it going", files["gistfile0.txt"].Content)
}
pkg/cmd/gist/create/create_test.go:37pkg/cmd/gist/create/create_test::Test_guessGistName_stdin · Go · 8 lines
func Test_guessGistName_stdin(t *testing.T) {
	files := map[string]*shared.GistFile{
		"gistfile0.txt": {Content: "sample content"},
	}

	gistName := guessGistName(files)
	assert.Equal(t, "", gistName)
}
pkg/cmd/gist/create/create_test.go:46pkg/cmd/gist/create/create_test::Test_guessGistName_userFiles · Go · 10 lines
func Test_guessGistName_userFiles(t *testing.T) {
	files := map[string]*shared.GistFile{
		"fig.txt":       {Content: "I am a fig"},
		"apple.txt":     {Content: "I am an apple"},
		"gistfile0.txt": {Content: "sample content"},
	}

	gistName := guessGistName(files)
	assert.Equal(t, "apple.txt", gistName)
}
+ 3 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist create
short: Create a new GitHub gist with given contents.
long: |-
    Gists can be created from one or multiple files. Alternatively, pass `-` as
    filename to read from standard input.

    By default, gists are secret; use `--public` to make publicly listed ones.
pname: gh gist
plink: gh_gist.yaml
options:
    - option: desc
      shorthand: d
DOCS
gh_gist_create.md:25Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gist create
short: Create a new GitHub gist with given contents.
long: |-
    Gists can be created from one or multiple files. Alternatively, pass `-` as
    filename to read from standard input.

    By default, gists are secret; use `--public` to make publicly listed ones.
pname: gh gist
plink: gh_gist.yaml
options:
    - option: desc
      shorthand: d
DOCS
gh_gist_create.md:26Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gist create
short: Create a new GitHub gist with given contents.
long: |-
    Gists can be created from one or multiple files. Alternatively, pass `-` as
    filename to read from standard input.

    By default, gists are secret; use `--public` to make publicly listed ones.
pname: gh gist
plink: gh_gist.yaml
options:
    - option: desc
      shorthand: d
DOCS
gh_gist_create.md:27Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist create
short: Create a new GitHub gist with given contents.
long: |-
    Gists can be created from one or multiple files. Alternatively, pass `-` as
    filename to read from standard input.

    By default, gists are secret; use `--public` to make publicly listed ones.
pname: gh gist
plink: gh_gist.yaml
options:
    - option: desc
      shorthand: d
DOCS
gh_gist_create.md:28Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gist delete
short: Delete a GitHub gist.
long: |-
    To delete a gist interactively, use `gh gist delete` with no arguments.

    To delete a gist non-interactively, supply the gist id or url.
pname: gh gist
plink: gh_gist.yaml
options:
    - option: "yes"
      value_type: bool
      default_value: "false"
DOCS
gh_gist_delete.md:1Markdown · 37 words
TESTS
pkg/cmd/gist/delete/delete_test.go:24pkg/cmd/gist/delete/delete_test::TestNewCmdDelete · Go · 96 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name       string
		cli        string
		tty        bool
		want       DeleteOptions
		wantErr    bool
		wantErrMsg string
	}{
		{
			name: "valid selector",
			cli:  "123",
			tty:  true,
			want: DeleteOptions{
				Selector: "123",
			},
		},
		{
			name: "valid selector, no ID supplied",
			cli:  "",
			tty:  true,
			want: DeleteOptions{
				Selector: "",
			},
		},
		{
			name: "no ID supplied with --yes",
			cli:  "--yes",
			tty:  true,
			want: DeleteOptions{
+ 66 more lines · read full file
pkg/cmd/gist/delete/delete_test.go:121pkg/cmd/gist/delete/delete_test::Test_deleteRun · Go · 207 lines
func Test_deleteRun(t *testing.T) {
	tests := []struct {
		name            string
		opts            *DeleteOptions
		cancel          bool
		httpStubs       func(*httpmock.Registry)
		mockPromptGists bool
		noGists         bool
		wantErr         bool
		wantStdout      string
		wantStderr      string
	}{
		{
			name: "successfully delete",
			opts: &DeleteOptions{
				Selector: "1234",
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.REST("GET", "gists/1234"),
					httpmock.JSONResponse(shared.Gist{ID: "1234", Files: map[string]*shared.GistFile{"cool.txt": {Filename: "cool.txt"}}}))
				reg.Register(httpmock.REST("DELETE", "gists/1234"),
					httpmock.StatusStringResponse(200, "{}"))
			},
			wantStdout: "✓ Gist \"cool.txt\" deleted\n",
		},
		{
			name: "successfully delete with prompt",
			opts: &DeleteOptions{
				Selector: "",
			},
+ 177 more lines · read full file
pkg/cmd/gist/delete/delete_test.go:329pkg/cmd/gist/delete/delete_test::Test_gistDelete · Go · 70 lines
func Test_gistDelete(t *testing.T) {
	tests := []struct {
		name          string
		httpStubs     func(*httpmock.Registry)
		hostname      string
		gistID        string
		wantErr       error
		wantErrString string
	}{
		{
			name: "successful delete",
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("DELETE", "gists/1234"),
					httpmock.StatusStringResponse(204, "{}"),
				)
			},
			hostname: "github.com",
			gistID:   "1234",
		},
		{
			name: "when a gist is not found, it returns a NotFoundError",
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("DELETE", "gists/1234"),
					httpmock.StatusStringResponse(404, "{}"),
				)
			},
			hostname:      "github.com",
			gistID:        "1234",
+ 40 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist delete
short: Delete a GitHub gist.
long: |-
    To delete a gist interactively, use `gh gist delete` with no arguments.

    To delete a gist non-interactively, supply the gist id or url.
pname: gh gist
plink: gh_gist.yaml
options:
    - option: "yes"
      value_type: bool
      default_value: "false"
DOCS
gh_gist_delete.md:24Markdown · 4 words
TESTS
pkg/cmd/gist/delete/delete_test.go:24pkg/cmd/gist/delete/delete_test::TestNewCmdDelete · Go · 96 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name       string
		cli        string
		tty        bool
		want       DeleteOptions
		wantErr    bool
		wantErrMsg string
	}{
		{
			name: "valid selector",
			cli:  "123",
			tty:  true,
			want: DeleteOptions{
				Selector: "123",
			},
		},
		{
			name: "valid selector, no ID supplied",
			cli:  "",
			tty:  true,
			want: DeleteOptions{
				Selector: "",
			},
		},
		{
			name: "no ID supplied with --yes",
			cli:  "--yes",
			tty:  true,
			want: DeleteOptions{
+ 66 more lines · read full file
pkg/cmd/gist/delete/delete_test.go:121pkg/cmd/gist/delete/delete_test::Test_deleteRun · Go · 207 lines
func Test_deleteRun(t *testing.T) {
	tests := []struct {
		name            string
		opts            *DeleteOptions
		cancel          bool
		httpStubs       func(*httpmock.Registry)
		mockPromptGists bool
		noGists         bool
		wantErr         bool
		wantStdout      string
		wantStderr      string
	}{
		{
			name: "successfully delete",
			opts: &DeleteOptions{
				Selector: "1234",
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.REST("GET", "gists/1234"),
					httpmock.JSONResponse(shared.Gist{ID: "1234", Files: map[string]*shared.GistFile{"cool.txt": {Filename: "cool.txt"}}}))
				reg.Register(httpmock.REST("DELETE", "gists/1234"),
					httpmock.StatusStringResponse(200, "{}"))
			},
			wantStdout: "✓ Gist \"cool.txt\" deleted\n",
		},
		{
			name: "successfully delete with prompt",
			opts: &DeleteOptions{
				Selector: "",
			},
+ 177 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gist edit
short: Edit one of your gists
pname: gh gist
plink: gh_gist.yaml
options:
    - option: add
      shorthand: a
      value_type: string
      description: Add a new file to the gist
    - option: desc
      shorthand: d
      value_type: string
DOCS
gh_gist_edit.md:1Markdown · 15 words
TESTS
pkg/cmd/gist/edit/edit_test.go:26pkg/cmd/gist/edit/edit_test::Test_getFilesToAdd · Go · 13 lines
func Test_getFilesToAdd(t *testing.T) {
	filename := "gist-test.txt"

	gf, err := getFilesToAdd(filename, []byte("hello"))
	require.NoError(t, err)

	assert.Equal(t, map[string]*gistFileToUpdate{
		filename: {
			NewFilename: filename,
			Content:     "hello",
		},
	}, gf)
}
pkg/cmd/gist/edit/edit_test.go:40pkg/cmd/gist/edit/edit_test::TestNewCmdEdit · Go · 99 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    EditOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "123",
			wants: EditOptions{
				Selector: "123",
			},
		},
		{
			name: "filename",
			cli:  "123 --filename cool.md",
			wants: EditOptions{
				Selector:     "123",
				EditFilename: "cool.md",
			},
		},
		{
			name: "add",
			cli:  "123 --add cool.md",
			wants: EditOptions{
				Selector:    "123",
				AddFilename: "cool.md",
			},
		},
+ 69 more lines · read full file
pkg/cmd/gist/edit/edit_test.go:140pkg/cmd/gist/edit/edit_test::Test_editRun · Go · 703 lines
func Test_editRun(t *testing.T) {
	fileToAdd := filepath.Join(t.TempDir(), "gist-test.txt")
	err := os.WriteFile(fileToAdd, []byte("hello"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name                      string
		opts                      *EditOptions
		mockGist                  *shared.Gist
		mockGistList              bool
		httpStubs                 func(*httpmock.Registry)
		prompterStubs             func(*prompter.MockPrompter)
		isTTY                     bool
		stdin                     string
		wantErr                   string
		wantLastRequestParameters map[string]interface{}
	}{
		{
			name:    "no such gist",
			wantErr: "gist not found: 1234",
			opts: &EditOptions{
				Selector: "1234",
			},
		},
		{
			name:  "one file",
			isTTY: false,
			opts: &EditOptions{
				Selector: "1234",
			},
+ 673 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist edit
short: Edit one of your gists
pname: gh gist
plink: gh_gist.yaml
options:
    - option: add
      shorthand: a
      value_type: string
      description: Add a new file to the gist
    - option: desc
      shorthand: d
      value_type: string
DOCS
gh_gist_edit.md:19Markdown · 7 words
TESTS
pkg/cmd/gist/edit/edit_test.go:40pkg/cmd/gist/edit/edit_test::TestNewCmdEdit · Go · 99 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    EditOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "123",
			wants: EditOptions{
				Selector: "123",
			},
		},
		{
			name: "filename",
			cli:  "123 --filename cool.md",
			wants: EditOptions{
				Selector:     "123",
				EditFilename: "cool.md",
			},
		},
		{
			name: "add",
			cli:  "123 --add cool.md",
			wants: EditOptions{
				Selector:    "123",
				AddFilename: "cool.md",
			},
		},
+ 69 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist edit
short: Edit one of your gists
pname: gh gist
plink: gh_gist.yaml
options:
    - option: add
      shorthand: a
      value_type: string
      description: Add a new file to the gist
    - option: desc
      shorthand: d
      value_type: string
DOCS
gh_gist_edit.md:20Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist edit
short: Edit one of your gists
pname: gh gist
plink: gh_gist.yaml
options:
    - option: add
      shorthand: a
      value_type: string
      description: Add a new file to the gist
    - option: desc
      shorthand: d
      value_type: string
DOCS
gh_gist_edit.md:21Markdown · 5 words
TESTS
pkg/cmd/gist/edit/edit_test.go:40pkg/cmd/gist/edit/edit_test::TestNewCmdEdit · Go · 99 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    EditOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "123",
			wants: EditOptions{
				Selector: "123",
			},
		},
		{
			name: "filename",
			cli:  "123 --filename cool.md",
			wants: EditOptions{
				Selector:     "123",
				EditFilename: "cool.md",
			},
		},
		{
			name: "add",
			cli:  "123 --add cool.md",
			wants: EditOptions{
				Selector:    "123",
				AddFilename: "cool.md",
			},
		},
+ 69 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist edit
short: Edit one of your gists
pname: gh gist
plink: gh_gist.yaml
options:
    - option: add
      shorthand: a
      value_type: string
      description: Add a new file to the gist
    - option: desc
      shorthand: d
      value_type: string
DOCS
gh_gist_edit.md:22Markdown · 6 words
TESTS
pkg/cmd/gist/edit/edit_test.go:40pkg/cmd/gist/edit/edit_test::TestNewCmdEdit · Go · 99 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    EditOptions
		wantsErr bool
	}{
		{
			name: "no flags",
			cli:  "123",
			wants: EditOptions{
				Selector: "123",
			},
		},
		{
			name: "filename",
			cli:  "123 --filename cool.md",
			wants: EditOptions{
				Selector:     "123",
				EditFilename: "cool.md",
			},
		},
		{
			name: "add",
			cli:  "123 --add cool.md",
			wants: EditOptions{
				Selector:    "123",
				AddFilename: "cool.md",
			},
		},
+ 69 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist list
short: List gists from your user account.
long: |-
    You can use a regular expression to filter the description, file names,
    or even the content of files in the gist using `--filter`.

    For supported regular expression syntax, see <https://pkg.go.dev/regexp/syntax>.

    Use `--include-content` to include content of files, noting that
    this will be slower and increase the rate limit used. Instead of printing a table,
    code will be printed with highlights similar to `gh search code`:
DOCS
gh_gist_list.md:1Markdown · 105 words
TESTS
pkg/cmd/gist/list/list_test.go:21pkg/cmd/gist/list/list_test::TestNewCmdList · Go · 110 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "no arguments",
			wants: ListOptions{
				Limit:      10,
				Visibility: "all",
			},
		},
		{
			name: "public",
			cli:  "--public",
			wants: ListOptions{
				Limit:      10,
				Visibility: "public",
			},
		},
		{
			name: "secret",
			cli:  "--secret",
			wants: ListOptions{
				Limit:      10,
				Visibility: "secret",
			},
		},
+ 80 more lines · read full file
pkg/cmd/gist/list/list_test.go:132pkg/cmd/gist/list/list_test::Test_listRun · Go · 519 lines
func Test_listRun(t *testing.T) {
	const query = `query GistList\b`
	sixHours, _ := time.ParseDuration("6h")
	sixHoursAgo := time.Now().Add(-sixHours)
	absTime, _ := time.Parse(time.RFC3339, "2020-07-30T15:24:28Z")

	tests := []struct {
		name    string
		opts    *ListOptions
		wantErr bool
		wantOut string
		stubs   func(*httpmock.Registry)
		color   bool
		nontty  bool
	}{
		{
			name: "no gists",
			opts: &ListOptions{},
			stubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(query),
					httpmock.StringResponse(`{ "data": { "viewer": {
						"gists": { "nodes": [] }
					} } }`))
			},
			wantErr: true,
		},
		{
			name: "default behavior",
			opts: &ListOptions{},
+ 489 more lines · read full file
pkg/cmd/gist/list/list_test.go:652pkg/cmd/gist/list/list_test::Test_highlightMatch · Go · 62 lines
func Test_highlightMatch(t *testing.T) {
	regex := regexp.MustCompilePOSIX(`[Oo]cto`)
	tests := []struct {
		name  string
		input string
		cs    *iostreams.ColorScheme
		want  string
	}{
		{
			name:  "single match",
			input: "Octo",
			cs:    &iostreams.ColorScheme{},
			want:  "Octo",
		},
		{
			name:  "single match (color)",
			input: "Octo",
			cs: &iostreams.ColorScheme{
				Enabled: true,
			},
			want: "\x1b[0;30;43mOcto\x1b[0m",
		},
		{
			name:  "single match with extra",
			input: "Hello, Octocat!",
			cs:    &iostreams.ColorScheme{},
			want:  "Hello, Octocat!",
		},
		{
			name:  "single match with extra (color)",
+ 32 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist list
short: List gists from your user account.
long: |-
    You can use a regular expression to filter the description, file names,
    or even the content of files in the gist using `--filter`.

    For supported regular expression syntax, see <https://pkg.go.dev/regexp/syntax>.

    Use `--include-content` to include content of files, noting that
    this will be slower and increase the rate limit used. Instead of printing a table,
    code will be printed with highlights similar to `gh search code`:
DOCS
gh_gist_list.md:35Markdown · 6 words
TESTS
pkg/cmd/gist/list/list_test.go:21pkg/cmd/gist/list/list_test::TestNewCmdList · Go · 110 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "no arguments",
			wants: ListOptions{
				Limit:      10,
				Visibility: "all",
			},
		},
		{
			name: "public",
			cli:  "--public",
			wants: ListOptions{
				Limit:      10,
				Visibility: "public",
			},
		},
		{
			name: "secret",
			cli:  "--secret",
			wants: ListOptions{
				Limit:      10,
				Visibility: "secret",
			},
		},
+ 80 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist list
short: List gists from your user account.
long: |-
    You can use a regular expression to filter the description, file names,
    or even the content of files in the gist using `--filter`.

    For supported regular expression syntax, see <https://pkg.go.dev/regexp/syntax>.

    Use `--include-content` to include content of files, noting that
    this will be slower and increase the rate limit used. Instead of printing a table,
    code will be printed with highlights similar to `gh search code`:
DOCS
gh_gist_list.md:36Markdown · 6 words
TESTS
pkg/cmd/gist/list/list_test.go:21pkg/cmd/gist/list/list_test::TestNewCmdList · Go · 110 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "no arguments",
			wants: ListOptions{
				Limit:      10,
				Visibility: "all",
			},
		},
		{
			name: "public",
			cli:  "--public",
			wants: ListOptions{
				Limit:      10,
				Visibility: "public",
			},
		},
		{
			name: "secret",
			cli:  "--secret",
			wants: ListOptions{
				Limit:      10,
				Visibility: "secret",
			},
		},
+ 80 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist list
short: List gists from your user account.
long: |-
    You can use a regular expression to filter the description, file names,
    or even the content of files in the gist using `--filter`.

    For supported regular expression syntax, see <https://pkg.go.dev/regexp/syntax>.

    Use `--include-content` to include content of files, noting that
    this will be slower and increase the rate limit used. Instead of printing a table,
    code will be printed with highlights similar to `gh search code`:
DOCS
gh_gist_list.md:37Markdown · 6 words
TESTS
pkg/cmd/gist/list/list_test.go:21pkg/cmd/gist/list/list_test::TestNewCmdList · Go · 110 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "no arguments",
			wants: ListOptions{
				Limit:      10,
				Visibility: "all",
			},
		},
		{
			name: "public",
			cli:  "--public",
			wants: ListOptions{
				Limit:      10,
				Visibility: "public",
			},
		},
		{
			name: "secret",
			cli:  "--secret",
			wants: ListOptions{
				Limit:      10,
				Visibility: "secret",
			},
		},
+ 80 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gist list
short: List gists from your user account.
long: |-
    You can use a regular expression to filter the description, file names,
    or even the content of files in the gist using `--filter`.

    For supported regular expression syntax, see <https://pkg.go.dev/regexp/syntax>.

    Use `--include-content` to include content of files, noting that
    this will be slower and increase the rate limit used. Instead of printing a table,
    code will be printed with highlights similar to `gh search code`:
DOCS
gh_gist_list.md:38Markdown · 4 words
TESTS
pkg/cmd/gist/list/list_test.go:21pkg/cmd/gist/list/list_test::TestNewCmdList · Go · 110 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "no arguments",
			wants: ListOptions{
				Limit:      10,
				Visibility: "all",
			},
		},
		{
			name: "public",
			cli:  "--public",
			wants: ListOptions{
				Limit:      10,
				Visibility: "public",
			},
		},
		{
			name: "secret",
			cli:  "--secret",
			wants: ListOptions{
				Limit:      10,
				Visibility: "secret",
			},
		},
+ 80 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gist list
short: List gists from your user account.
long: |-
    You can use a regular expression to filter the description, file names,
    or even the content of files in the gist using `--filter`.

    For supported regular expression syntax, see <https://pkg.go.dev/regexp/syntax>.

    Use `--include-content` to include content of files, noting that
    this will be slower and increase the rate limit used. Instead of printing a table,
    code will be printed with highlights similar to `gh search code`:
DOCS
gh_gist_list.md:39Markdown · 4 words
TESTS
pkg/cmd/gist/list/list_test.go:21pkg/cmd/gist/list/list_test::TestNewCmdList · Go · 110 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "no arguments",
			wants: ListOptions{
				Limit:      10,
				Visibility: "all",
			},
		},
		{
			name: "public",
			cli:  "--public",
			wants: ListOptions{
				Limit:      10,
				Visibility: "public",
			},
		},
		{
			name: "secret",
			cli:  "--secret",
			wants: ListOptions{
				Limit:      10,
				Visibility: "secret",
			},
		},
+ 80 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist rename
short: Rename a file in the given gist ID / URL.
pname: gh gist
plink: gh_gist.yaml
DOCS
gh_gist_rename.md:1Markdown · 18 words
TESTS
pkg/cmd/gist/rename/rename_test.go:18pkg/cmd/gist/rename/rename_test::TestNewCmdRename · Go · 71 lines
func TestNewCmdRename(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  RenameOptions
		errMsg  string
		tty     bool
		wantErr bool
	}{
		{
			name:    "no arguments",
			input:   "",
			errMsg:  "accepts 3 arg(s), received 0",
			wantErr: true,
		},
		{
			name:    "missing old filename and new filename",
			input:   "123",
			errMsg:  "accepts 3 arg(s), received 1",
			wantErr: true,
		},
		{
			name:    "missing new filename",
			input:   "123 old.txt",
			errMsg:  "accepts 3 arg(s), received 2",
			wantErr: true,
		},
		{
			name:  "rename",
			input: "123 old.txt new.txt",
+ 41 more lines · read full file
pkg/cmd/gist/rename/rename_test.go:90pkg/cmd/gist/rename/rename_test::TestRenameRun · Go · 97 lines
func TestRenameRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       *RenameOptions
		gist       *shared.Gist
		httpStubs  func(*httpmock.Registry)
		nontty     bool
		stdin      string
		wantOut    string
		wantParams map[string]interface{}
	}{
		{
			name:    "no such gist",
			wantOut: "gist not found: 1234",
		},
		{
			name: "rename from old.txt to new.txt",
			opts: &RenameOptions{
				Selector:    "1234",
				OldFileName: "old.txt",
				NewFileName: "new.txt",
			},
			gist: &shared.Gist{
				ID: "1234",
				Files: map[string]*shared.GistFile{
					"old.txt": {
						Filename: "old.txt",
						Type:     "text/plain",
					},
				},
+ 67 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist view
short: View the given gist or select from recent gists.
pname: gh gist
plink: gh_gist.yaml
options:
    - option: filename
      shorthand: f
      value_type: string
      description: Display a single file from the gist
    - option: files
      value_type: bool
      default_value: "false"
DOCS
gh_gist_view.md:1Markdown · 18 words
TESTS
pkg/cmd/gist/view/view_test.go:22pkg/cmd/gist/view/view_test::TestNewCmdView · Go · 91 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants ViewOptions
		tty   bool
	}{
		{
			name: "tty no arguments",
			tty:  true,
			cli:  "123",
			wants: ViewOptions{
				Raw:       false,
				Selector:  "123",
				ListFiles: false,
			},
		},
		{
			name: "nontty no arguments",
			cli:  "123",
			wants: ViewOptions{
				Raw:       true,
				Selector:  "123",
				ListFiles: false,
			},
		},
		{
			name: "filename passed",
			cli:  "-fcool.txt 123",
			tty:  true,
+ 61 more lines · read full file
pkg/cmd/gist/view/view_test.go:114pkg/cmd/gist/view/view_test::Test_viewRun · Go · 406 lines
func Test_viewRun(t *testing.T) {
	tests := []struct {
		name         string
		opts         *ViewOptions
		wantOut      string
		mockGist     *shared.Gist
		mockGistList bool
		isTTY        bool
		wantErr      string
	}{
		{
			name:  "no such gist",
			isTTY: false,
			opts: &ViewOptions{
				Selector:  "1234",
				ListFiles: false,
			},
			wantErr: "not found",
		},
		{
			name:  "one file",
			isTTY: true,
			opts: &ViewOptions{
				Selector:  "1234",
				ListFiles: false,
			},
			mockGist: &shared.Gist{
				Files: map[string]*shared.GistFile{
					"cicada.txt": {
						Content: "bwhiizzzbwhuiiizzzz",
+ 376 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gist view
short: View the given gist or select from recent gists.
pname: gh gist
plink: gh_gist.yaml
options:
    - option: filename
      shorthand: f
      value_type: string
      description: Display a single file from the gist
    - option: files
      value_type: bool
      default_value: "false"
DOCS
gh_gist_view.md:19Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gist view
short: View the given gist or select from recent gists.
pname: gh gist
plink: gh_gist.yaml
options:
    - option: filename
      shorthand: f
      value_type: string
      description: Display a single file from the gist
    - option: files
      value_type: bool
      default_value: "false"
DOCS
gh_gist_view.md:20Markdown · 6 words
TESTS
pkg/cmd/gist/view/view_test.go:22pkg/cmd/gist/view/view_test::TestNewCmdView · Go · 91 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants ViewOptions
		tty   bool
	}{
		{
			name: "tty no arguments",
			tty:  true,
			cli:  "123",
			wants: ViewOptions{
				Raw:       false,
				Selector:  "123",
				ListFiles: false,
			},
		},
		{
			name: "nontty no arguments",
			cli:  "123",
			wants: ViewOptions{
				Raw:       true,
				Selector:  "123",
				ListFiles: false,
			},
		},
		{
			name: "filename passed",
			cli:  "-fcool.txt 123",
			tty:  true,
+ 61 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gist view
short: View the given gist or select from recent gists.
pname: gh gist
plink: gh_gist.yaml
options:
    - option: filename
      shorthand: f
      value_type: string
      description: Display a single file from the gist
    - option: files
      value_type: bool
      default_value: "false"
DOCS
gh_gist_view.md:21Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gist view
short: View the given gist or select from recent gists.
pname: gh gist
plink: gh_gist.yaml
options:
    - option: filename
      shorthand: f
      value_type: string
      description: Display a single file from the gist
    - option: files
      value_type: bool
      default_value: "false"
DOCS
gh_gist_view.md:22Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gpg-key
short: Manage GPG keys registered with your GitHub account.
pname: gh
plink: gh.yaml
DOCS
gh_gpg-key.md:1Markdown · 28 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gpg-key add
short: Add a GPG key to your GitHub account
pname: gh gpg-key
plink: gh_gpg-key.yaml
options:
    - option: title
      shorthand: t
      value_type: string
      description: Title for the new key
DOCS
gh_gpg-key_add.md:1Markdown · 17 words
TESTS
pkg/cmd/gpg-key/add/add_test.go:15pkg/cmd/gpg-key/add/add_test::Test_runAdd · Go · 131 lines
func Test_runAdd(t *testing.T) {
	tests := []struct {
		name       string
		stdin      string
		httpStubs  func(*httpmock.Registry)
		wantStdout string
		wantStderr string
		wantErrMsg string
		opts       AddOptions
	}{
		{
			name:  "valid key",
			stdin: "-----BEGIN PGP PUBLIC KEY BLOCK-----",
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("POST", "user/gpg_keys"),
					httpmock.RESTPayload(200, ``, func(payload map[string]interface{}) {
						assert.Contains(t, payload, "armored_public_key")
						assert.NotContains(t, payload, "title")
					}))
			},
			wantStdout: "✓ GPG key added to your account\n",
			wantStderr: "",
			wantErrMsg: "",
			opts:       AddOptions{KeyFile: "-"},
		},
		{
			name:  "valid key with title",
			stdin: "-----BEGIN PGP PUBLIC KEY BLOCK-----",
			httpStubs: func(reg *httpmock.Registry) {
+ 101 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gpg-key add
short: Add a GPG key to your GitHub account
pname: gh gpg-key
plink: gh_gpg-key.yaml
options:
    - option: title
      shorthand: t
      value_type: string
      description: Title for the new key
DOCS
gh_gpg-key_add.md:19Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gpg-key delete
short: Delete a GPG key from your GitHub account
pname: gh gpg-key
plink: gh_gpg-key.yaml
options:
    - option: "yes"
      shorthand: "y"
      value_type: bool
      default_value: "false"
      description: Skip the confirmation prompt
DOCS
gh_gpg-key_delete.md:1Markdown · 17 words
TESTS
pkg/cmd/gpg-key/delete/delete_test.go:19pkg/cmd/gpg-key/delete/delete_test::TestNewCmdDelete · Go · 90 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		input      string
		output     DeleteOptions
		wantErr    bool
		wantErrMsg string
	}{
		{
			name:   "tty",
			tty:    true,
			input:  "ABC123",
			output: DeleteOptions{KeyID: "ABC123", Confirmed: false},
		},
		{
			name:   "confirm flag tty",
			tty:    true,
			input:  "ABC123 --yes",
			output: DeleteOptions{KeyID: "ABC123", Confirmed: true},
		},
		{
			name:   "shorthand confirm flag tty",
			tty:    true,
			input:  "ABC123 -y",
			output: DeleteOptions{KeyID: "ABC123", Confirmed: true},
		},
		{
			name:       "no tty",
			input:      "ABC123",
+ 60 more lines · read full file
pkg/cmd/gpg-key/delete/delete_test.go:110pkg/cmd/gpg-key/delete/delete_test::Test_deleteRun · Go · 116 lines
func Test_deleteRun(t *testing.T) {
	keysResp := "[{\"id\":123,\"key_id\":\"ABC123\"}]"
	tests := []struct {
		name          string
		tty           bool
		opts          DeleteOptions
		httpStubs     func(*httpmock.Registry)
		prompterStubs func(*prompter.PrompterMock)
		wantStdout    string
		wantErr       bool
		wantErrMsg    string
	}{
		{
			name: "delete tty",
			tty:  true,
			opts: DeleteOptions{KeyID: "ABC123", Confirmed: false},
			prompterStubs: func(pm *prompter.PrompterMock) {
				pm.ConfirmDeletionFunc = func(_ string) error {
					return nil
				}
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.REST("GET", "user/gpg_keys"), httpmock.StatusStringResponse(200, keysResp))
				reg.Register(httpmock.REST("DELETE", "user/gpg_keys/123"), httpmock.StatusStringResponse(204, ""))
			},
			wantStdout: "✓ GPG key ABC123 deleted from your account\n",
		},
		{
			name: "delete with confirm flag tty",
			tty:  true,
+ 86 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh gpg-key delete
short: Delete a GPG key from your GitHub account
pname: gh gpg-key
plink: gh_gpg-key.yaml
options:
    - option: "yes"
      shorthand: "y"
      value_type: bool
      default_value: "false"
      description: Skip the confirmation prompt
DOCS
gh_gpg-key_delete.md:19Markdown · 4 words
TESTS
pkg/cmd/gpg-key/delete/delete_test.go:19pkg/cmd/gpg-key/delete/delete_test::TestNewCmdDelete · Go · 90 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		input      string
		output     DeleteOptions
		wantErr    bool
		wantErrMsg string
	}{
		{
			name:   "tty",
			tty:    true,
			input:  "ABC123",
			output: DeleteOptions{KeyID: "ABC123", Confirmed: false},
		},
		{
			name:   "confirm flag tty",
			tty:    true,
			input:  "ABC123 --yes",
			output: DeleteOptions{KeyID: "ABC123", Confirmed: true},
		},
		{
			name:   "shorthand confirm flag tty",
			tty:    true,
			input:  "ABC123 -y",
			output: DeleteOptions{KeyID: "ABC123", Confirmed: true},
		},
		{
			name:       "no tty",
			input:      "ABC123",
+ 60 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh gpg-key list
short: Lists GPG keys in your GitHub account
pname: gh gpg-key
plink: gh_gpg-key.yaml
DOCS
gh_gpg-key_list.md:1Markdown · 19 words
TESTS
pkg/cmd/gpg-key/list/list_test.go:17pkg/cmd/gpg-key/list/list_test::Test_listRun · Go · 129 lines
func Test_listRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       ListOptions
		isTTY      bool
		wantStdout string
		wantStderr string
		wantErr    bool
	}{
		{
			name: "list tty",
			opts: ListOptions{HTTPClient: func() (*http.Client, error) {
				createdAt := time.Now().Add(time.Duration(-24) * time.Hour)
				expiresAt, _ := time.Parse(time.RFC3339, "2099-01-01T15:44:24+01:00")
				noExpires := time.Time{}
				reg := &httpmock.Registry{}
				reg.Register(
					httpmock.REST("GET", "user/gpg_keys"),
					httpmock.StringResponse(fmt.Sprintf(`[
						{
							"id": 1234,
							"key_id": "ABCDEF1234567890",
							"public_key": "xJMEWfoofoofoo",
							"emails": [{"email": "johnny@test.com"}],
							"created_at": "%[1]s",
							"expires_at": "%[2]s"
						},
						{
							"id": 5678,
							"key_id": "1234567890ABCDEF",
+ 99 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue
short: Work with GitHub issues.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
TESTS

N/A

EXAMPLES
CONTRACT
command: gh issue
short: Work with GitHub issues.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_issue.md:38Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue close
short: Close issue
pname: gh issue
plink: gh_issue.yaml
options:
    - option: comment
      shorthand: c
      value_type: string
      description: Leave a closing comment
    - option: duplicate-of
      value_type: string
      description: Mark as duplicate of another issue by number or URL
TESTS
pkg/cmd/issue/close/close_test.go:18pkg/cmd/issue/close/close_test::TestNewCmdClose · Go · 94 lines
func TestNewCmdClose(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdClose)

	tests := []struct {
		name             string
		input            string
		output           CloseOptions
		expectedBaseRepo ghrepo.Interface
		wantErr          bool
		errMsg           string
	}{
		{
			name:  "comment",
			input: "123 --comment 'closing comment'",
			output: CloseOptions{
				IssueNumber: 123,
				Comment:     "closing comment",
			},
		},
		{
			name:  "reason",
			input: "123 --reason 'not planned'",
			output: CloseOptions{
				IssueNumber: 123,
				Reason:      "not planned",
			},
		},
		{
			name:  "reason duplicate",
+ 64 more lines · read full file
pkg/cmd/issue/close/close_test.go:113pkg/cmd/issue/close/close_test::TestCloseRun · Go · 287 lines
func TestCloseRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       *CloseOptions
		httpStubs  func(*httpmock.Registry)
		wantStderr string
		wantErr    bool
		errMsg     string
	}{
		{
			name: "close issue by number",
			opts: &CloseOptions{
				IssueNumber: 13,
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query IssueByNumber\b`),
					httpmock.StringResponse(`
            { "data": { "repository": {
              "hasIssuesEnabled": true,
              "issue": { "id": "THE-ID", "number": 13, "title": "The title of the issue"}
            } } }`),
				)
				reg.Register(
					httpmock.GraphQL(`mutation IssueClose\b`),
					httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
						func(inputs map[string]interface{}) {
							assert.Equal(t, "THE-ID", inputs["issueId"])
						}),
				)
+ 257 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue close
short: Close issue
pname: gh issue
plink: gh_issue.yaml
options:
    - option: comment
      shorthand: c
      value_type: string
      description: Leave a closing comment
    - option: duplicate-of
      value_type: string
      description: Mark as duplicate of another issue by number or URL
DOCS
gh_issue_close.md:19Markdown · 4 words
TESTS
pkg/cmd/issue/close/close_test.go:18pkg/cmd/issue/close/close_test::TestNewCmdClose · Go · 94 lines
func TestNewCmdClose(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdClose)

	tests := []struct {
		name             string
		input            string
		output           CloseOptions
		expectedBaseRepo ghrepo.Interface
		wantErr          bool
		errMsg           string
	}{
		{
			name:  "comment",
			input: "123 --comment 'closing comment'",
			output: CloseOptions{
				IssueNumber: 123,
				Comment:     "closing comment",
			},
		},
		{
			name:  "reason",
			input: "123 --reason 'not planned'",
			output: CloseOptions{
				IssueNumber: 123,
				Reason:      "not planned",
			},
		},
		{
			name:  "reason duplicate",
+ 64 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue close
short: Close issue
pname: gh issue
plink: gh_issue.yaml
options:
    - option: comment
      shorthand: c
      value_type: string
      description: Leave a closing comment
    - option: duplicate-of
      value_type: string
      description: Mark as duplicate of another issue by number or URL
DOCS
gh_issue_close.md:20Markdown · 10 words
TESTS
pkg/cmd/issue/close/close_test.go:18pkg/cmd/issue/close/close_test::TestNewCmdClose · Go · 94 lines
func TestNewCmdClose(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdClose)

	tests := []struct {
		name             string
		input            string
		output           CloseOptions
		expectedBaseRepo ghrepo.Interface
		wantErr          bool
		errMsg           string
	}{
		{
			name:  "comment",
			input: "123 --comment 'closing comment'",
			output: CloseOptions{
				IssueNumber: 123,
				Comment:     "closing comment",
			},
		},
		{
			name:  "reason",
			input: "123 --reason 'not planned'",
			output: CloseOptions{
				IssueNumber: 123,
				Reason:      "not planned",
			},
		},
		{
			name:  "reason duplicate",
+ 64 more lines · read full file
pkg/cmd/issue/close/close_test.go:113pkg/cmd/issue/close/close_test::TestCloseRun · Go · 287 lines
func TestCloseRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       *CloseOptions
		httpStubs  func(*httpmock.Registry)
		wantStderr string
		wantErr    bool
		errMsg     string
	}{
		{
			name: "close issue by number",
			opts: &CloseOptions{
				IssueNumber: 13,
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query IssueByNumber\b`),
					httpmock.StringResponse(`
            { "data": { "repository": {
              "hasIssuesEnabled": true,
              "issue": { "id": "THE-ID", "number": 13, "title": "The title of the issue"}
            } } }`),
				)
				reg.Register(
					httpmock.GraphQL(`mutation IssueClose\b`),
					httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
						func(inputs map[string]interface{}) {
							assert.Equal(t, "THE-ID", inputs["issueId"])
						}),
				)
+ 257 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue close
short: Close issue
pname: gh issue
plink: gh_issue.yaml
options:
    - option: comment
      shorthand: c
      value_type: string
      description: Leave a closing comment
    - option: duplicate-of
      value_type: string
      description: Mark as duplicate of another issue by number or URL
DOCS
gh_issue_close.md:21Markdown · 5 words
TESTS
pkg/cmd/issue/close/close_test.go:18pkg/cmd/issue/close/close_test::TestNewCmdClose · Go · 94 lines
func TestNewCmdClose(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdClose)

	tests := []struct {
		name             string
		input            string
		output           CloseOptions
		expectedBaseRepo ghrepo.Interface
		wantErr          bool
		errMsg           string
	}{
		{
			name:  "comment",
			input: "123 --comment 'closing comment'",
			output: CloseOptions{
				IssueNumber: 123,
				Comment:     "closing comment",
			},
		},
		{
			name:  "reason",
			input: "123 --reason 'not planned'",
			output: CloseOptions{
				IssueNumber: 123,
				Reason:      "not planned",
			},
		},
		{
			name:  "reason duplicate",
+ 64 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue comment
short: Add a comment to a GitHub issue.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
TESTS
pkg/cmd/issue/comment/comment_test.go:24pkg/cmd/issue/comment/comment_test::TestNewCmdComment · Go · 275 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
		},
		{
			name:  "issue number",
			input: "1",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
+ 245 more lines · read full file
pkg/cmd/issue/comment/comment_test.go:300pkg/cmd/issue/comment/comment_test::Test_commentRun · Go · 383 lines
func Test_commentRun(t *testing.T) {
	tests := []struct {
		name          string
		input         *shared.CommentableOptions
		emptyComments bool
		comments      api.Comments
		httpStubs     func(*testing.T, *httpmock.Registry)
		stdout        string
		stderr        string
		wantsErr      bool
	}{
		{
			name: "creating new comment with interactive editor succeeds",
			input: &shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",

				InteractiveEditSurvey: func(string) (string, error) { return "comment body", nil },
				ConfirmSubmitSurvey:   func() (bool, error) { return true, nil },
			},
			emptyComments: true,
			httpStubs: func(t *testing.T, reg *httpmock.Registry) {
				mockCommentCreate(t, reg)
			},
			stdout: "https://github.com/OWNER/REPO/issues/123#issuecomment-456\n",
		},
		{
			name: "updating last comment with interactive editor fails if there are no comments and decline prompt to create",
			input: &shared.CommentableOptions{
+ 353 more lines · read full file
CONTRACT
command: gh issue comment
short: Add a comment to a GitHub issue.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
TESTS
pkg/cmd/issue/comment/comment_test.go:24pkg/cmd/issue/comment/comment_test::TestNewCmdComment · Go · 275 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
		},
		{
			name:  "issue number",
			input: "1",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
+ 245 more lines · read full file
EXAMPLES
CONTRACT
command: gh issue comment
short: Add a comment to a GitHub issue.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_issue_comment.md:24Markdown · 12 words
TESTS
pkg/cmd/issue/comment/comment_test.go:24pkg/cmd/issue/comment/comment_test::TestNewCmdComment · Go · 275 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
		},
		{
			name:  "issue number",
			input: "1",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
+ 245 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue comment
short: Add a comment to a GitHub issue.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_issue_comment.md:25Markdown · 15 words
TESTS
pkg/cmd/issue/comment/comment_test.go:24pkg/cmd/issue/comment/comment_test::TestNewCmdComment · Go · 275 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
		},
		{
			name:  "issue number",
			input: "1",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
+ 245 more lines · read full file
pkg/cmd/issue/comment/comment_test.go:300pkg/cmd/issue/comment/comment_test::Test_commentRun · Go · 383 lines
func Test_commentRun(t *testing.T) {
	tests := []struct {
		name          string
		input         *shared.CommentableOptions
		emptyComments bool
		comments      api.Comments
		httpStubs     func(*testing.T, *httpmock.Registry)
		stdout        string
		stderr        string
		wantsErr      bool
	}{
		{
			name: "creating new comment with interactive editor succeeds",
			input: &shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",

				InteractiveEditSurvey: func(string) (string, error) { return "comment body", nil },
				ConfirmSubmitSurvey:   func() (bool, error) { return true, nil },
			},
			emptyComments: true,
			httpStubs: func(t *testing.T, reg *httpmock.Registry) {
				mockCommentCreate(t, reg)
			},
			stdout: "https://github.com/OWNER/REPO/issues/123#issuecomment-456\n",
		},
		{
			name: "updating last comment with interactive editor fails if there are no comments and decline prompt to create",
			input: &shared.CommentableOptions{
+ 353 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue comment
short: Add a comment to a GitHub issue.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_issue_comment.md:26Markdown · 8 words
TESTS
pkg/cmd/issue/comment/comment_test.go:24pkg/cmd/issue/comment/comment_test::TestNewCmdComment · Go · 275 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
		},
		{
			name:  "issue number",
			input: "1",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
+ 245 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue comment
short: Add a comment to a GitHub issue.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_issue_comment.md:27Markdown · 8 words
TESTS
pkg/cmd/issue/comment/comment_test.go:24pkg/cmd/issue/comment/comment_test::TestNewCmdComment · Go · 275 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
		},
		{
			name:  "issue number",
			input: "1",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
+ 245 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue comment
short: Add a comment to a GitHub issue.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_issue_comment.md:28Markdown · 12 words
TESTS
pkg/cmd/issue/comment/comment_test.go:24pkg/cmd/issue/comment/comment_test::TestNewCmdComment · Go · 275 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
		},
		{
			name:  "issue number",
			input: "1",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
+ 245 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue comment
short: Add a comment to a GitHub issue.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_issue_comment.md:29Markdown · 8 words
TESTS
pkg/cmd/issue/comment/comment_test.go:24pkg/cmd/issue/comment/comment_test::TestNewCmdComment · Go · 275 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
		},
		{
			name:  "issue number",
			input: "1",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
+ 245 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue comment
short: Add a comment to a GitHub issue.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_issue_comment.md:30Markdown · 9 words
TESTS
pkg/cmd/issue/comment/comment_test.go:24pkg/cmd/issue/comment/comment_test::TestNewCmdComment · Go · 275 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:     "no arguments",
			input:    "",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
		},
		{
			name:  "issue number",
			input: "1",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
+ 245 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue create
short: Create an issue on GitHub.
long: |-
    Adding an issue to projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--assignee` flag supports the following special values:
    - `@me`: assign yourself
    - `@copilot`: assign Copilot (not supported on GitHub Enterprise Server)
TESTS
pkg/cmd/issue/create/create_test.go:32pkg/cmd/issue/create/create_test::TestNewCmdCreate · Go · 221 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "-t mytitle",
			wantsErr: true,
		},
		{
			name:     "empty tty",
			tty:      true,
			cli:      "",
+ 191 more lines · read full file
pkg/cmd/issue/create/create_test.go:254pkg/cmd/issue/create/create_test::Test_createRun · Go · 418 lines
func Test_createRun(t *testing.T) {
	tests := []struct {
		name        string
		opts        CreateOptions
		httpStubs   func(*httpmock.Registry)
		promptStubs func(*prompter.PrompterMock)
		wantsStdout string
		wantsStderr string
		wantsBrowse string
		wantsErr    string
	}{
		{
			name: "no args",
			opts: CreateOptions{
				Detector: &fd.EnabledDetectorMock{},
				WebMode:  true,
			},
			wantsBrowse: "https://github.com/OWNER/REPO/issues/new",
			wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n",
		},
		{
			name: "title and body",
			opts: CreateOptions{
				Detector: &fd.EnabledDetectorMock{},
				WebMode:  true,
				Title:    "myissue",
				Body:     "hello cli",
			},
			wantsBrowse: "https://github.com/OWNER/REPO/issues/new?body=hello+cli&title=myissue",
			wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n",
+ 388 more lines · read full file
pkg/cmd/issue/create/create_test.go:725pkg/cmd/issue/create/create_test::TestIssueCreate · Go · 32 lines
func TestIssueCreate(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query IssueRepositoryInfo\b`),
		httpmock.StringResponse(`
			{ "data": { "repository": {
				"id": "REPOID",
				"hasIssuesEnabled": true
			} } }`),
	)
	http.Register(
		httpmock.GraphQL(`mutation IssueCreate\b`),
		httpmock.GraphQLMutation(`
				{ "data": { "createIssue": { "issue": {
					"URL": "https://github.com/OWNER/REPO/issues/12"
				} } } }`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["repositoryId"], "REPOID")
				assert.Equal(t, inputs["title"], "hello")
				assert.Equal(t, inputs["body"], "cash rules everything around me")
			}),
	)

	output, err := runCommand(http, true, `-t hello -b "cash rules everything around me"`, nil)
	if err != nil {
		t.Errorf("error running command `issue create`: %v", err)
	}
+ 3 more lines · read full file
+ 13 more tests · open all in source
EXAMPLES
CONTRACT
command: gh issue create
short: Create an issue on GitHub.
long: |-
    Adding an issue to projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--assignee` flag supports the following special values:
    - `@me`: assign yourself
    - `@copilot`: assign Copilot (not supported on GitHub Enterprise Server)
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue create
short: Create an issue on GitHub.
long: |-
    Adding an issue to projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--assignee` flag supports the following special values:
    - `@me`: assign yourself
    - `@copilot`: assign Copilot (not supported on GitHub Enterprise Server)
TESTS

N/A

EXAMPLES
CONTRACT
command: gh issue create
short: Create an issue on GitHub.
long: |-
    Adding an issue to projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--assignee` flag supports the following special values:
    - `@me`: assign yourself
    - `@copilot`: assign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_create.md:29Markdown · 12 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue create
short: Create an issue on GitHub.
long: |-
    Adding an issue to projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--assignee` flag supports the following special values:
    - `@me`: assign yourself
    - `@copilot`: assign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_create.md:30Markdown · 27 words
TESTS
pkg/cmd/issue/create/create_test.go:32pkg/cmd/issue/create/create_test::TestNewCmdCreate · Go · 221 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "-t mytitle",
			wantsErr: true,
		},
		{
			name:     "empty tty",
			tty:      true,
			cli:      "",
+ 191 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue create
short: Create an issue on GitHub.
long: |-
    Adding an issue to projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--assignee` flag supports the following special values:
    - `@me`: assign yourself
    - `@copilot`: assign Copilot (not supported on GitHub Enterprise Server)
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue create
short: Create an issue on GitHub.
long: |-
    Adding an issue to projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--assignee` flag supports the following special values:
    - `@me`: assign yourself
    - `@copilot`: assign Copilot (not supported on GitHub Enterprise Server)
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue create
short: Create an issue on GitHub.
long: |-
    Adding an issue to projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--assignee` flag supports the following special values:
    - `@me`: assign yourself
    - `@copilot`: assign Copilot (not supported on GitHub Enterprise Server)
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue create
short: Create an issue on GitHub.
long: |-
    Adding an issue to projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--assignee` flag supports the following special values:
    - `@me`: assign yourself
    - `@copilot`: assign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_create.md:34Markdown · 8 words
TESTS
pkg/cmd/issue/create/create_test.go:758pkg/cmd/issue/create/create_test::TestIssueCreate_recover · Go · 83 lines
func TestIssueCreate_recover(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query IssueRepositoryInfo\b`),
		httpmock.StringResponse(`
			{ "data": { "repository": {
				"id": "REPOID",
				"hasIssuesEnabled": true
			} } }`))
	// Should only be one fetch of metadata.
	http.Register(
		httpmock.GraphQL(`query RepositoryLabelList\b`),
		httpmock.StringResponse(`
			{ "data": { "repository": { "labels": {
				"nodes": [
					{ "name": "TODO", "id": "TODOID" },
					{ "name": "bug", "id": "BUGID" }
				],
				"pageInfo": { "hasNextPage": false }
			} } } }
		`))
	http.Register(
		httpmock.GraphQL(`mutation IssueCreate\b`),
		httpmock.GraphQLMutation(`
		{ "data": { "createIssue": { "issue": {
			"URL": "https://github.com/OWNER/REPO/issues/12"
		} } } }
	`, func(inputs map[string]interface{}) {
+ 53 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue create
short: Create an issue on GitHub.
long: |-
    Adding an issue to projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--assignee` flag supports the following special values:
    - `@me`: assign yourself
    - `@copilot`: assign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_create.md:35Markdown · 8 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue create
short: Create an issue on GitHub.
long: |-
    Adding an issue to projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--assignee` flag supports the following special values:
    - `@me`: assign yourself
    - `@copilot`: assign Copilot (not supported on GitHub Enterprise Server)
TESTS

N/A

EXAMPLES
CONTRACT
command: gh issue create
short: Create an issue on GitHub.
long: |-
    Adding an issue to projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--assignee` flag supports the following special values:
    - `@me`: assign yourself
    - `@copilot`: assign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_create.md:37Markdown · 7 words
TESTS
pkg/cmd/issue/create/create_test.go:32pkg/cmd/issue/create/create_test::TestNewCmdCreate · Go · 221 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "-t mytitle",
			wantsErr: true,
		},
		{
			name:     "empty tty",
			tty:      true,
			cli:      "",
+ 191 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue delete
short: Delete issue
pname: gh issue
plink: gh_issue.yaml
options:
    - option: "yes"
      value_type: bool
      default_value: "false"
      description: Confirm deletion without prompting
DOCS
gh_issue_delete.md:1Markdown · 16 words
TESTS
pkg/cmd/issue/delete/delete_test.go:24pkg/cmd/issue/delete/delete_test::TestNewCmdDelete · Go · 3 lines
func TestNewCmdDelete(t *testing.T) {
	argparsetest.TestArgParsing(t, NewCmdDelete)
}
pkg/cmd/issue/delete/delete_test.go:67pkg/cmd/issue/delete/delete_test::TestIssueDelete · Go · 34 lines
func TestIssueDelete(t *testing.T) {
	httpRegistry := &httpmock.Registry{}
	defer httpRegistry.Verify(t)

	httpRegistry.Register(
		httpmock.GraphQL(`query IssueByNumber\b`),
		httpmock.StringResponse(`
			{ "data": { "repository": {
				"hasIssuesEnabled": true,
				"issue": { "id": "THE-ID", "number": 13, "title": "The title of the issue"}
			} } }`),
	)
	httpRegistry.Register(
		httpmock.GraphQL(`mutation IssueDelete\b`),
		httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["issueId"], "THE-ID")
			}),
	)

	pm := prompter.NewMockPrompter(t)
	pm.RegisterConfirmDeletion("13", func(_ string) error { return nil })

	output, err := runCommand(httpRegistry, pm, true, "13")
	if err != nil {
		t.Fatalf("error running command `issue delete`: %v", err)
	}

	r := regexp.MustCompile(`Deleted issue OWNER/REPO#13 \(The title of the issue\)`)
+ 5 more lines · read full file
pkg/cmd/issue/delete/delete_test.go:102pkg/cmd/issue/delete/delete_test::TestIssueDelete_confirm · Go · 31 lines
func TestIssueDelete_confirm(t *testing.T) {
	httpRegistry := &httpmock.Registry{}
	defer httpRegistry.Verify(t)

	httpRegistry.Register(
		httpmock.GraphQL(`query IssueByNumber\b`),
		httpmock.StringResponse(`
			{ "data": { "repository": {
				"hasIssuesEnabled": true,
				"issue": { "id": "THE-ID", "number": 13, "title": "The title of the issue"}
			} } }`),
	)
	httpRegistry.Register(
		httpmock.GraphQL(`mutation IssueDelete\b`),
		httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["issueId"], "THE-ID")
			}),
	)

	output, err := runCommand(httpRegistry, nil, true, "13 --confirm")
	if err != nil {
		t.Fatalf("error running command `issue delete`: %v", err)
	}

	r := regexp.MustCompile(`Deleted issue OWNER/REPO#13 \(The title of the issue\)`)

	if !r.MatchString(output.Stderr()) {
		t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr())
	}
+ 1 more lines · read full file
+ 3 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue delete
short: Delete issue
pname: gh issue
plink: gh_issue.yaml
options:
    - option: "yes"
      value_type: bool
      default_value: "false"
      description: Confirm deletion without prompting
DOCS
gh_issue_delete.md:19Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue develop
short: Manage linked branches for an issue.
long: |-
    When using the `--base` flag, the new development branch will be created from the specified
    remote branch. The new branch will be configured as the base branch for pull requests created using
    `gh pr create`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: base
      shorthand: b
      value_type: string
DOCS
gh_issue_develop.md:1Markdown · 56 words
TESTS
pkg/cmd/issue/develop/develop_test.go:23pkg/cmd/issue/develop/develop_test::TestNewCmdDevelop · Go · 132 lines
func TestNewCmdDevelop(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdDevelop)

	tests := []struct {
		name             string
		input            string
		output           DevelopOptions
		expectedBaseRepo ghrepo.Interface
		wantStdout       string
		wantStderr       string
		wantErr          bool
		errMsg           string
	}{
		{
			name:  "branch-repo flag",
			input: "1 --branch-repo owner/repo",
			output: DevelopOptions{
				IssueNumber: 1,
				BranchRepo:  "owner/repo",
			},
		},
		{
			name:  "base flag",
			input: "1 --base feature",
			output: DevelopOptions{
				IssueNumber: 1,
				BaseBranch:  "feature",
			},
		},
+ 102 more lines · read full file
pkg/cmd/issue/develop/develop_test.go:156pkg/cmd/issue/develop/develop_test::TestDevelopRun · Go · 614 lines
func TestDevelopRun(t *testing.T) {
	featureEnabledPayload := `{"data":{"LinkedBranch":{"fields":[{"name":"id"},{"name":"ref"}]}}}`
	featureDisabledPayload := `{"data":{"LinkedBranch":null}}`

	tests := []struct {
		name           string
		opts           *DevelopOptions
		cmdStubs       func(*run.CommandStubber)
		runStubs       func(*run.CommandStubber)
		remotes        map[string]string
		httpStubs      func(*httpmock.Registry, *testing.T)
		expectedOut    string
		expectedErrOut string
		wantErr        string
		tty            bool
	}{
		{
			name: "returns an error when the feature is not supported by the API",
			opts: &DevelopOptions{
				IssueNumber: 42,
				List:        true,
			},
			httpStubs: func(reg *httpmock.Registry, t *testing.T) {
				reg.Register(
					httpmock.GraphQL(`query IssueByNumber\b`),
					httpmock.StringResponse(`{"data":{"repository":{"hasIssuesEnabled":true,"issue":{"id":"SOMEID","number":42}}}}`),
				)
				reg.Register(
					httpmock.GraphQL(`query LinkedBranchFeature\b`),
					httpmock.StringResponse(featureDisabledPayload),
+ 584 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh issue develop
short: Manage linked branches for an issue.
long: |-
    When using the `--base` flag, the new development branch will be created from the specified
    remote branch. The new branch will be configured as the base branch for pull requests created using
    `gh pr create`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: base
      shorthand: b
      value_type: string
DOCS
gh_issue_develop.md:24Markdown · 13 words
TESTS
pkg/cmd/issue/develop/develop_test.go:23pkg/cmd/issue/develop/develop_test::TestNewCmdDevelop · Go · 132 lines
func TestNewCmdDevelop(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdDevelop)

	tests := []struct {
		name             string
		input            string
		output           DevelopOptions
		expectedBaseRepo ghrepo.Interface
		wantStdout       string
		wantStderr       string
		wantErr          bool
		errMsg           string
	}{
		{
			name:  "branch-repo flag",
			input: "1 --branch-repo owner/repo",
			output: DevelopOptions{
				IssueNumber: 1,
				BranchRepo:  "owner/repo",
			},
		},
		{
			name:  "base flag",
			input: "1 --base feature",
			output: DevelopOptions{
				IssueNumber: 1,
				BaseBranch:  "feature",
			},
		},
+ 102 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue develop
short: Manage linked branches for an issue.
long: |-
    When using the `--base` flag, the new development branch will be created from the specified
    remote branch. The new branch will be configured as the base branch for pull requests created using
    `gh pr create`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: base
      shorthand: b
      value_type: string
DOCS
gh_issue_develop.md:25Markdown · 14 words
TESTS
pkg/cmd/issue/develop/develop_test.go:23pkg/cmd/issue/develop/develop_test::TestNewCmdDevelop · Go · 132 lines
func TestNewCmdDevelop(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdDevelop)

	tests := []struct {
		name             string
		input            string
		output           DevelopOptions
		expectedBaseRepo ghrepo.Interface
		wantStdout       string
		wantStderr       string
		wantErr          bool
		errMsg           string
	}{
		{
			name:  "branch-repo flag",
			input: "1 --branch-repo owner/repo",
			output: DevelopOptions{
				IssueNumber: 1,
				BranchRepo:  "owner/repo",
			},
		},
		{
			name:  "base flag",
			input: "1 --base feature",
			output: DevelopOptions{
				IssueNumber: 1,
				BaseBranch:  "feature",
			},
		},
+ 102 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue develop
short: Manage linked branches for an issue.
long: |-
    When using the `--base` flag, the new development branch will be created from the specified
    remote branch. The new branch will be configured as the base branch for pull requests created using
    `gh pr create`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: base
      shorthand: b
      value_type: string
DOCS
gh_issue_develop.md:26Markdown · 6 words
TESTS
pkg/cmd/issue/develop/develop_test.go:23pkg/cmd/issue/develop/develop_test::TestNewCmdDevelop · Go · 132 lines
func TestNewCmdDevelop(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdDevelop)

	tests := []struct {
		name             string
		input            string
		output           DevelopOptions
		expectedBaseRepo ghrepo.Interface
		wantStdout       string
		wantStderr       string
		wantErr          bool
		errMsg           string
	}{
		{
			name:  "branch-repo flag",
			input: "1 --branch-repo owner/repo",
			output: DevelopOptions{
				IssueNumber: 1,
				BranchRepo:  "owner/repo",
			},
		},
		{
			name:  "base flag",
			input: "1 --base feature",
			output: DevelopOptions{
				IssueNumber: 1,
				BaseBranch:  "feature",
			},
		},
+ 102 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue develop
short: Manage linked branches for an issue.
long: |-
    When using the `--base` flag, the new development branch will be created from the specified
    remote branch. The new branch will be configured as the base branch for pull requests created using
    `gh pr create`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: base
      shorthand: b
      value_type: string
DOCS
gh_issue_develop.md:27Markdown · 6 words
TESTS
pkg/cmd/issue/develop/develop_test.go:23pkg/cmd/issue/develop/develop_test::TestNewCmdDevelop · Go · 132 lines
func TestNewCmdDevelop(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdDevelop)

	tests := []struct {
		name             string
		input            string
		output           DevelopOptions
		expectedBaseRepo ghrepo.Interface
		wantStdout       string
		wantStderr       string
		wantErr          bool
		errMsg           string
	}{
		{
			name:  "branch-repo flag",
			input: "1 --branch-repo owner/repo",
			output: DevelopOptions{
				IssueNumber: 1,
				BranchRepo:  "owner/repo",
			},
		},
		{
			name:  "base flag",
			input: "1 --base feature",
			output: DevelopOptions{
				IssueNumber: 1,
				BaseBranch:  "feature",
			},
		},
+ 102 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue develop
short: Manage linked branches for an issue.
long: |-
    When using the `--base` flag, the new development branch will be created from the specified
    remote branch. The new branch will be configured as the base branch for pull requests created using
    `gh pr create`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: base
      shorthand: b
      value_type: string
DOCS
gh_issue_develop.md:28Markdown · 6 words
TESTS
pkg/cmd/issue/develop/develop_test.go:23pkg/cmd/issue/develop/develop_test::TestNewCmdDevelop · Go · 132 lines
func TestNewCmdDevelop(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdDevelop)

	tests := []struct {
		name             string
		input            string
		output           DevelopOptions
		expectedBaseRepo ghrepo.Interface
		wantStdout       string
		wantStderr       string
		wantErr          bool
		errMsg           string
	}{
		{
			name:  "branch-repo flag",
			input: "1 --branch-repo owner/repo",
			output: DevelopOptions{
				IssueNumber: 1,
				BranchRepo:  "owner/repo",
			},
		},
		{
			name:  "base flag",
			input: "1 --base feature",
			output: DevelopOptions{
				IssueNumber: 1,
				BaseBranch:  "feature",
			},
		},
+ 102 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue edit
short: Edit one or more issues within the same repository.
long: |-
    Editing issues' projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
    - `@copilot`: assign or unassign Copilot (not supported on GitHub Enterprise Server)
TESTS
pkg/cmd/issue/edit/edit_test.go:25pkg/cmd/issue/edit/edit_test::TestNewCmdEdit · Go · 312 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:     "no argument",
			input:    "",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "issue number argument",
			input: "23",
			output: EditOptions{
				IssueNumbers: []int{23},
				Interactive:  true,
			},
			wantsErr: false,
		},
		{
			name:  "title flag",
+ 282 more lines · read full file
pkg/cmd/issue/edit/edit_test.go:338pkg/cmd/issue/edit/edit_test::Test_editRun · Go · 416 lines
func Test_editRun(t *testing.T) {
	tests := []struct {
		name      string
		input     *EditOptions
		httpStubs func(*testing.T, *httpmock.Registry)
		stdout    string
		stderr    string
		wantErr   bool
	}{
		{
			name: "non-interactive",
			input: &EditOptions{
				Detector:     &fd.EnabledDetectorMock{},
				IssueNumbers: []int{123},
				Interactive:  false,
				Editable: prShared.Editable{
					Title: prShared.EditableString{
						Value:  "new title",
						Edited: true,
					},
					Body: prShared.EditableString{
						Value:  "new body",
						Edited: true,
					},
					Assignees: prShared.EditableAssignees{
						EditableSlice: prShared.EditableSlice{
							Add:    []string{"monalisa", "hubot"},
							Remove: []string{"octocat"},
							Edited: true,
						},
+ 386 more lines · read full file
pkg/cmd/issue/edit/edit_test.go:938pkg/cmd/issue/edit/edit_test::TestApiActorsSupported · Go · 78 lines
func TestApiActorsSupported(t *testing.T) {
	t.Run("when actors are assignable, query includes assignedActors", func(t *testing.T) {
		ios, _, _, _ := iostreams.Test()

		reg := &httpmock.Registry{}
		reg.Register(
			httpmock.GraphQL(`assignedActors`),
			// Simulate a GraphQL error to early exit the test.
			httpmock.StatusStringResponse(500, ""),
		)

		_, cmdTeardown := run.Stub()
		defer cmdTeardown(t)

		// Ignore the error because we don't care.
		_ = editRun(&EditOptions{
			IO: ios,
			HttpClient: func() (*http.Client, error) {
				return &http.Client{Transport: reg}, nil
			},
			BaseRepo: func() (ghrepo.Interface, error) {
				return ghrepo.New("OWNER", "REPO"), nil
			},
			Detector:     &fd.EnabledDetectorMock{},
			IssueNumbers: []int{123},
			Editable: prShared.Editable{
				Assignees: prShared.EditableAssignees{
					EditableSlice: prShared.EditableSlice{
						Add:    []string{"monalisa", "octocat"},
						Edited: true,
+ 48 more lines · read full file
+ 5 more tests · open all in source
EXAMPLES
CONTRACT
command: gh issue edit
short: Edit one or more issues within the same repository.
long: |-
    Editing issues' projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
    - `@copilot`: assign or unassign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_edit.md:28Markdown · 16 words
TESTS
pkg/cmd/issue/edit/edit_test.go:25pkg/cmd/issue/edit/edit_test::TestNewCmdEdit · Go · 312 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:     "no argument",
			input:    "",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "issue number argument",
			input: "23",
			output: EditOptions{
				IssueNumbers: []int{23},
				Interactive:  true,
			},
			wantsErr: false,
		},
		{
			name:  "title flag",
+ 282 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue edit
short: Edit one or more issues within the same repository.
long: |-
    Editing issues' projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
    - `@copilot`: assign or unassign Copilot (not supported on GitHub Enterprise Server)
TESTS
pkg/cmd/issue/edit/edit_test.go:25pkg/cmd/issue/edit/edit_test::TestNewCmdEdit · Go · 312 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:     "no argument",
			input:    "",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "issue number argument",
			input: "23",
			output: EditOptions{
				IssueNumbers: []int{23},
				Interactive:  true,
			},
			wantsErr: false,
		},
		{
			name:  "title flag",
+ 282 more lines · read full file
EXAMPLES
CONTRACT
command: gh issue edit
short: Edit one or more issues within the same repository.
long: |-
    Editing issues' projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
    - `@copilot`: assign or unassign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_edit.md:30Markdown · 7 words
TESTS
pkg/cmd/issue/edit/edit_test.go:25pkg/cmd/issue/edit/edit_test::TestNewCmdEdit · Go · 312 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:     "no argument",
			input:    "",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "issue number argument",
			input: "23",
			output: EditOptions{
				IssueNumbers: []int{23},
				Interactive:  true,
			},
			wantsErr: false,
		},
		{
			name:  "title flag",
+ 282 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue edit
short: Edit one or more issues within the same repository.
long: |-
    Editing issues' projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
    - `@copilot`: assign or unassign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_edit.md:31Markdown · 4 words
TESTS
pkg/cmd/issue/edit/edit_test.go:25pkg/cmd/issue/edit/edit_test::TestNewCmdEdit · Go · 312 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:     "no argument",
			input:    "",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "issue number argument",
			input: "23",
			output: EditOptions{
				IssueNumbers: []int{23},
				Interactive:  true,
			},
			wantsErr: false,
		},
		{
			name:  "title flag",
+ 282 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue edit
short: Edit one or more issues within the same repository.
long: |-
    Editing issues' projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
    - `@copilot`: assign or unassign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_edit.md:32Markdown · 12 words
TESTS
pkg/cmd/issue/edit/edit_test.go:25pkg/cmd/issue/edit/edit_test::TestNewCmdEdit · Go · 312 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:     "no argument",
			input:    "",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "issue number argument",
			input: "23",
			output: EditOptions{
				IssueNumbers: []int{23},
				Interactive:  true,
			},
			wantsErr: false,
		},
		{
			name:  "title flag",
+ 282 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue edit
short: Edit one or more issues within the same repository.
long: |-
    Editing issues' projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
    - `@copilot`: assign or unassign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_edit.md:33Markdown · 9 words
TESTS
pkg/cmd/issue/edit/edit_test.go:25pkg/cmd/issue/edit/edit_test::TestNewCmdEdit · Go · 312 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:     "no argument",
			input:    "",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "issue number argument",
			input: "23",
			output: EditOptions{
				IssueNumbers: []int{23},
				Interactive:  true,
			},
			wantsErr: false,
		},
		{
			name:  "title flag",
+ 282 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue edit
short: Edit one or more issues within the same repository.
long: |-
    Editing issues' projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
    - `@copilot`: assign or unassign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_edit.md:34Markdown · 16 words
TESTS
pkg/cmd/issue/edit/edit_test.go:25pkg/cmd/issue/edit/edit_test::TestNewCmdEdit · Go · 312 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:     "no argument",
			input:    "",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "issue number argument",
			input: "23",
			output: EditOptions{
				IssueNumbers: []int{23},
				Interactive:  true,
			},
			wantsErr: false,
		},
		{
			name:  "title flag",
+ 282 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue edit
short: Edit one or more issues within the same repository.
long: |-
    Editing issues' projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
    - `@copilot`: assign or unassign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_edit.md:35Markdown · 4 words
TESTS
pkg/cmd/issue/edit/edit_test.go:25pkg/cmd/issue/edit/edit_test::TestNewCmdEdit · Go · 312 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:     "no argument",
			input:    "",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "issue number argument",
			input: "23",
			output: EditOptions{
				IssueNumbers: []int{23},
				Interactive:  true,
			},
			wantsErr: false,
		},
		{
			name:  "title flag",
+ 282 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue edit
short: Edit one or more issues within the same repository.
long: |-
    Editing issues' projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
    - `@copilot`: assign or unassign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_edit.md:36Markdown · 7 words
TESTS
pkg/cmd/issue/edit/edit_test.go:25pkg/cmd/issue/edit/edit_test::TestNewCmdEdit · Go · 312 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:     "no argument",
			input:    "",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "issue number argument",
			input: "23",
			output: EditOptions{
				IssueNumbers: []int{23},
				Interactive:  true,
			},
			wantsErr: false,
		},
		{
			name:  "title flag",
+ 282 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue edit
short: Edit one or more issues within the same repository.
long: |-
    Editing issues' projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
    - `@copilot`: assign or unassign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_edit.md:37Markdown · 7 words
TESTS
pkg/cmd/issue/edit/edit_test.go:25pkg/cmd/issue/edit/edit_test::TestNewCmdEdit · Go · 312 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:     "no argument",
			input:    "",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "issue number argument",
			input: "23",
			output: EditOptions{
				IssueNumbers: []int{23},
				Interactive:  true,
			},
			wantsErr: false,
		},
		{
			name:  "title flag",
+ 282 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue edit
short: Edit one or more issues within the same repository.
long: |-
    Editing issues' projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
    - `@copilot`: assign or unassign Copilot (not supported on GitHub Enterprise Server)
DOCS
gh_issue_edit.md:38Markdown · 4 words
TESTS
pkg/cmd/issue/edit/edit_test.go:25pkg/cmd/issue/edit/edit_test::TestNewCmdEdit · Go · 312 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:     "no argument",
			input:    "",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "issue number argument",
			input: "23",
			output: EditOptions{
				IssueNumbers: []int{23},
				Interactive:  true,
			},
			wantsErr: false,
		},
		{
			name:  "title flag",
+ 282 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
TESTS
pkg/cmd/issue/list/list_test.go:73pkg/cmd/issue/list/list_test::TestIssueList_nontty · Go · 20 lines
func TestIssueList_nontty(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query IssueList\b`),
		httpmock.FileResponse("./fixtures/issueList.json"))

	output, err := runCommand(http, false, "")
	if err != nil {
		t.Errorf("error running command `issue list`: %v", err)
	}

	assert.Equal(t, "", output.Stderr())
	//nolint:staticcheck // prefer exact matchers over ExpectLines
	test.ExpectLines(t, output.String(),
		`1[\t]+number won[\t]+label[\t]+\d+`,
		`2[\t]+number too[\t]+label[\t]+\d+`,
		`4[\t]+number fore[\t]+label[\t]+\d+`)
}
pkg/cmd/issue/list/list_test.go:94pkg/cmd/issue/list/list_test::TestIssueList_tty · Go · 24 lines
func TestIssueList_tty(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query IssueList\b`),
		httpmock.FileResponse("./fixtures/issueList.json"))

	output, err := runCommand(http, true, "")
	if err != nil {
		t.Errorf("error running command `issue list`: %v", err)
	}

	assert.Equal(t, heredoc.Doc(`

		Showing 3 of 3 open issues in OWNER/REPO

		ID  TITLE        LABELS  UPDATED
		#1  number won   label   about 1 day ago
		#2  number too   label   about 1 month ago
		#4  number fore  label   about 2 years ago
	`), output.String())
	assert.Equal(t, ``, output.Stderr())
}
pkg/cmd/issue/list/list_test.go:119pkg/cmd/issue/list/list_test::TestIssueList_tty_withFlags · Go · 23 lines
func TestIssueList_tty_withFlags(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query IssueList\b`),
		httpmock.GraphQLQuery(`
		{ "data": {	"repository": {
			"hasIssuesEnabled": true,
			"issues": { "nodes": [] }
		} } }`, func(_ string, params map[string]interface{}) {
			assert.Equal(t, "probablyCher", params["assignee"].(string))
			assert.Equal(t, "foo", params["author"].(string))
			assert.Equal(t, "me", params["mention"].(string))
			assert.Equal(t, []interface{}{"OPEN"}, params["states"].([]interface{}))
		}))

	output, err := runCommand(http, true, "-a probablyCher -s open -A foo --mention me")
	assert.EqualError(t, err, "no issues match your search in OWNER/REPO")

	assert.Equal(t, "", output.String())
	assert.Equal(t, "", output.Stderr())
}
+ 7 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_issue_list.md:27Markdown · 5 words
TESTS
pkg/cmd/issue/list/list_test.go:143pkg/cmd/issue/list/list_test::TestIssueList_tty_withAppFlag · Go · 20 lines
func TestIssueList_tty_withAppFlag(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query IssueList\b`),
		httpmock.GraphQLQuery(`
		{ "data": {	"repository": {
			"hasIssuesEnabled": true,
			"issues": { "nodes": [] }
		} } }`, func(_ string, params map[string]interface{}) {
			assert.Equal(t, "app/dependabot", params["author"].(string))
		}))

	output, err := runCommand(http, true, "--app dependabot")
	assert.EqualError(t, err, "no issues match your search in OWNER/REPO")

	assert.Equal(t, "", output.String())
	assert.Equal(t, "", output.Stderr())
}
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_issue_list.md:28Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_issue_list.md:29Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_issue_list.md:30Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_issue_list.md:31Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_issue_list.md:32Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_issue_list.md:33Markdown · 6 words
TESTS
pkg/cmd/issue/list/list_test.go:164pkg/cmd/issue/list/list_test::TestIssueList_withInvalidLimitFlag · Go · 10 lines
func TestIssueList_withInvalidLimitFlag(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	_, err := runCommand(http, true, "--limit=0")

	if err == nil || err.Error() != "invalid limit: 0" {
		t.Errorf("error running command `issue list`: %v", err)
	}
}
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_issue_list.md:34Markdown · 3 words
TESTS
pkg/cmd/issue/list/list_test.go:119pkg/cmd/issue/list/list_test::TestIssueList_tty_withFlags · Go · 23 lines
func TestIssueList_tty_withFlags(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query IssueList\b`),
		httpmock.GraphQLQuery(`
		{ "data": {	"repository": {
			"hasIssuesEnabled": true,
			"issues": { "nodes": [] }
		} } }`, func(_ string, params map[string]interface{}) {
			assert.Equal(t, "probablyCher", params["assignee"].(string))
			assert.Equal(t, "foo", params["author"].(string))
			assert.Equal(t, "me", params["mention"].(string))
			assert.Equal(t, []interface{}{"OPEN"}, params["states"].([]interface{}))
		}))

	output, err := runCommand(http, true, "-a probablyCher -s open -A foo --mention me")
	assert.EqualError(t, err, "no issues match your search in OWNER/REPO")

	assert.Equal(t, "", output.String())
	assert.Equal(t, "", output.Stderr())
}
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_issue_list.md:35Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_issue_list.md:37Markdown · 4 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_issue_list.md:38Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue list
short: List issues in a GitHub repository. By default, this only lists open issues.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_issue_list.md:39Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue lock
short: Lock issue conversation
pname: gh issue
plink: gh_issue.yaml
options:
    - option: reason
      shorthand: r
      value_type: string
      description: Optional reason for locking conversation (off_topic, resolved, spam, too_heated).
DOCS
gh_issue_lock.md:1Markdown · 17 words
TESTS
pkg/cmd/issue/lock/lock_test.go:20pkg/cmd/issue/lock/lock_test::Test_NewCmdLock · Go · 114 lines
func Test_NewCmdLock(t *testing.T) {
	cases := []struct {
		name    string
		args    string
		want    LockOptions
		wantErr string
		tty     bool
	}{
		{
			name: "sets reason",
			args: "--reason off_topic 451",
			want: LockOptions{
				Reason:      "off_topic",
				IssueNumber: 451,
			},
		},
		{
			name:    "no args",
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name: "no flags",
			args: "451",
			want: LockOptions{
				IssueNumber: 451,
			},
		},
		{
			name: "issue number argument",
			args: "451 --repo owner/repo",
+ 84 more lines · read full file
pkg/cmd/issue/lock/lock_test.go:135pkg/cmd/issue/lock/lock_test::Test_NewCmdUnlock · Go · 84 lines
func Test_NewCmdUnlock(t *testing.T) {
	cases := []struct {
		name    string
		args    string
		want    LockOptions
		wantErr string
		tty     bool
	}{
		{
			name:    "no args",
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name: "no flags",
			args: "451",
			want: LockOptions{
				IssueNumber: 451,
			},
		},
		{
			name: "issue number argument",
			args: "451 --repo owner/repo",
			want: LockOptions{
				IssueNumber: 451,
			},
		},
		{
			name: "argument is hash prefixed number",
			// Escaping is required here to avoid what I think is shellex treating it as a comment.
			args: "\\#451 --repo owner/repo",
+ 54 more lines · read full file
pkg/cmd/issue/lock/lock_test.go:220pkg/cmd/issue/lock/lock_test::Test_runLock · Go · 513 lines
func Test_runLock(t *testing.T) {
	cases := []struct {
		name        string
		opts        LockOptions
		promptStubs func(*testing.T, *prompter.PrompterMock)
		httpStubs   func(*testing.T, *httpmock.Registry)
		wantOut     string
		wantErrOut  string
		wantErr     string
		tty         bool
		state       string
	}{
		{
			name:  "lock issue nontty",
			state: Lock,
			opts: LockOptions{
				IssueNumber: 451,
				ParentCmd:   "issue",
			},
			httpStubs: func(t *testing.T, reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query IssueByNumber\b`),
					httpmock.StringResponse(`
						{ "data": { "repository": { "hasIssuesEnabled": true, "issue": {
							"number": 451,
							"__typename": "Issue" }}}}`))
				reg.Register(
					httpmock.GraphQL(`mutation LockLockable\b`),
					httpmock.StringResponse(`
						{ "data": {
+ 483 more lines · read full file
+ 1 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue lock
short: Lock issue conversation
pname: gh issue
plink: gh_issue.yaml
options:
    - option: reason
      shorthand: r
      value_type: string
      description: Optional reason for locking conversation (off_topic, resolved, spam, too_heated).
DOCS
gh_issue_lock.md:19Markdown · 9 words
TESTS
pkg/cmd/issue/lock/lock_test.go:20pkg/cmd/issue/lock/lock_test::Test_NewCmdLock · Go · 114 lines
func Test_NewCmdLock(t *testing.T) {
	cases := []struct {
		name    string
		args    string
		want    LockOptions
		wantErr string
		tty     bool
	}{
		{
			name: "sets reason",
			args: "--reason off_topic 451",
			want: LockOptions{
				Reason:      "off_topic",
				IssueNumber: 451,
			},
		},
		{
			name:    "no args",
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name: "no flags",
			args: "451",
			want: LockOptions{
				IssueNumber: 451,
			},
		},
		{
			name: "issue number argument",
			args: "451 --repo owner/repo",
+ 84 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue pin
short: Pin an issue to a repository.
long: The issue can be specified by issue number or URL.
pname: gh issue
plink: gh_issue.yaml
TESTS
pkg/cmd/issue/pin/pin_test.go:16pkg/cmd/issue/pin/pin_test::TestNewCmdPin · Go · 4 lines
func TestNewCmdPin(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdPin)
}
pkg/cmd/issue/pin/pin_test.go:21pkg/cmd/issue/pin/pin_test::TestPinRun · Go · 80 lines
func TestPinRun(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		opts       *PinOptions
		httpStubs  func(*httpmock.Registry)
		wantStdout string
		wantStderr string
	}{
		{
			name: "pin issue",
			tty:  true,
			opts: &PinOptions{IssueNumber: 20},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query IssueByNumber\b`),
					httpmock.StringResponse(`
            { "data": { "repository": {
              "issue": { "id": "ISSUE-ID", "number": 20, "title": "Issue Title", "isPinned": false}
            } } }`),
				)
				reg.Register(
					httpmock.GraphQL(`mutation IssuePin\b`),
					httpmock.GraphQLMutation(`{"id": "ISSUE-ID"}`,
						func(inputs map[string]interface{}) {
							assert.Equal(t, inputs["issueId"], "ISSUE-ID")
						},
					),
				)
			},
+ 50 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue reopen
short: Reopen issue
pname: gh issue
plink: gh_issue.yaml
options:
    - option: comment
      shorthand: c
      value_type: string
      description: Add a reopening comment
DOCS
gh_issue_reopen.md:1Markdown · 16 words
TESTS
pkg/cmd/issue/reopen/reopen_test.go:22pkg/cmd/issue/reopen/reopen_test::TestNewCmdReopen · Go · 4 lines
func TestNewCmdReopen(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdReopen)
}
pkg/cmd/issue/reopen/reopen_test.go:65pkg/cmd/issue/reopen/reopen_test::TestIssueReopen · Go · 31 lines
func TestIssueReopen(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query IssueByNumber\b`),
		httpmock.StringResponse(`
			{ "data": { "repository": {
				"hasIssuesEnabled": true,
				"issue": { "id": "THE-ID", "number": 2, "state": "CLOSED", "title": "The title of the issue"}
			} } }`),
	)
	http.Register(
		httpmock.GraphQL(`mutation IssueReopen\b`),
		httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["issueId"], "THE-ID")
			}),
	)

	output, err := runCommand(http, true, "2")
	if err != nil {
		t.Fatalf("error running command `issue reopen`: %v", err)
	}

	r := regexp.MustCompile(`Reopened issue OWNER/REPO#2 \(The title of the issue\)`)

	if !r.MatchString(output.Stderr()) {
		t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr())
	}
+ 1 more lines · read full file
pkg/cmd/issue/reopen/reopen_test.go:97pkg/cmd/issue/reopen/reopen_test::TestIssueReopen_alreadyOpen · Go · 24 lines
func TestIssueReopen_alreadyOpen(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query IssueByNumber\b`),
		httpmock.StringResponse(`
			{ "data": { "repository": {
				"hasIssuesEnabled": true,
				"issue": { "number": 2, "state": "OPEN", "title": "The title of the issue"}
			} } }`),
	)

	output, err := runCommand(http, true, "2")
	if err != nil {
		t.Fatalf("error running command `issue reopen`: %v", err)
	}

	r := regexp.MustCompile(`Issue OWNER/REPO#2 \(The title of the issue\) is already open`)

	if !r.MatchString(output.Stderr()) {
		t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr())
	}
}
+ 2 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue reopen
short: Reopen issue
pname: gh issue
plink: gh_issue.yaml
options:
    - option: comment
      shorthand: c
      value_type: string
      description: Add a reopening comment
DOCS
gh_issue_reopen.md:19Markdown · 4 words
TESTS
pkg/cmd/issue/reopen/reopen_test.go:155pkg/cmd/issue/reopen/reopen_test::TestIssueReopen_withComment · Go · 42 lines
func TestIssueReopen_withComment(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query IssueByNumber\b`),
		httpmock.StringResponse(`
			{ "data": { "repository": {
				"hasIssuesEnabled": true,
				"issue": { "id": "THE-ID", "number": 2, "state": "CLOSED", "title": "The title of the issue"}
			} } }`),
	)
	http.Register(
		httpmock.GraphQL(`mutation CommentCreate\b`),
		httpmock.GraphQLMutation(`
		{ "data": { "addComment": { "commentEdge": { "node": {
			"url": "https://github.com/OWNER/REPO/issues/123#issuecomment-456"
		} } } } }`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, "THE-ID", inputs["subjectId"])
				assert.Equal(t, "reopening comment", inputs["body"])
			}),
	)
	http.Register(
		httpmock.GraphQL(`mutation IssueReopen\b`),
		httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["issueId"], "THE-ID")
			}),
	)
+ 12 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue status
short: Show status of relevant issues
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_issue_status.md:1Markdown · 42 words
TESTS
pkg/cmd/issue/status/status_test.go:58pkg/cmd/issue/status/status_test::TestIssueStatus · Go · 30 lines
func TestIssueStatus(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query UserCurrent\b`),
		httpmock.StringResponse(`{"data":{"viewer":{"login":"octocat"}}}`))
	http.Register(
		httpmock.GraphQL(`query IssueStatus\b`),
		httpmock.FileResponse("./fixtures/issueStatus.json"))

	output, err := runCommand(http, true, "")
	if err != nil {
		t.Errorf("error running command `issue status`: %v", err)
	}

	expectedIssues := []*regexp.Regexp{
		regexp.MustCompile(`(?m)8.*carrots.*about.*ago`),
		regexp.MustCompile(`(?m)9.*squash.*about.*ago`),
		regexp.MustCompile(`(?m)10.*broccoli.*about.*ago`),
		regexp.MustCompile(`(?m)11.*swiss chard.*about.*ago`),
	}

	for _, r := range expectedIssues {
		if !r.MatchString(output.String()) {
			t.Errorf("output did not match regexp /%s/\n> output\n%s\n", r, output)
			return
		}
	}
}
pkg/cmd/issue/status/status_test.go:89pkg/cmd/issue/status/status_test::TestIssueStatus_blankSlate · Go · 39 lines
func TestIssueStatus_blankSlate(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query UserCurrent\b`),
		httpmock.StringResponse(`{"data":{"viewer":{"login":"octocat"}}}`))
	http.Register(
		httpmock.GraphQL(`query IssueStatus\b`),
		httpmock.StringResponse(`
		{ "data": { "repository": {
			"hasIssuesEnabled": true,
			"assigned": { "nodes": [] },
			"mentioned": { "nodes": [] },
			"authored": { "nodes": [] }
		} } }`))

	output, err := runCommand(http, true, "")
	if err != nil {
		t.Errorf("error running command `issue status`: %v", err)
	}

	expectedOutput := `
Relevant issues in OWNER/REPO

Issues assigned to you
  There are no issues assigned to you

Issues mentioning you
  There are no issues mentioning you
+ 9 more lines · read full file
pkg/cmd/issue/status/status_test.go:129pkg/cmd/issue/status/status_test::TestIssueStatus_disabledIssues · Go · 19 lines
func TestIssueStatus_disabledIssues(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query UserCurrent\b`),
		httpmock.StringResponse(`{"data":{"viewer":{"login":"octocat"}}}`))
	http.Register(
		httpmock.GraphQL(`query IssueStatus\b`),
		httpmock.StringResponse(`
		{ "data": { "repository": {
			"hasIssuesEnabled": false
		} } }`))

	_, err := runCommand(http, true, "")
	if err == nil || err.Error() != "the 'OWNER/REPO' repository has disabled issues" {
		t.Errorf("error running command `issue status`: %v", err)
	}
}
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue status
short: Show status of relevant issues
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_issue_status.md:19Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue status
short: Show status of relevant issues
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_issue_status.md:20Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue status
short: Show status of relevant issues
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_issue_status.md:21Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue transfer
short: Transfer issue to another repository
pname: gh issue
plink: gh_issue.yaml
TESTS
pkg/cmd/issue/transfer/transfer_test.go:59pkg/cmd/issue/transfer/transfer_test::TestNewCmdTransfer · Go · 86 lines
func TestNewCmdTransfer(t *testing.T) {
	tests := []struct {
		name         string
		cli          string
		wants        TransferOptions
		wantBaseRepo ghrepo.Interface
		wantErr      bool
	}{
		{
			name:    "no argument",
			cli:     "",
			wantErr: true,
		},
		{
			name: "issue number argument",
			cli:  "--repo cli/repo 23 OWNER/REPO",
			wants: TransferOptions{
				IssueNumber:      23,
				DestRepoSelector: "OWNER/REPO",
			},
			wantBaseRepo: ghrepo.New("cli", "repo"),
		},
		{
			name: "argument is hash prefixed number",
			// Escaping is required here to avoid what I think is shellex treating it as a comment.
			cli: "--repo cli/repo \\#23 OWNER/REPO",
			wants: TransferOptions{
				IssueNumber:      23,
				DestRepoSelector: "OWNER/REPO",
			},
+ 56 more lines · read full file
pkg/cmd/issue/transfer/transfer_test.go:146pkg/cmd/issue/transfer/transfer_test::Test_transferRun_noflags · Go · 12 lines
func Test_transferRun_noflags(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	output, err := runCommand(http, "")

	if err != nil {
		assert.Equal(t, "issue and destination repository are required", err.Error())
	}

	assert.Equal(t, "", output.String())
}
pkg/cmd/issue/transfer/transfer_test.go:159pkg/cmd/issue/transfer/transfer_test::Test_transferRunSuccessfulIssueTransfer · Go · 36 lines
func Test_transferRunSuccessfulIssueTransfer(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query IssueByNumber\b`),
		httpmock.StringResponse(`
			{ "data": { "repository": {
				"hasIssuesEnabled": true,
				"issue": { "id": "THE-ID", "number": 1234, "title": "The title of the issue"}
			} } }`))

	http.Register(
		httpmock.GraphQL(`query IssueRepositoryInfo\b`),
		httpmock.StringResponse(`
				{ "data": { "repository": {
						"id": "dest-id",
						"name": "REPO1",
						"owner": { "login": "OWNER1" },
						"viewerPermission": "WRITE",
						"hasIssuesEnabled": true
				}}}`))

	http.Register(
		httpmock.GraphQL(`mutation IssueTransfer\b`),
		httpmock.GraphQLMutation(`{"data":{"transferIssue":{"issue":{"url":"https://github.com/OWNER1/REPO1/issues/1"}}}}`, func(input map[string]interface{}) {
			assert.Equal(t, input["issueId"], "THE-ID")
			assert.Equal(t, input["repositoryId"], "dest-id")
		}))
+ 7 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue unlock
short: Unlock issue conversation
pname: gh issue
plink: gh_issue.yaml
DOCS
gh_issue_unlock.md:1Markdown · 16 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue unpin
short: Unpin an issue from a repository.
long: The issue can be specified by issue number or URL.
pname: gh issue
plink: gh_issue.yaml
TESTS
pkg/cmd/issue/unpin/unpin_test.go:16pkg/cmd/issue/unpin/unpin_test::TestNewCmdUnpin · Go · 4 lines
func TestNewCmdUnpin(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdUnpin)
}
pkg/cmd/issue/unpin/unpin_test.go:21pkg/cmd/issue/unpin/unpin_test::TestUnpinRun · Go · 80 lines
func TestUnpinRun(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		opts       *UnpinOptions
		httpStubs  func(*httpmock.Registry)
		wantStdout string
		wantStderr string
	}{
		{
			name: "unpin issue",
			tty:  true,
			opts: &UnpinOptions{IssueNumber: 20},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query IssueByNumber\b`),
					httpmock.StringResponse(`
            { "data": { "repository": {
              "issue": { "id": "ISSUE-ID", "number": 20, "title": "Issue Title", "isPinned": true}
            } } }`),
				)
				reg.Register(
					httpmock.GraphQL(`mutation IssueUnpin\b`),
					httpmock.GraphQLMutation(`{"id": "ISSUE-ID"}`,
						func(inputs map[string]interface{}) {
							assert.Equal(t, inputs["issueId"], "ISSUE-ID")
						},
					),
				)
			},
+ 50 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue view
short: Display the title, body, and other information about an issue.
long: |-
    With `--web` flag, open the issue in a web browser instead.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: comments
      shorthand: c
      value_type: bool
DOCS
gh_issue_view.md:1Markdown · 58 words
TESTS
pkg/cmd/issue/view/view_test.go:26pkg/cmd/issue/view/view_test::TestJSONFields · Go · 25 lines
func TestJSONFields(t *testing.T) {
	jsonfieldstest.ExpectCommandToSupportJSONFields(t, NewCmdView, []string{
		"assignees",
		"author",
		"body",
		"closed",
		"comments",
		"closedByPullRequestsReferences",
		"createdAt",
		"closedAt",
		"id",
		"labels",
		"milestone",
		"number",
		"projectCards",
		"projectItems",
		"reactionGroups",
		"state",
		"title",
		"updatedAt",
		"url",
		"isPinned",
		"stateReason",
	})
}
pkg/cmd/issue/view/view_test.go:52pkg/cmd/issue/view/view_test::TestNewCmdView · Go · 4 lines
func TestNewCmdView(t *testing.T) {
	// Test shared parsing of issue number / URL.
	argparsetest.TestArgParsing(t, NewCmdView)
}
pkg/cmd/issue/view/view_test.go:95pkg/cmd/issue/view/view_test::TestIssueView_web · Go · 41 lines
func TestIssueView_web(t *testing.T) {
	ios, _, stdout, stderr := iostreams.Test()
	ios.SetStdoutTTY(true)
	ios.SetStderrTTY(true)
	browser := &browser.Stub{}

	reg := &httpmock.Registry{}
	defer reg.Verify(t)

	reg.Register(
		httpmock.GraphQL(`query IssueByNumber\b`),
		httpmock.StringResponse(`
			{ "data": { "repository": { "hasIssuesEnabled": true, "issue": {
				"number": 123,
				"url": "https://github.com/OWNER/REPO/issues/123"
			} } } }
		`))

	_, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	err := viewRun(&ViewOptions{
		IO:      ios,
		Browser: browser,
		HttpClient: func() (*http.Client, error) {
			return &http.Client{Transport: reg}, nil
		},
		BaseRepo: func() (ghrepo.Interface, error) {
			return ghrepo.New("OWNER", "REPO"), nil
		},
+ 11 more lines · read full file
+ 9 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh issue view
short: Display the title, body, and other information about an issue.
long: |-
    With `--web` flag, open the issue in a web browser instead.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: comments
      shorthand: c
      value_type: bool
DOCS
gh_issue_view.md:22Markdown · 3 words
TESTS
pkg/cmd/issue/view/view_test.go:379pkg/cmd/issue/view/view_test::TestIssueView_tty_Comments · Go · 72 lines
func TestIssueView_tty_Comments(t *testing.T) {
	tests := map[string]struct {
		cli             string
		httpStubs       func(*httpmock.Registry)
		expectedOutputs []string
		wantsErr        bool
	}{
		"without comments flag": {
			cli: "123",
			httpStubs: func(r *httpmock.Registry) {
				r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewSingleComment.json"))
				mockEmptyV2ProjectItems(t, r)
			},
			expectedOutputs: []string{
				`some title OWNER/REPO#123`,
				`some body`,
				`———————— Not showing 5 comments ————————`,
				`marseilles \(Collaborator\) • Jan  1, 2020 • Newest comment`,
				`Comment 5`,
				`Use --comments to view the full conversation`,
				`View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
			},
		},
		"with comments flag": {
			cli: "123 --comments",
			httpStubs: func(r *httpmock.Registry) {
				r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewSingleComment.json"))
				r.Register(httpmock.GraphQL(`query CommentsForIssue\b`), httpmock.FileResponse("./fixtures/issueView_previewFullComments.json"))
				mockEmptyV2ProjectItems(t, r)
			},
+ 42 more lines · read full file
pkg/cmd/issue/view/view_test.go:452pkg/cmd/issue/view/view_test::TestIssueView_nontty_Comments · Go · 76 lines
func TestIssueView_nontty_Comments(t *testing.T) {
	tests := map[string]struct {
		cli             string
		httpStubs       func(*httpmock.Registry)
		expectedOutputs []string
		wantsErr        bool
	}{
		"without comments flag": {
			cli: "123",
			httpStubs: func(r *httpmock.Registry) {
				r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewSingleComment.json"))
				mockEmptyV2ProjectItems(t, r)
			},
			expectedOutputs: []string{
				`title:\tsome title`,
				`state:\tOPEN`,
				`author:\tmarseilles`,
				`comments:\t6`,
				`number:\t123`,
				`some body`,
			},
		},
		"with comments flag": {
			cli: "123 --comments",
			httpStubs: func(r *httpmock.Registry) {
				r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewSingleComment.json"))
				r.Register(httpmock.GraphQL(`query CommentsForIssue\b`), httpmock.FileResponse("./fixtures/issueView_previewFullComments.json"))
				mockEmptyV2ProjectItems(t, r)
			},
			expectedOutputs: []string{
+ 46 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue view
short: Display the title, body, and other information about an issue.
long: |-
    With `--web` flag, open the issue in a web browser instead.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: comments
      shorthand: c
      value_type: bool
DOCS
gh_issue_view.md:23Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue view
short: Display the title, body, and other information about an issue.
long: |-
    With `--web` flag, open the issue in a web browser instead.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: comments
      shorthand: c
      value_type: bool
DOCS
gh_issue_view.md:24Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue view
short: Display the title, body, and other information about an issue.
long: |-
    With `--web` flag, open the issue in a web browser instead.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: comments
      shorthand: c
      value_type: bool
DOCS
gh_issue_view.md:25Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh issue view
short: Display the title, body, and other information about an issue.
long: |-
    With `--web` flag, open the issue in a web browser instead.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh issue
plink: gh_issue.yaml
options:
    - option: comments
      shorthand: c
      value_type: bool
DOCS
gh_issue_view.md:26Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh label
short: Work with GitHub labels.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_label.md:1Markdown · 33 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh label
short: Work with GitHub labels.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_label.md:24Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh label clone
short: Clones labels from a source repository to a destination repository on GitHub.
long: |-
    By default, the destination repository is the current repository.

    All labels from the source repository will be copied to the destination
    repository. Labels in the destination repository that are not in the source
    repository will not be deleted or modified.

    Labels from the source repository that already exist in the destination
    repository will be skipped. You can overwrite existing labels in the
    destination repository using the `--force` flag.
DOCS
gh_label_clone.md:1Markdown · 95 words
TESTS
pkg/cmd/label/clone_test.go:16pkg/cmd/label/clone_test::TestNewCmdClone · Go · 64 lines
func TestNewCmdClone(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  cloneOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "cannot clone labels: source-repository argument required",
		},
		{
			name:  "source-repository argument",
			input: "OWNER/REPO",
			output: cloneOptions{
				SourceRepo: ghrepo.New("OWNER", "REPO"),
			},
		},
		{
			name:  "force flag",
			input: "OWNER/REPO --force",
			output: cloneOptions{
				SourceRepo: ghrepo.New("OWNER", "REPO"),
				Force:      true,
			},
		},
	}
+ 34 more lines · read full file
pkg/cmd/label/clone_test.go:81pkg/cmd/label/clone_test::TestCloneRun · Go · 505 lines
func TestCloneRun(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		opts       *cloneOptions
		httpStubs  func(*httpmock.Registry)
		wantStdout string
		wantErr    bool
		wantErrMsg string
	}{
		{
			name: "clones all labels",
			tty:  true,
			opts: &cloneOptions{SourceRepo: ghrepo.New("cli", "cli")},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query LabelList\b`),
					httpmock.GraphQLQuery(`
					{
						"data": {
							"repository": {
								"labels": {
									"totalCount": 2,
									"nodes": [
										{
											"name": "bug",
											"color": "d73a4a",
											"description": "Something isn't working"
										},
										{
+ 475 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label clone
short: Clones labels from a source repository to a destination repository on GitHub.
long: |-
    By default, the destination repository is the current repository.

    All labels from the source repository will be copied to the destination
    repository. Labels in the destination repository that are not in the source
    repository will not be deleted or modified.

    Labels from the source repository that already exist in the destination
    repository will be skipped. You can overwrite existing labels in the
    destination repository using the `--force` flag.
DOCS
gh_label_clone.md:29Markdown · 6 words
TESTS
pkg/cmd/label/clone_test.go:16pkg/cmd/label/clone_test::TestNewCmdClone · Go · 64 lines
func TestNewCmdClone(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  cloneOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "cannot clone labels: source-repository argument required",
		},
		{
			name:  "source-repository argument",
			input: "OWNER/REPO",
			output: cloneOptions{
				SourceRepo: ghrepo.New("OWNER", "REPO"),
			},
		},
		{
			name:  "force flag",
			input: "OWNER/REPO --force",
			output: cloneOptions{
				SourceRepo: ghrepo.New("OWNER", "REPO"),
				Force:      true,
			},
		},
	}
+ 34 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label create
short: Create a new label on GitHub, or update an existing one with `--force`.
long: |-
    Must specify name for the label. The description and color are optional.
    If a color isn't provided, a random one will be chosen.

    The label color needs to be 6 character hex value.
pname: gh label
plink: gh_label.yaml
options:
    - option: color
      shorthand: c
DOCS
gh_label_create.md:1Markdown · 61 words
TESTS
pkg/cmd/label/create_test.go:18pkg/cmd/label/create_test::TestNewCmdCreate · Go · 67 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  createOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "cannot create label: name argument required",
		},
		{
			name:   "name argument",
			input:  "test",
			output: createOptions{Name: "test"},
		},
		{
			name:   "description flag",
			input:  "test --description 'some description'",
			output: createOptions{Name: "test", Description: "some description"},
		},
		{
			name:   "color flag",
			input:  "test --color FFFFFF",
			output: createOptions{Name: "test", Color: "FFFFFF"},
		},
		{
+ 37 more lines · read full file
pkg/cmd/label/create_test.go:86pkg/cmd/label/create_test::TestCreateRun · Go · 84 lines
func TestCreateRun(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		opts       *createOptions
		httpStubs  func(*httpmock.Registry)
		wantStdout string
	}{
		{
			name: "creates label",
			tty:  true,
			opts: &createOptions{Name: "test", Description: "some description"},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("POST", "repos/OWNER/REPO/labels"),
					httpmock.StatusStringResponse(201, "{}"),
				)
			},
			wantStdout: "✓ Label \"test\" created in OWNER/REPO\n",
		},
		{
			name: "creates label notty",
			tty:  false,
			opts: &createOptions{Name: "test", Description: "some description"},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("POST", "repos/OWNER/REPO/labels"),
					httpmock.StatusStringResponse(201, "{}"),
				)
			},
+ 54 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label create
short: Create a new label on GitHub, or update an existing one with `--force`.
long: |-
    Must specify name for the label. The description and color are optional.
    If a color isn't provided, a random one will be chosen.

    The label color needs to be 6 character hex value.
pname: gh label
plink: gh_label.yaml
options:
    - option: color
      shorthand: c
DOCS
gh_label_create.md:25Markdown · 4 words
TESTS
pkg/cmd/label/create_test.go:18pkg/cmd/label/create_test::TestNewCmdCreate · Go · 67 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  createOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "cannot create label: name argument required",
		},
		{
			name:   "name argument",
			input:  "test",
			output: createOptions{Name: "test"},
		},
		{
			name:   "description flag",
			input:  "test --description 'some description'",
			output: createOptions{Name: "test", Description: "some description"},
		},
		{
			name:   "color flag",
			input:  "test --color FFFFFF",
			output: createOptions{Name: "test", Color: "FFFFFF"},
		},
		{
+ 37 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label create
short: Create a new label on GitHub, or update an existing one with `--force`.
long: |-
    Must specify name for the label. The description and color are optional.
    If a color isn't provided, a random one will be chosen.

    The label color needs to be 6 character hex value.
pname: gh label
plink: gh_label.yaml
options:
    - option: color
      shorthand: c
DOCS
gh_label_create.md:26Markdown · 4 words
TESTS
pkg/cmd/label/create_test.go:18pkg/cmd/label/create_test::TestNewCmdCreate · Go · 67 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  createOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "cannot create label: name argument required",
		},
		{
			name:   "name argument",
			input:  "test",
			output: createOptions{Name: "test"},
		},
		{
			name:   "description flag",
			input:  "test --description 'some description'",
			output: createOptions{Name: "test", Description: "some description"},
		},
		{
			name:   "color flag",
			input:  "test --color FFFFFF",
			output: createOptions{Name: "test", Color: "FFFFFF"},
		},
		{
+ 37 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label create
short: Create a new label on GitHub, or update an existing one with `--force`.
long: |-
    Must specify name for the label. The description and color are optional.
    If a color isn't provided, a random one will be chosen.

    The label color needs to be 6 character hex value.
pname: gh label
plink: gh_label.yaml
options:
    - option: color
      shorthand: c
DOCS
gh_label_create.md:27Markdown · 10 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh label delete
short: Delete a label from a repository
pname: gh label
plink: gh_label.yaml
options:
    - option: "yes"
      value_type: bool
      default_value: "false"
      description: Confirm deletion without prompting
DOCS
gh_label_delete.md:1Markdown · 20 words
TESTS
pkg/cmd/label/delete_test.go:17pkg/cmd/label/delete_test::TestNewCmdDelete · Go · 66 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		input      string
		output     deleteOptions
		wantErr    bool
		wantErrMsg string
	}{
		{
			name:       "no argument",
			input:      "",
			wantErr:    true,
			wantErrMsg: "cannot delete label: name argument required",
		},
		{
			name:   "name argument",
			tty:    true,
			input:  "test",
			output: deleteOptions{Name: "test"},
		},
		{
			name:   "confirm argument",
			input:  "test --yes",
			output: deleteOptions{Name: "test", Confirmed: true},
		},
		{
			name:       "confirm no tty",
			input:      "test",
			wantErr:    true,
+ 36 more lines · read full file
pkg/cmd/label/delete_test.go:84pkg/cmd/label/delete_test::TestDeleteRun · Go · 99 lines
func TestDeleteRun(t *testing.T) {
	tests := []struct {
		name          string
		tty           bool
		opts          *deleteOptions
		httpStubs     func(*httpmock.Registry)
		prompterStubs func(*prompter.PrompterMock)
		wantStdout    string
		wantErr       bool
		errMsg        string
	}{
		{
			name: "deletes label",
			tty:  true,
			opts: &deleteOptions{Name: "test"},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("DELETE", "repos/OWNER/REPO/labels/test"),
					httpmock.StatusStringResponse(204, "{}"),
				)
			},
			prompterStubs: func(pm *prompter.PrompterMock) {
				pm.ConfirmDeletionFunc = func(_ string) error {
					return nil
				}
			},
			wantStdout: "✓ Label \"test\" deleted from OWNER/REPO\n",
		},
		{
			name: "deletes label notty",
+ 69 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label delete
short: Delete a label from a repository
pname: gh label
plink: gh_label.yaml
options:
    - option: "yes"
      value_type: bool
      default_value: "false"
      description: Confirm deletion without prompting
DOCS
gh_label_delete.md:19Markdown · 4 words
TESTS
pkg/cmd/label/delete_test.go:17pkg/cmd/label/delete_test::TestNewCmdDelete · Go · 66 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		input      string
		output     deleteOptions
		wantErr    bool
		wantErrMsg string
	}{
		{
			name:       "no argument",
			input:      "",
			wantErr:    true,
			wantErrMsg: "cannot delete label: name argument required",
		},
		{
			name:   "name argument",
			tty:    true,
			input:  "test",
			output: deleteOptions{Name: "test"},
		},
		{
			name:   "confirm argument",
			input:  "test --yes",
			output: deleteOptions{Name: "test", Confirmed: true},
		},
		{
			name:       "confirm no tty",
			input:      "test",
			wantErr:    true,
+ 36 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh label edit
short: Update a label on GitHub.
long: |-
    A label can be renamed using the `--name` flag.

    The label color needs to be 6 character hex value.
pname: gh label
plink: gh_label.yaml
options:
    - option: color
      shorthand: c
      value_type: string
DOCS
gh_label_edit.md:1Markdown · 39 words
TESTS
pkg/cmd/label/edit_test.go:16pkg/cmd/label/edit_test::TestNewCmdEdit · Go · 74 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  editOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "cannot update label: name argument required",
		},
		{
			name:    "name argument",
			input:   "test",
			wantErr: true,
			errMsg:  "specify at least one of `--color`, `--description`, or `--name`",
		},
		{
			name:   "description flag",
			input:  "test --description 'some description'",
			output: editOptions{Name: "test", Description: "some description"},
		},
		{
			name:   "color flag",
			input:  "test --color FFFFFF",
			output: editOptions{Name: "test", Color: "FFFFFF"},
		},
+ 44 more lines · read full file
pkg/cmd/label/edit_test.go:91pkg/cmd/label/edit_test::TestEditRun · Go · 80 lines
func TestEditRun(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		opts       *editOptions
		httpStubs  func(*httpmock.Registry)
		wantStdout string
		wantErrMsg string
	}{
		{
			name: "updates label",
			tty:  true,
			opts: &editOptions{Name: "test", Description: "some description"},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("PATCH", "repos/OWNER/REPO/labels/test"),
					httpmock.StatusStringResponse(201, "{}"),
				)
			},
			wantStdout: "✓ Label \"test\" updated in OWNER/REPO\n",
		},
		{
			name: "updates label notty",
			tty:  false,
			opts: &editOptions{Name: "test", Description: "some description"},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("PATCH", "repos/OWNER/REPO/labels/test"),
					httpmock.StatusStringResponse(201, "{}"),
				)
+ 50 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label edit
short: Update a label on GitHub.
long: |-
    A label can be renamed using the `--name` flag.

    The label color needs to be 6 character hex value.
pname: gh label
plink: gh_label.yaml
options:
    - option: color
      shorthand: c
      value_type: string
DOCS
gh_label_edit.md:24Markdown · 4 words
TESTS
pkg/cmd/label/edit_test.go:16pkg/cmd/label/edit_test::TestNewCmdEdit · Go · 74 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  editOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "cannot update label: name argument required",
		},
		{
			name:    "name argument",
			input:   "test",
			wantErr: true,
			errMsg:  "specify at least one of `--color`, `--description`, or `--name`",
		},
		{
			name:   "description flag",
			input:  "test --description 'some description'",
			output: editOptions{Name: "test", Description: "some description"},
		},
		{
			name:   "color flag",
			input:  "test --color FFFFFF",
			output: editOptions{Name: "test", Color: "FFFFFF"},
		},
+ 44 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label edit
short: Update a label on GitHub.
long: |-
    A label can be renamed using the `--name` flag.

    The label color needs to be 6 character hex value.
pname: gh label
plink: gh_label.yaml
options:
    - option: color
      shorthand: c
      value_type: string
DOCS
gh_label_edit.md:25Markdown · 4 words
TESTS
pkg/cmd/label/edit_test.go:16pkg/cmd/label/edit_test::TestNewCmdEdit · Go · 74 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  editOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "cannot update label: name argument required",
		},
		{
			name:    "name argument",
			input:   "test",
			wantErr: true,
			errMsg:  "specify at least one of `--color`, `--description`, or `--name`",
		},
		{
			name:   "description flag",
			input:  "test --description 'some description'",
			output: editOptions{Name: "test", Description: "some description"},
		},
		{
			name:   "color flag",
			input:  "test --color FFFFFF",
			output: editOptions{Name: "test", Color: "FFFFFF"},
		},
+ 44 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label edit
short: Update a label on GitHub.
long: |-
    A label can be renamed using the `--name` flag.

    The label color needs to be 6 character hex value.
pname: gh label
plink: gh_label.yaml
options:
    - option: color
      shorthand: c
      value_type: string
DOCS
gh_label_edit.md:26Markdown · 5 words
TESTS
pkg/cmd/label/edit_test.go:16pkg/cmd/label/edit_test::TestNewCmdEdit · Go · 74 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  editOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "cannot update label: name argument required",
		},
		{
			name:    "name argument",
			input:   "test",
			wantErr: true,
			errMsg:  "specify at least one of `--color`, `--description`, or `--name`",
		},
		{
			name:   "description flag",
			input:  "test --description 'some description'",
			output: editOptions{Name: "test", Description: "some description"},
		},
		{
			name:   "color flag",
			input:  "test --color FFFFFF",
			output: editOptions{Name: "test", Color: "FFFFFF"},
		},
+ 44 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label list
short: Display labels in a GitHub repository.
long: |-
    When using the `--search` flag results are sorted by best match of the query.
    This behavior cannot be configured with the `--order` or `--sort` flags.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh label
plink: gh_label.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_label_list.md:1Markdown · 60 words
TESTS
pkg/cmd/label/list_test.go:18pkg/cmd/label/list_test::TestNewCmdList · Go · 152 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  listOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:   "no argument",
			input:  "",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}},
		},
		{
			name:   "limit flag",
			input:  "--limit 10",
			output: listOptions{Query: listQueryOptions{Limit: 10, Order: "asc", Sort: "created"}},
		},
		{
			name:    "invalid limit flag",
			input:   "--limit 0",
			wantErr: true,
			errMsg:  "invalid limit: 0",
		},
		{
			name:   "web flag",
			input:  "--web",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}, WebMode: true},
		},
		{
+ 122 more lines · read full file
pkg/cmd/label/list_test.go:171pkg/cmd/label/list_test::TestListRun · Go · 223 lines
func TestListRun(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		opts       *listOptions
		httpStubs  func(*httpmock.Registry)
		wantErr    bool
		wantErrMsg string
		wantStdout string
		wantStderr string
	}{
		{
			name: "lists labels",
			tty:  true,
			opts: &listOptions{},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query LabelList\b`),
					httpmock.StringResponse(`
						{
							"data": {
								"repository": {
									"labels": {
										"totalCount": 2,
										"nodes": [
											{
												"name": "bug",
												"color": "d73a4a",
												"description": "This is a bug label"
											},
+ 193 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label list
short: Display labels in a GitHub repository.
long: |-
    When using the `--search` flag results are sorted by best match of the query.
    This behavior cannot be configured with the `--order` or `--sort` flags.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh label
plink: gh_label.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_label_list.md:23Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh label list
short: Display labels in a GitHub repository.
long: |-
    When using the `--search` flag results are sorted by best match of the query.
    This behavior cannot be configured with the `--order` or `--sort` flags.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh label
plink: gh_label.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_label_list.md:24Markdown · 6 words
TESTS
pkg/cmd/label/list_test.go:18pkg/cmd/label/list_test::TestNewCmdList · Go · 152 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  listOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:   "no argument",
			input:  "",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}},
		},
		{
			name:   "limit flag",
			input:  "--limit 10",
			output: listOptions{Query: listQueryOptions{Limit: 10, Order: "asc", Sort: "created"}},
		},
		{
			name:    "invalid limit flag",
			input:   "--limit 0",
			wantErr: true,
			errMsg:  "invalid limit: 0",
		},
		{
			name:   "web flag",
			input:  "--web",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}, WebMode: true},
		},
		{
+ 122 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh label list
short: Display labels in a GitHub repository.
long: |-
    When using the `--search` flag results are sorted by best match of the query.
    This behavior cannot be configured with the `--order` or `--sort` flags.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh label
plink: gh_label.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_label_list.md:25Markdown · 6 words
TESTS
pkg/cmd/label/list_test.go:18pkg/cmd/label/list_test::TestNewCmdList · Go · 152 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  listOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:   "no argument",
			input:  "",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}},
		},
		{
			name:   "limit flag",
			input:  "--limit 10",
			output: listOptions{Query: listQueryOptions{Limit: 10, Order: "asc", Sort: "created"}},
		},
		{
			name:    "invalid limit flag",
			input:   "--limit 0",
			wantErr: true,
			errMsg:  "invalid limit: 0",
		},
		{
			name:   "web flag",
			input:  "--web",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}, WebMode: true},
		},
		{
+ 122 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh label list
short: Display labels in a GitHub repository.
long: |-
    When using the `--search` flag results are sorted by best match of the query.
    This behavior cannot be configured with the `--order` or `--sort` flags.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh label
plink: gh_label.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_label_list.md:26Markdown · 5 words
TESTS
pkg/cmd/label/list_test.go:18pkg/cmd/label/list_test::TestNewCmdList · Go · 152 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  listOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:   "no argument",
			input:  "",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}},
		},
		{
			name:   "limit flag",
			input:  "--limit 10",
			output: listOptions{Query: listQueryOptions{Limit: 10, Order: "asc", Sort: "created"}},
		},
		{
			name:    "invalid limit flag",
			input:   "--limit 0",
			wantErr: true,
			errMsg:  "invalid limit: 0",
		},
		{
			name:   "web flag",
			input:  "--web",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}, WebMode: true},
		},
		{
+ 122 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh label list
short: Display labels in a GitHub repository.
long: |-
    When using the `--search` flag results are sorted by best match of the query.
    This behavior cannot be configured with the `--order` or `--sort` flags.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh label
plink: gh_label.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_label_list.md:27Markdown · 5 words
TESTS
pkg/cmd/label/list_test.go:18pkg/cmd/label/list_test::TestNewCmdList · Go · 152 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  listOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:   "no argument",
			input:  "",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}},
		},
		{
			name:   "limit flag",
			input:  "--limit 10",
			output: listOptions{Query: listQueryOptions{Limit: 10, Order: "asc", Sort: "created"}},
		},
		{
			name:    "invalid limit flag",
			input:   "--limit 0",
			wantErr: true,
			errMsg:  "invalid limit: 0",
		},
		{
			name:   "web flag",
			input:  "--web",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}, WebMode: true},
		},
		{
+ 122 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label list
short: Display labels in a GitHub repository.
long: |-
    When using the `--search` flag results are sorted by best match of the query.
    This behavior cannot be configured with the `--order` or `--sort` flags.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh label
plink: gh_label.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_label_list.md:28Markdown · 4 words
TESTS
pkg/cmd/label/list_test.go:18pkg/cmd/label/list_test::TestNewCmdList · Go · 152 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  listOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:   "no argument",
			input:  "",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}},
		},
		{
			name:   "limit flag",
			input:  "--limit 10",
			output: listOptions{Query: listQueryOptions{Limit: 10, Order: "asc", Sort: "created"}},
		},
		{
			name:    "invalid limit flag",
			input:   "--limit 0",
			wantErr: true,
			errMsg:  "invalid limit: 0",
		},
		{
			name:   "web flag",
			input:  "--web",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}, WebMode: true},
		},
		{
+ 122 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh label list
short: Display labels in a GitHub repository.
long: |-
    When using the `--search` flag results are sorted by best match of the query.
    This behavior cannot be configured with the `--order` or `--sort` flags.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh label
plink: gh_label.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_label_list.md:29Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh label list
short: Display labels in a GitHub repository.
long: |-
    When using the `--search` flag results are sorted by best match of the query.
    This behavior cannot be configured with the `--order` or `--sort` flags.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh label
plink: gh_label.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_label_list.md:30Markdown · 6 words
TESTS
pkg/cmd/label/list_test.go:18pkg/cmd/label/list_test::TestNewCmdList · Go · 152 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  listOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:   "no argument",
			input:  "",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}},
		},
		{
			name:   "limit flag",
			input:  "--limit 10",
			output: listOptions{Query: listQueryOptions{Limit: 10, Order: "asc", Sort: "created"}},
		},
		{
			name:    "invalid limit flag",
			input:   "--limit 0",
			wantErr: true,
			errMsg:  "invalid limit: 0",
		},
		{
			name:   "web flag",
			input:  "--web",
			output: listOptions{Query: listQueryOptions{Limit: 30, Order: "asc", Sort: "created"}, WebMode: true},
		},
		{
+ 122 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh licenses
short: View license information for third-party libraries used in this build of the GitHub CLI.
pname: gh
plink: gh.yaml
DOCS
gh_licenses.md:1Markdown · 20 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh org
short: Work with GitHub organizations.
pname: gh
plink: gh.yaml
DOCS
gh_org.md:1Markdown · 17 words
TESTS

N/A

EXAMPLES
gh_org.md:18Markdown
WORKFLOWS

N/A

CONTRACT
command: gh org list
short: List organizations for the authenticated user.
pname: gh org
plink: gh_org.yaml
options:
    - option: limit
      shorthand: L
      value_type: int
      description: Maximum number of organizations to list (default 30)
DOCS
gh_org_list.md:1Markdown · 20 words
TESTS
pkg/cmd/org/list/list_test.go:18pkg/cmd/org/list/list_test::TestNewCmdList · Go · 61 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ListOptions{
				Limit: 30,
			},
		},
		{
			name: "with limit",
			cli:  "-L 101",
			wants: ListOptions{
				Limit: 101,
			},
		},
		{
			name:     "too many arguments",
			cli:      "123 456",
			wantsErr: "accepts at most 1 arg(s), received 2",
		},
		{
			name:     "invalid limit",
			cli:      "-L 0",
			wantsErr: "invalid limit: 0",
+ 31 more lines · read full file
pkg/cmd/org/list/list_test.go:80pkg/cmd/org/list/list_test::TestListRun · Go · 159 lines
func TestListRun(t *testing.T) {
	tests := []struct {
		name    string
		opts    ListOptions
		isTTY   bool
		wantOut string
	}{
		{
			name: "no organizations found",
			opts: ListOptions{HttpClient: func() (*http.Client, error) {
				r := &httpmock.Registry{}

				r.Register(
					httpmock.GraphQL(`query UserCurrent\b`),
					httpmock.StringResponse(`{"data": {"viewer": {"login": "octocat"}}}`))

				r.Register(
					httpmock.GraphQL(`query OrganizationList\b`),
					httpmock.StringResponse(`
						{ "data": { "user": {
							"organizations": { "nodes": [], "totalCount": 0 }
						} } }`,
					),
				)

				return &http.Client{Transport: r}, nil
			}},
			isTTY: true,
			wantOut: heredoc.Doc(`
+ 130 more lines · read full file
pkg/cmd/project/list/list_test.go:470pkg/cmd/project/list/list_test::TestRunListOrg · Go · 78 lines
func TestRunListOrg(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// get org ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "github",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"organization": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"user"},
				},
			},
		})

	gock.New("https://api.github.com").
+ 48 more lines · read full file
+ 1 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh org list
short: List organizations for the authenticated user.
pname: gh org
plink: gh_org.yaml
options:
    - option: limit
      shorthand: L
      value_type: int
      description: Maximum number of organizations to list (default 30)
DOCS
gh_org_list.md:19Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr
short: Work with GitHub pull requests.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
TESTS

N/A

EXAMPLES
gh_pr.md:48Markdown
CONTRACT
command: gh pr
short: Work with GitHub pull requests.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_pr.md:41Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr checkout
short: Check out a pull request in git
pname: gh pr
plink: gh_pr.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Local branch name to use (default [the name of the head branch])
TESTS
pkg/cmd/pr/checkout/checkout_test.go:29pkg/cmd/pr/checkout/checkout_test::TestNewCmdCheckout · Go · 77 lines
func TestNewCmdCheckout(t *testing.T) {
	tests := []struct {
		name      string
		args      string
		wantsOpts CheckoutOptions
		wantErr   error
	}{
		{
			name: "recurse submodules",
			args: "--recurse-submodules 123",
			wantsOpts: CheckoutOptions{
				RecurseSubmodules: true,
			},
		},
		{
			name: "force",
			args: "--force 123",
			wantsOpts: CheckoutOptions{
				Force: true,
			},
		},
		{
			name: "detach",
			args: "--detach 123",
			wantsOpts: CheckoutOptions{
				Detach: true,
			},
		},
		{
			name: "branch",
+ 47 more lines · read full file
pkg/cmd/pr/checkout/checkout_test.go:166pkg/cmd/pr/checkout/checkout_test::Test_checkoutRun · Go · 198 lines
func Test_checkoutRun(t *testing.T) {
	tests := []struct {
		name string
		opts *CheckoutOptions

		httpStubs   func(*httpmock.Registry)
		runStubs    func(*run.CommandStubber)
		promptStubs func(*prompter.MockPrompter)

		remotes    map[string]string
		wantStdout string
		wantStderr string
		wantErr    bool
		errMsg     string
	}{
		{
			name: "checkout with ssh remote URL",
			opts: &CheckoutOptions{
				PRResolver: func() PRResolver {
					baseRepo, pr := stubPR("OWNER/REPO:master", "OWNER/REPO:feature")
					return &stubPRResolver{
						pr:       pr,
						baseRepo: baseRepo,
					}
				}(),
				Config: func() (gh.Config, error) {
					return config.NewBlankConfig(), nil
				},
				Branch: func() (string, error) {
					return "main", nil
+ 168 more lines · read full file
pkg/cmd/pr/checkout/checkout_test.go:365pkg/cmd/pr/checkout/checkout_test::TestSpecificPRResolver · Go · 34 lines
func TestSpecificPRResolver(t *testing.T) {
	t.Run("when the PR Finder returns results, those are returned", func(t *testing.T) {
		t.Parallel()

		baseRepo, pr := stubPR("OWNER/REPO:master", "OWNER/REPO:feature")
		mockFinder := shared.NewMockFinder("123", pr, baseRepo)
		mockFinder.ExpectFields([]string{"number", "headRefName", "headRepository", "headRepositoryOwner", "isCrossRepository", "maintainerCanModify"})

		resolver := &specificPRResolver{
			prFinder: mockFinder,
			selector: "123",
		}

		resolvedPR, resolvedBaseRepo, err := resolver.Resolve()
		require.NoError(t, err)
		require.Equal(t, pr, resolvedPR)
		require.True(t, ghrepo.IsSame(baseRepo, resolvedBaseRepo), "expected repos to be the same")
	})

	t.Run("when the PR Finder errors, that error is returned", func(t *testing.T) {
		t.Parallel()

		mockFinder := shared.NewMockFinder("123", nil, nil)

		resolver := &specificPRResolver{
			prFinder: mockFinder,
			selector: "123",
		}

		_, _, err := resolver.Resolve()
+ 4 more lines · read full file
+ 18 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr checkout
short: Check out a pull request in git
pname: gh pr
plink: gh_pr.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Local branch name to use (default [the name of the head branch])
DOCS
gh_pr_checkout.md:19Markdown · 12 words
TESTS
pkg/cmd/pr/checkout/checkout_test.go:29pkg/cmd/pr/checkout/checkout_test::TestNewCmdCheckout · Go · 77 lines
func TestNewCmdCheckout(t *testing.T) {
	tests := []struct {
		name      string
		args      string
		wantsOpts CheckoutOptions
		wantErr   error
	}{
		{
			name: "recurse submodules",
			args: "--recurse-submodules 123",
			wantsOpts: CheckoutOptions{
				RecurseSubmodules: true,
			},
		},
		{
			name: "force",
			args: "--force 123",
			wantsOpts: CheckoutOptions{
				Force: true,
			},
		},
		{
			name: "detach",
			args: "--detach 123",
			wantsOpts: CheckoutOptions{
				Detach: true,
			},
		},
		{
			name: "branch",
+ 47 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr checkout
short: Check out a pull request in git
pname: gh pr
plink: gh_pr.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Local branch name to use (default [the name of the head branch])
DOCS
gh_pr_checkout.md:20Markdown · 6 words
TESTS
pkg/cmd/pr/checkout/checkout_test.go:29pkg/cmd/pr/checkout/checkout_test::TestNewCmdCheckout · Go · 77 lines
func TestNewCmdCheckout(t *testing.T) {
	tests := []struct {
		name      string
		args      string
		wantsOpts CheckoutOptions
		wantErr   error
	}{
		{
			name: "recurse submodules",
			args: "--recurse-submodules 123",
			wantsOpts: CheckoutOptions{
				RecurseSubmodules: true,
			},
		},
		{
			name: "force",
			args: "--force 123",
			wantsOpts: CheckoutOptions{
				Force: true,
			},
		},
		{
			name: "detach",
			args: "--detach 123",
			wantsOpts: CheckoutOptions{
				Detach: true,
			},
		},
		{
			name: "branch",
+ 47 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr checkout
short: Check out a pull request in git
pname: gh pr
plink: gh_pr.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Local branch name to use (default [the name of the head branch])
DOCS
gh_pr_checkout.md:21Markdown · 13 words
TESTS
pkg/cmd/pr/checkout/checkout_test.go:29pkg/cmd/pr/checkout/checkout_test::TestNewCmdCheckout · Go · 77 lines
func TestNewCmdCheckout(t *testing.T) {
	tests := []struct {
		name      string
		args      string
		wantsOpts CheckoutOptions
		wantErr   error
	}{
		{
			name: "recurse submodules",
			args: "--recurse-submodules 123",
			wantsOpts: CheckoutOptions{
				RecurseSubmodules: true,
			},
		},
		{
			name: "force",
			args: "--force 123",
			wantsOpts: CheckoutOptions{
				Force: true,
			},
		},
		{
			name: "detach",
			args: "--detach 123",
			wantsOpts: CheckoutOptions{
				Detach: true,
			},
		},
		{
			name: "branch",
+ 47 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr checkout
short: Check out a pull request in git
pname: gh pr
plink: gh_pr.yaml
options:
    - option: branch
      shorthand: b
      value_type: string
      description: Local branch name to use (default [the name of the head branch])
DOCS
gh_pr_checkout.md:22Markdown · 5 words
TESTS
pkg/cmd/pr/checkout/checkout_test.go:29pkg/cmd/pr/checkout/checkout_test::TestNewCmdCheckout · Go · 77 lines
func TestNewCmdCheckout(t *testing.T) {
	tests := []struct {
		name      string
		args      string
		wantsOpts CheckoutOptions
		wantErr   error
	}{
		{
			name: "recurse submodules",
			args: "--recurse-submodules 123",
			wantsOpts: CheckoutOptions{
				RecurseSubmodules: true,
			},
		},
		{
			name: "force",
			args: "--force 123",
			wantsOpts: CheckoutOptions{
				Force: true,
			},
		},
		{
			name: "detach",
			args: "--detach 123",
			wantsOpts: CheckoutOptions{
				Detach: true,
			},
		},
		{
			name: "branch",
+ 47 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr checks
short: Show CI status for a single pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When the `--json` flag is used, it includes a `bucket` field, which categorizes
    the `state` field into `pass`, `fail`, `pending`, `skipping`, or `cancel`.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: fail-fast
DOCS
gh_pr_checks.md:1Markdown · 76 words
TESTS
pkg/cmd/pr/checks/checks_test.go:24pkg/cmd/pr/checks/checks_test::TestNewCmdChecks · Go · 106 lines
func TestNewCmdChecks(t *testing.T) {
	tests := []struct {
		name       string
		cli        string
		wants      ChecksOptions
		wantsError string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ChecksOptions{
				Interval: time.Duration(10000000000),
			},
		},
		{
			name: "pr argument",
			cli:  "1234",
			wants: ChecksOptions{
				SelectorArg: "1234",
				Interval:    time.Duration(10000000000),
			},
		},
		{
			name: "watch flag",
			cli:  "--watch",
			wants: ChecksOptions{
				Watch:    true,
				Interval: time.Duration(10000000000),
			},
		},
+ 76 more lines · read full file
pkg/cmd/pr/checks/checks_test.go:131pkg/cmd/pr/checks/checks_test::Test_checksRun · Go · 487 lines
func Test_checksRun(t *testing.T) {
	tests := []struct {
		name            string
		tty             bool
		watch           bool
		failFast        bool
		required        bool
		disableDetector bool
		httpStubs       func(*httpmock.Registry)
		wantOut         string
		wantErr         string
	}{
		{
			name: "no commits tty",
			tty:  true,
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query PullRequestStatusChecks\b`),
					httpmock.StringResponse(`{"data":{"node":{}}}`),
				)
			},
			wantOut: "",
			wantErr: "no commit found on the pull request",
		},
		{
			name: "no checks tty",
			tty:  true,
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query PullRequestStatusChecks\b`),
+ 457 more lines · read full file
pkg/cmd/pr/checks/checks_test.go:619pkg/cmd/pr/checks/checks_test::TestChecksRun_web · Go · 49 lines
func TestChecksRun_web(t *testing.T) {
	tests := []struct {
		name       string
		isTTY      bool
		wantStderr string
		wantStdout string
		wantBrowse string
	}{
		{
			name:       "tty",
			isTTY:      true,
			wantStderr: "Opening https://github.com/OWNER/REPO/pull/123/checks in your browser.\n",
			wantStdout: "",
			wantBrowse: "https://github.com/OWNER/REPO/pull/123/checks",
		},
		{
			name:       "nontty",
			isTTY:      false,
			wantStderr: "",
			wantStdout: "",
			wantBrowse: "https://github.com/OWNER/REPO/pull/123/checks",
		},
	}
	for _, tc := range tests {
		t.Run(tc.name, func(t *testing.T) {
			browser := &browser.Stub{}

			ios, _, stdout, stderr := iostreams.Test()
			ios.SetStdoutTTY(tc.isTTY)
			ios.SetStdinTTY(tc.isTTY)
+ 19 more lines · read full file
+ 1 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr checks
short: Show CI status for a single pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When the `--json` flag is used, it includes a `bucket` field, which categorizes
    the `state` field into `pass`, `fail`, `pending`, `skipping`, or `cancel`.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: fail-fast
DOCS
gh_pr_checks.md:29Markdown · 7 words
TESTS
pkg/cmd/pr/checks/checks_test.go:24pkg/cmd/pr/checks/checks_test::TestNewCmdChecks · Go · 106 lines
func TestNewCmdChecks(t *testing.T) {
	tests := []struct {
		name       string
		cli        string
		wants      ChecksOptions
		wantsError string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ChecksOptions{
				Interval: time.Duration(10000000000),
			},
		},
		{
			name: "pr argument",
			cli:  "1234",
			wants: ChecksOptions{
				SelectorArg: "1234",
				Interval:    time.Duration(10000000000),
			},
		},
		{
			name: "watch flag",
			cli:  "--watch",
			wants: ChecksOptions{
				Watch:    true,
				Interval: time.Duration(10000000000),
			},
		},
+ 76 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr checks
short: Show CI status for a single pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When the `--json` flag is used, it includes a `bucket` field, which categorizes
    the `state` field into `pass`, `fail`, `pending`, `skipping`, or `cancel`.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: fail-fast
DOCS
gh_pr_checks.md:30Markdown · 7 words
TESTS
pkg/cmd/pr/checks/checks_test.go:24pkg/cmd/pr/checks/checks_test::TestNewCmdChecks · Go · 106 lines
func TestNewCmdChecks(t *testing.T) {
	tests := []struct {
		name       string
		cli        string
		wants      ChecksOptions
		wantsError string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ChecksOptions{
				Interval: time.Duration(10000000000),
			},
		},
		{
			name: "pr argument",
			cli:  "1234",
			wants: ChecksOptions{
				SelectorArg: "1234",
				Interval:    time.Duration(10000000000),
			},
		},
		{
			name: "watch flag",
			cli:  "--watch",
			wants: ChecksOptions{
				Watch:    true,
				Interval: time.Duration(10000000000),
			},
		},
+ 76 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr checks
short: Show CI status for a single pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When the `--json` flag is used, it includes a `bucket` field, which categorizes
    the `state` field into `pass`, `fail`, `pending`, `skipping`, or `cancel`.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: fail-fast
DOCS
gh_pr_checks.md:31Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr checks
short: Show CI status for a single pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When the `--json` flag is used, it includes a `bucket` field, which categorizes
    the `state` field into `pass`, `fail`, `pending`, `skipping`, or `cancel`.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: fail-fast
DOCS
gh_pr_checks.md:32Markdown · 6 words
TESTS
pkg/cmd/pr/checks/checks_test.go:24pkg/cmd/pr/checks/checks_test::TestNewCmdChecks · Go · 106 lines
func TestNewCmdChecks(t *testing.T) {
	tests := []struct {
		name       string
		cli        string
		wants      ChecksOptions
		wantsError string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ChecksOptions{
				Interval: time.Duration(10000000000),
			},
		},
		{
			name: "pr argument",
			cli:  "1234",
			wants: ChecksOptions{
				SelectorArg: "1234",
				Interval:    time.Duration(10000000000),
			},
		},
		{
			name: "watch flag",
			cli:  "--watch",
			wants: ChecksOptions{
				Watch:    true,
				Interval: time.Duration(10000000000),
			},
		},
+ 76 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr checks
short: Show CI status for a single pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When the `--json` flag is used, it includes a `bucket` field, which categorizes
    the `state` field into `pass`, `fail`, `pending`, `skipping`, or `cancel`.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: fail-fast
DOCS
gh_pr_checks.md:33Markdown · 6 words
TESTS
pkg/cmd/pr/checks/checks_test.go:24pkg/cmd/pr/checks/checks_test::TestNewCmdChecks · Go · 106 lines
func TestNewCmdChecks(t *testing.T) {
	tests := []struct {
		name       string
		cli        string
		wants      ChecksOptions
		wantsError string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ChecksOptions{
				Interval: time.Duration(10000000000),
			},
		},
		{
			name: "pr argument",
			cli:  "1234",
			wants: ChecksOptions{
				SelectorArg: "1234",
				Interval:    time.Duration(10000000000),
			},
		},
		{
			name: "watch flag",
			cli:  "--watch",
			wants: ChecksOptions{
				Watch:    true,
				Interval: time.Duration(10000000000),
			},
		},
+ 76 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr checks
short: Show CI status for a single pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When the `--json` flag is used, it includes a `bucket` field, which categorizes
    the `state` field into `pass`, `fail`, `pending`, `skipping`, or `cancel`.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: fail-fast
DOCS
gh_pr_checks.md:34Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr checks
short: Show CI status for a single pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When the `--json` flag is used, it includes a `bucket` field, which categorizes
    the `state` field into `pass`, `fail`, `pending`, `skipping`, or `cancel`.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: fail-fast
DOCS
gh_pr_checks.md:35Markdown · 5 words
TESTS
pkg/cmd/pr/checks/checks_test.go:24pkg/cmd/pr/checks/checks_test::TestNewCmdChecks · Go · 106 lines
func TestNewCmdChecks(t *testing.T) {
	tests := []struct {
		name       string
		cli        string
		wants      ChecksOptions
		wantsError string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ChecksOptions{
				Interval: time.Duration(10000000000),
			},
		},
		{
			name: "pr argument",
			cli:  "1234",
			wants: ChecksOptions{
				SelectorArg: "1234",
				Interval:    time.Duration(10000000000),
			},
		},
		{
			name: "watch flag",
			cli:  "--watch",
			wants: ChecksOptions{
				Watch:    true,
				Interval: time.Duration(10000000000),
			},
		},
+ 76 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr checks
short: Show CI status for a single pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When the `--json` flag is used, it includes a `bucket` field, which categorizes
    the `state` field into `pass`, `fail`, `pending`, `skipping`, or `cancel`.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: fail-fast
DOCS
gh_pr_checks.md:36Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr close
short: Close a pull request
pname: gh pr
plink: gh_pr.yaml
options:
    - option: comment
      shorthand: c
      value_type: string
      description: Leave a closing comment
    - option: delete-branch
      shorthand: d
      value_type: bool
DOCS
gh_pr_close.md:1Markdown · 18 words
TESTS
pkg/cmd/pr/close/close_test.go:98pkg/cmd/pr/close/close_test::TestNoArgs · Go · 8 lines
func TestNoArgs(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	_, err := runCommand(http, true, "")

	assert.EqualError(t, err, "cannot close pull request: number, url, or branch required")
}
pkg/cmd/pr/close/close_test.go:107pkg/cmd/pr/close/close_test::TestPrClose · Go · 21 lines
func TestPrClose(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	baseRepo, pr := stubPR("OWNER/REPO", "OWNER/REPO:feature")
	pr.Title = "The title of the PR"
	shared.StubFinderForRunCommandStyleTests(t, "96", pr, baseRepo)

	http.Register(
		httpmock.GraphQL(`mutation PullRequestClose\b`),
		httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["pullRequestId"], "THE-ID")
			}),
	)

	output, err := runCommand(http, true, "96")
	assert.NoError(t, err)
	assert.Equal(t, "", output.String())
	assert.Equal(t, "✓ Closed pull request OWNER/REPO#96 (The title of the PR)\n", output.Stderr())
}
pkg/cmd/pr/close/close_test.go:129pkg/cmd/pr/close/close_test::TestPrClose_alreadyClosed · Go · 14 lines
func TestPrClose_alreadyClosed(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	baseRepo, pr := stubPR("OWNER/REPO", "OWNER/REPO:feature")
	pr.State = "CLOSED"
	pr.Title = "The title of the PR"
	shared.StubFinderForRunCommandStyleTests(t, "96", pr, baseRepo)

	output, err := runCommand(http, true, "96")
	assert.NoError(t, err)
	assert.Equal(t, "", output.String())
	assert.Equal(t, "! Pull request OWNER/REPO#96 (The title of the PR) is already closed\n", output.Stderr())
}
+ 5 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr close
short: Close a pull request
pname: gh pr
plink: gh_pr.yaml
options:
    - option: comment
      shorthand: c
      value_type: string
      description: Leave a closing comment
    - option: delete-branch
      shorthand: d
      value_type: bool
DOCS
gh_pr_close.md:19Markdown · 4 words
TESTS
pkg/cmd/pr/close/close_test.go:279pkg/cmd/pr/close/close_test::TestPrClose_withComment · Go · 32 lines
func TestPrClose_withComment(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	baseRepo, pr := stubPR("OWNER/REPO", "OWNER/REPO:feature")
	pr.Title = "The title of the PR"
	shared.StubFinderForRunCommandStyleTests(t, "96", pr, baseRepo)

	http.Register(
		httpmock.GraphQL(`mutation CommentCreate\b`),
		httpmock.GraphQLMutation(`
		{ "data": { "addComment": { "commentEdge": { "node": {
			"url": "https://github.com/OWNER/REPO/issues/123#issuecomment-456"
		} } } } }`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, "THE-ID", inputs["subjectId"])
				assert.Equal(t, "closing comment", inputs["body"])
			}),
	)
	http.Register(
		httpmock.GraphQL(`mutation PullRequestClose\b`),
		httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["pullRequestId"], "THE-ID")
			}),
	)

	output, err := runCommand(http, true, "96 --comment 'closing comment'")
	assert.NoError(t, err)
	assert.Equal(t, "", output.String())
+ 2 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr close
short: Close a pull request
pname: gh pr
plink: gh_pr.yaml
options:
    - option: comment
      shorthand: c
      value_type: string
      description: Leave a closing comment
    - option: delete-branch
      shorthand: d
      value_type: bool
DOCS
gh_pr_close.md:20Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr comment
short: Add a comment to a GitHub pull request.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_pr_comment.md:1Markdown · 39 words
TESTS
pkg/cmd/pr/comment/comment_test.go:24pkg/cmd/pr/comment/comment_test::TestNewCmdComment · Go · 297 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:  "no arguments",
			input: "",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
+ 267 more lines · read full file
pkg/cmd/pr/comment/comment_test.go:322pkg/cmd/pr/comment/comment_test::Test_commentRun · Go · 380 lines
func Test_commentRun(t *testing.T) {
	tests := []struct {
		name          string
		input         *shared.CommentableOptions
		emptyComments bool
		comments      api.Comments
		httpStubs     func(*testing.T, *httpmock.Registry)
		stdout        string
		stderr        string
		wantsErr      bool
	}{
		{
			name: "creating new comment with interactive editor succeeds",
			input: &shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",

				InteractiveEditSurvey: func(string) (string, error) { return "comment body", nil },
				ConfirmSubmitSurvey:   func() (bool, error) { return true, nil },
			},
			httpStubs: func(t *testing.T, reg *httpmock.Registry) {
				mockCommentCreate(t, reg)
			},
			stdout: "https://github.com/OWNER/REPO/pull/123#issuecomment-456\n",
		},
		{
			name: "updating last comment with interactive editor fails if there are no comments and decline prompt to create",
			input: &shared.CommentableOptions{
				Interactive: true,
+ 350 more lines · read full file
EXAMPLES
CONTRACT
command: gh pr comment
short: Add a comment to a GitHub pull request.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_pr_comment.md:23Markdown · 4 words
TESTS
pkg/cmd/pr/comment/comment_test.go:24pkg/cmd/pr/comment/comment_test::TestNewCmdComment · Go · 297 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:  "no arguments",
			input: "",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
+ 267 more lines · read full file
EXAMPLES
CONTRACT
command: gh pr comment
short: Add a comment to a GitHub pull request.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_pr_comment.md:24Markdown · 12 words
TESTS
pkg/cmd/pr/comment/comment_test.go:24pkg/cmd/pr/comment/comment_test::TestNewCmdComment · Go · 297 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:  "no arguments",
			input: "",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
+ 267 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr comment
short: Add a comment to a GitHub pull request.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_pr_comment.md:25Markdown · 15 words
TESTS
pkg/cmd/pr/comment/comment_test.go:24pkg/cmd/pr/comment/comment_test::TestNewCmdComment · Go · 297 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:  "no arguments",
			input: "",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
+ 267 more lines · read full file
pkg/cmd/pr/comment/comment_test.go:322pkg/cmd/pr/comment/comment_test::Test_commentRun · Go · 380 lines
func Test_commentRun(t *testing.T) {
	tests := []struct {
		name          string
		input         *shared.CommentableOptions
		emptyComments bool
		comments      api.Comments
		httpStubs     func(*testing.T, *httpmock.Registry)
		stdout        string
		stderr        string
		wantsErr      bool
	}{
		{
			name: "creating new comment with interactive editor succeeds",
			input: &shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",

				InteractiveEditSurvey: func(string) (string, error) { return "comment body", nil },
				ConfirmSubmitSurvey:   func() (bool, error) { return true, nil },
			},
			httpStubs: func(t *testing.T, reg *httpmock.Registry) {
				mockCommentCreate(t, reg)
			},
			stdout: "https://github.com/OWNER/REPO/pull/123#issuecomment-456\n",
		},
		{
			name: "updating last comment with interactive editor fails if there are no comments and decline prompt to create",
			input: &shared.CommentableOptions{
				Interactive: true,
+ 350 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr comment
short: Add a comment to a GitHub pull request.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_pr_comment.md:26Markdown · 8 words
TESTS
pkg/cmd/pr/comment/comment_test.go:24pkg/cmd/pr/comment/comment_test::TestNewCmdComment · Go · 297 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:  "no arguments",
			input: "",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
+ 267 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr comment
short: Add a comment to a GitHub pull request.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_pr_comment.md:27Markdown · 8 words
TESTS
pkg/cmd/pr/comment/comment_test.go:24pkg/cmd/pr/comment/comment_test::TestNewCmdComment · Go · 297 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:  "no arguments",
			input: "",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
+ 267 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr comment
short: Add a comment to a GitHub pull request.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_pr_comment.md:28Markdown · 12 words
TESTS
pkg/cmd/pr/comment/comment_test.go:24pkg/cmd/pr/comment/comment_test::TestNewCmdComment · Go · 297 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:  "no arguments",
			input: "",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
+ 267 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr comment
short: Add a comment to a GitHub pull request.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_pr_comment.md:29Markdown · 8 words
TESTS
pkg/cmd/pr/comment/comment_test.go:24pkg/cmd/pr/comment/comment_test::TestNewCmdComment · Go · 297 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:  "no arguments",
			input: "",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
+ 267 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr comment
short: Add a comment to a GitHub pull request.
long: |-
    Without the body text supplied through flags, the command will interactively
    prompt for the comment text.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The comment body text
DOCS
gh_pr_comment.md:30Markdown · 9 words
TESTS
pkg/cmd/pr/comment/comment_test.go:24pkg/cmd/pr/comment/comment_test::TestNewCmdComment · Go · 297 lines
func TestNewCmdComment(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name     string
		input    string
		stdin    string
		output   shared.CommentableOptions
		wantsErr bool
		isTTY    bool
	}{
		{
			name:  "no arguments",
			input: "",
			output: shared.CommentableOptions{
				Interactive: true,
				InputType:   0,
				Body:        "",
			},
			isTTY:    true,
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   shared.CommentableOptions{},
			isTTY:    true,
			wantsErr: true,
+ 267 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
TESTS
pkg/cmd/pr/create/create_test.go:33pkg/cmd/pr/create/create_test::TestNewCmdCreate · Go · 299 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "--title mytitle",
			wantsErr: true,
		},
		{
			name:     "minimum non-tty",
			tty:      false,
			cli:      "--title mytitle --body ''",
+ 269 more lines · read full file
pkg/cmd/pr/create/create_test.go:333pkg/cmd/pr/create/create_test::Test_createRun · Go · 1329 lines
func Test_createRun(t *testing.T) {
	tests := []struct {
		name               string
		setup              func(*CreateOptions, *testing.T) func()
		cmdStubs           func(*run.CommandStubber)
		promptStubs        func(*prompter.PrompterMock)
		httpStubs          func(*httpmock.Registry, *testing.T)
		expectedOutputs    []string
		expectedOut        string
		expectedErrOut     string
		expectedBrowse     string
		wantErr            string
		tty                bool
		customBranchConfig bool
	}{
		{
			name: "nontty web",
			setup: func(opts *CreateOptions, t *testing.T) func() {
				opts.WebMode = true
				opts.HeadBranch = "feature"
				return func() {}
			},
			cmdStubs: func(cs *run.CommandStubber) {
				cs.Register(`git( .+)? log( .+)? origin/master\.\.\.feature`, 0, "")
			},
			expectedBrowse: "https://github.com/OWNER/REPO/compare/master...feature?body=&expand=1",
		},
		{
			name: "nontty",
			httpStubs: func(reg *httpmock.Registry, t *testing.T) {
+ 1299 more lines · read full file
pkg/cmd/pr/create/create_test.go:1663pkg/cmd/pr/create/create_test::Test_createRun_GHES · Go · 518 lines
func Test_createRun_GHES(t *testing.T) {
	tests := []struct {
		name               string
		setup              func(*CreateOptions, *testing.T) func()
		cmdStubs           func(*run.CommandStubber)
		promptStubs        func(*prompter.PrompterMock)
		httpStubs          func(*httpmock.Registry, *testing.T)
		expectedOutputs    []string
		expectedOut        string
		expectedErrOut     string
		tty                bool
		customBranchConfig bool
	}{
		{
			name: "dry-run-nontty-with-all-opts",
			tty:  false,
			setup: func(opts *CreateOptions, t *testing.T) func() {
				opts.TitleProvided = true
				opts.BodyProvided = true
				opts.Title = "TITLE"
				opts.Body = "BODY"
				opts.BaseBranch = "trunk"
				opts.HeadBranch = "feature"
				opts.Assignees = []string{"monalisa"}
				opts.Labels = []string{"bug", "todo"}
				opts.Reviewers = []string{"hubot", "monalisa", "OWNER/core", "OWNER/robots"}
				opts.Milestone = "big one.oh"
				opts.DryRun = true
				return func() {}
			},
+ 488 more lines · read full file
+ 10 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
TESTS
pkg/cmd/pr/create/create_test.go:33pkg/cmd/pr/create/create_test::TestNewCmdCreate · Go · 299 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "--title mytitle",
			wantsErr: true,
		},
		{
			name:     "minimum non-tty",
			tty:      false,
			cli:      "--title mytitle --body ''",
+ 269 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
TESTS
pkg/cmd/pr/create/create_test.go:33pkg/cmd/pr/create/create_test::TestNewCmdCreate · Go · 299 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "--title mytitle",
			wantsErr: true,
		},
		{
			name:     "minimum non-tty",
			tty:      false,
			cli:      "--title mytitle --body ''",
+ 269 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
DOCS
gh_pr_create.md:55Markdown · 12 words
TESTS
pkg/cmd/pr/create/create_test.go:33pkg/cmd/pr/create/create_test::TestNewCmdCreate · Go · 299 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "--title mytitle",
			wantsErr: true,
		},
		{
			name:     "minimum non-tty",
			tty:      false,
			cli:      "--title mytitle --body ''",
+ 269 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
DOCS
gh_pr_create.md:57Markdown · 12 words
TESTS
pkg/cmd/pr/create/create_test.go:33pkg/cmd/pr/create/create_test::TestNewCmdCreate · Go · 299 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "--title mytitle",
			wantsErr: true,
		},
		{
			name:     "minimum non-tty",
			tty:      false,
			cli:      "--title mytitle --body ''",
+ 269 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
DOCS
gh_pr_create.md:58Markdown · 27 words
TESTS
pkg/cmd/pr/create/create_test.go:33pkg/cmd/pr/create/create_test::TestNewCmdCreate · Go · 299 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "--title mytitle",
			wantsErr: true,
		},
		{
			name:     "minimum non-tty",
			tty:      false,
			cli:      "--title mytitle --body ''",
+ 269 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
DOCS
gh_pr_create.md:59Markdown · 7 words
TESTS
pkg/cmd/pr/create/create_test.go:33pkg/cmd/pr/create/create_test::TestNewCmdCreate · Go · 299 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "--title mytitle",
			wantsErr: true,
		},
		{
			name:     "minimum non-tty",
			tty:      false,
			cli:      "--title mytitle --body ''",
+ 269 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
DOCS
gh_pr_create.md:60Markdown · 8 words
TESTS
pkg/cmd/pr/create/create_test.go:33pkg/cmd/pr/create/create_test::TestNewCmdCreate · Go · 299 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "--title mytitle",
			wantsErr: true,
		},
		{
			name:     "minimum non-tty",
			tty:      false,
			cli:      "--title mytitle --body ''",
+ 269 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
DOCS
gh_pr_create.md:61Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
TESTS
pkg/cmd/pr/create/create_test.go:333pkg/cmd/pr/create/create_test::Test_createRun · Go · 1329 lines
func Test_createRun(t *testing.T) {
	tests := []struct {
		name               string
		setup              func(*CreateOptions, *testing.T) func()
		cmdStubs           func(*run.CommandStubber)
		promptStubs        func(*prompter.PrompterMock)
		httpStubs          func(*httpmock.Registry, *testing.T)
		expectedOutputs    []string
		expectedOut        string
		expectedErrOut     string
		expectedBrowse     string
		wantErr            string
		tty                bool
		customBranchConfig bool
	}{
		{
			name: "nontty web",
			setup: func(opts *CreateOptions, t *testing.T) func() {
				opts.WebMode = true
				opts.HeadBranch = "feature"
				return func() {}
			},
			cmdStubs: func(cs *run.CommandStubber) {
				cs.Register(`git( .+)? log( .+)? origin/master\.\.\.feature`, 0, "")
			},
			expectedBrowse: "https://github.com/OWNER/REPO/compare/master...feature?body=&expand=1",
		},
		{
			name: "nontty",
			httpStubs: func(reg *httpmock.Registry, t *testing.T) {
+ 1299 more lines · read full file
pkg/cmd/pr/create/create_test.go:2269pkg/cmd/pr/create/create_test::TestNoRepoCanBeDetermined · Go · 66 lines
func TestNoRepoCanBeDetermined(t *testing.T) {
	// Given no head repo can be determined from git config
	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	cs.Register(`git status --porcelain`, 0, "")
	cs.Register(`git config --get-regexp \^branch\\\..+\\\.\(remote\|merge\|pushremote\|gh-merge-base\)\$`, 0, "")
	cs.Register(`git rev-parse --symbolic-full-name feature@{push}`, 1, "")
	cs.Register("git config remote.pushDefault", 1, "")
	cs.Register("git config push.default", 1, "")

	// And Given there is no remote on the correct SHA
	cs.Register(`git show-ref --verify -- HEAD refs/remotes/origin/feature`, 0, heredoc.Doc(`
	deadbeef HEAD
	deadb00f refs/remotes/origin/feature`))

	// When the command is run with no TTY
	reg := &httpmock.Registry{}
	reg.StubRepoInfoResponse("OWNER", "REPO", "master")
	defer reg.Verify(t)

	ios, _, _, stderr := iostreams.Test()

	opts := CreateOptions{
		HttpClient: func() (*http.Client, error) {
			return &http.Client{Transport: reg}, nil
		},
		Config: func() (gh.Config, error) {
			return config.NewBlankConfig(), nil
		},
+ 36 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
DOCS
gh_pr_create.md:65Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
DOCS
gh_pr_create.md:67Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
DOCS
gh_pr_create.md:69Markdown · 8 words
TESTS
pkg/cmd/pr/create/create_test.go:33pkg/cmd/pr/create/create_test::TestNewCmdCreate · Go · 299 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "--title mytitle",
			wantsErr: true,
		},
		{
			name:     "minimum non-tty",
			tty:      false,
			cli:      "--title mytitle --body ''",
+ 269 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
TESTS
pkg/cmd/pr/create/create_test.go:33pkg/cmd/pr/create/create_test::TestNewCmdCreate · Go · 299 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "--title mytitle",
			wantsErr: true,
		},
		{
			name:     "minimum non-tty",
			tty:      false,
			cli:      "--title mytitle --body ''",
+ 269 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr create
short: Create a pull request on GitHub.
long: |-
    Upon success, the URL of the created pull request will be printed.

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Any fork created this
    way will only have the default branch of the upstream repository. Use `--head` to
    explicitly skip any forking or pushing behavior.

    `--head` supports `<user>:<branch>` syntax to select a head repo owned by `<user>`.
    Using an organization as the `<user>` is currently not supported.
TESTS
pkg/cmd/pr/create/create_test.go:33pkg/cmd/pr/create/create_test::TestNewCmdCreate · Go · 299 lines
func TestNewCmdCreate(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name      string
		tty       bool
		stdin     string
		cli       string
		config    string
		wantsErr  bool
		wantsOpts CreateOptions
	}{
		{
			name:     "empty non-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "only title non-tty",
			tty:      false,
			cli:      "--title mytitle",
			wantsErr: true,
		},
		{
			name:     "minimum non-tty",
			tty:      false,
			cli:      "--title mytitle --body ''",
+ 269 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr diff
short: View changes in a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    With `--web` flag, open the pull request diff in a web browser instead.

    Use `--exclude` to filter out files matching a glob pattern. The pattern
    uses forward slashes as path separators on all platforms. You can repeat
    the flag to exclude multiple patterns.
pname: gh pr
DOCS
gh_pr_diff.md:1Markdown · 78 words
TESTS
pkg/cmd/pr/diff/diff_test.go:24pkg/cmd/pr/diff/diff_test::Test_NewCmdDiff · Go · 145 lines
func Test_NewCmdDiff(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DiffOptions
		wantErr string
	}{
		{
			name: "name only",
			args: "--name-only",
			want: DiffOptions{
				NameOnly: true,
			},
		},
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: DiffOptions{
				SelectorArg: "123",
				UseColor:    true,
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: DiffOptions{
				SelectorArg: "",
+ 115 more lines · read full file
pkg/cmd/pr/diff/diff_test.go:170pkg/cmd/pr/diff/diff_test::Test_diffRun · Go · 149 lines
func Test_diffRun(t *testing.T) {
	pr := &api.PullRequest{Number: 123, URL: "https://github.com/OWNER/REPO/pull/123"}

	tests := []struct {
		name           string
		opts           DiffOptions
		wantFields     []string
		wantStdout     string
		wantStderr     string
		wantBrowsedURL string
		httpStubs      func(*httpmock.Registry)
	}{
		{
			name: "no color",
			opts: DiffOptions{
				SelectorArg: "123",
				UseColor:    false,
				Patch:       false,
			},
			wantFields: []string{"number"},
			wantStdout: fmt.Sprintf(testDiff, "", "", "", ""),
			httpStubs: func(reg *httpmock.Registry) {
				stubDiffRequest(reg, "application/vnd.github.v3.diff", fmt.Sprintf(testDiff, "", "", "", ""))
			},
		},
		{
			name: "with color",
			opts: DiffOptions{
				SelectorArg: "123",
				UseColor:    true,
+ 119 more lines · read full file
pkg/cmd/pr/diff/diff_test.go:353pkg/cmd/pr/diff/diff_test::Test_colorDiffLines · Go · 42 lines
func Test_colorDiffLines(t *testing.T) {
	inputs := []struct {
		input, output string
	}{
		{
			input:  "",
			output: "",
		},
		{
			input:  "\n",
			output: "\n",
		},
		{
			input:  "foo\nbar\nbaz\n",
			output: "foo\nbar\nbaz\n",
		},
		{
			input:  "foo\nbar\nbaz",
			output: "foo\nbar\nbaz\n",
		},
		{
			input: fmt.Sprintf("+foo\n-b%sr\n+++ baz\n", strings.Repeat("a", 2*lineBufferSize)),
			output: fmt.Sprintf(
				"%[4]s+foo%[2]s\n%[5]s-b%[1]sr%[2]s\n%[3]s+++ baz%[2]s\n",
				strings.Repeat("a", 2*lineBufferSize),
				"\x1b[m",
				"\x1b[1;37m",
				"\x1b[32m",
				"\x1b[31m",
			),
+ 12 more lines · read full file
+ 4 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr diff
short: View changes in a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    With `--web` flag, open the pull request diff in a web browser instead.

    Use `--exclude` to filter out files matching a glob pattern. The pattern
    uses forward slashes as path separators on all platforms. You can repeat
    the flag to exclude multiple patterns.
pname: gh pr
DOCS
gh_pr_diff.md:29Markdown · 6 words
TESTS
pkg/cmd/pr/diff/diff_test.go:24pkg/cmd/pr/diff/diff_test::Test_NewCmdDiff · Go · 145 lines
func Test_NewCmdDiff(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DiffOptions
		wantErr string
	}{
		{
			name: "name only",
			args: "--name-only",
			want: DiffOptions{
				NameOnly: true,
			},
		},
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: DiffOptions{
				SelectorArg: "123",
				UseColor:    true,
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: DiffOptions{
				SelectorArg: "",
+ 115 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr diff
short: View changes in a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    With `--web` flag, open the pull request diff in a web browser instead.

    Use `--exclude` to filter out files matching a glob pattern. The pattern
    uses forward slashes as path separators on all platforms. You can repeat
    the flag to exclude multiple patterns.
pname: gh pr
DOCS
gh_pr_diff.md:30Markdown · 8 words
TESTS
pkg/cmd/pr/diff/diff_test.go:24pkg/cmd/pr/diff/diff_test::Test_NewCmdDiff · Go · 145 lines
func Test_NewCmdDiff(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DiffOptions
		wantErr string
	}{
		{
			name: "name only",
			args: "--name-only",
			want: DiffOptions{
				NameOnly: true,
			},
		},
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: DiffOptions{
				SelectorArg: "123",
				UseColor:    true,
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: DiffOptions{
				SelectorArg: "",
+ 115 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr diff
short: View changes in a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    With `--web` flag, open the pull request diff in a web browser instead.

    Use `--exclude` to filter out files matching a glob pattern. The pattern
    uses forward slashes as path separators on all platforms. You can repeat
    the flag to exclude multiple patterns.
pname: gh pr
DOCS
gh_pr_diff.md:31Markdown · 6 words
TESTS
pkg/cmd/pr/diff/diff_test.go:24pkg/cmd/pr/diff/diff_test::Test_NewCmdDiff · Go · 145 lines
func Test_NewCmdDiff(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DiffOptions
		wantErr string
	}{
		{
			name: "name only",
			args: "--name-only",
			want: DiffOptions{
				NameOnly: true,
			},
		},
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: DiffOptions{
				SelectorArg: "123",
				UseColor:    true,
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: DiffOptions{
				SelectorArg: "",
+ 115 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr diff
short: View changes in a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    With `--web` flag, open the pull request diff in a web browser instead.

    Use `--exclude` to filter out files matching a glob pattern. The pattern
    uses forward slashes as path separators on all platforms. You can repeat
    the flag to exclude multiple patterns.
pname: gh pr
DOCS
gh_pr_diff.md:32Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr diff
short: View changes in a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    With `--web` flag, open the pull request diff in a web browser instead.

    Use `--exclude` to filter out files matching a glob pattern. The pattern
    uses forward slashes as path separators on all platforms. You can repeat
    the flag to exclude multiple patterns.
pname: gh pr
DOCS
gh_pr_diff.md:33Markdown · 8 words
TESTS
pkg/cmd/pr/diff/diff_test.go:24pkg/cmd/pr/diff/diff_test::Test_NewCmdDiff · Go · 145 lines
func Test_NewCmdDiff(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DiffOptions
		wantErr string
	}{
		{
			name: "name only",
			args: "--name-only",
			want: DiffOptions{
				NameOnly: true,
			},
		},
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: DiffOptions{
				SelectorArg: "123",
				UseColor:    true,
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: DiffOptions{
				SelectorArg: "",
+ 115 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:1Markdown · 105 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
pkg/cmd/pr/edit/edit_test.go:354pkg/cmd/pr/edit/edit_test::Test_editRun · Go · 828 lines
func Test_editRun(t *testing.T) {
	tests := []struct {
		name      string
		input     *EditOptions
		httpStubs func(*testing.T, *httpmock.Registry)
		stdout    string
		stderr    string
	}{
		{
			name: "non-interactive",
			input: &EditOptions{
				Detector:    &fd.EnabledDetectorMock{},
				SelectorArg: "123",
				Finder: shared.NewMockFinder("123", &api.PullRequest{
					URL: "https://github.com/OWNER/REPO/pull/123",
				}, ghrepo.New("OWNER", "REPO")),
				Interactive: false,
				Editable: shared.Editable{
					Title: shared.EditableString{
						Value:  "new title",
						Edited: true,
					},
					Body: shared.EditableString{
						Value:  "new body",
						Edited: true,
					},
					Base: shared.EditableString{
						Value:  "base-branch-name",
						Edited: true,
					},
+ 798 more lines · read full file
pkg/cmd/pr/edit/edit_test.go:1400pkg/cmd/pr/edit/edit_test::TestProjectsV1Deprecation · Go · 67 lines
func TestProjectsV1Deprecation(t *testing.T) {
	t.Run("when projects v1 is supported, is included in query", func(t *testing.T) {
		ios, _, _, _ := iostreams.Test()

		reg := &httpmock.Registry{}
		reg.Register(
			httpmock.GraphQL(`projectCards`),
			// Simulate a GraphQL error to early exit the test.
			httpmock.StatusStringResponse(500, ""),
		)

		f := &cmdutil.Factory{
			IOStreams: ios,
			HttpClient: func() (*http.Client, error) {
				return &http.Client{Transport: reg}, nil
			},
		}

		// Ignore the error because we have no way to really stub it without
		// fully stubbing a GQL error structure in the request body.
		_ = editRun(&EditOptions{
			IO: ios,
			HttpClient: func() (*http.Client, error) {
				return &http.Client{Transport: reg}, nil
			},
			Detector: &fd.EnabledDetectorMock{},

			Finder: shared.NewFinder(f),

			SelectorArg: "https://github.com/cli/cli/pull/123",
+ 37 more lines · read full file
+ 2 more tests · open all in source
EXAMPLES
CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:35Markdown · 16 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:36Markdown · 4 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:37Markdown · 8 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:38Markdown · 14 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:39Markdown · 8 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:40Markdown · 4 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:41Markdown · 12 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:42Markdown · 10 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:43Markdown · 16 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:44Markdown · 4 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:45Markdown · 8 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:46Markdown · 8 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:47Markdown · 13 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr edit
short: Edit a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    Editing a pull request's projects requires authorization with the `project` scope.
    To authorize, run `gh auth refresh -s project`.

    The `--add-assignee` and `--remove-assignee` flags both support
    the following special values:
    - `@me`: assign or unassign yourself
DOCS
gh_pr_edit.md:48Markdown · 4 words
TESTS
pkg/cmd/pr/edit/edit_test.go:24pkg/cmd/pr/edit/edit_test::TestNewCmdEdit · Go · 329 lines
func TestNewCmdEdit(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name             string
		input            string
		stdin            string
		output           EditOptions
		expectedBaseRepo ghrepo.Interface
		wantsErr         bool
	}{
		{
			name:  "no argument",
			input: "",
			output: EditOptions{
				SelectorArg: "",
				Interactive: true,
			},
			wantsErr: false,
		},
		{
			name:     "two arguments",
			input:    "1 2",
			output:   EditOptions{},
			wantsErr: true,
		},
		{
			name:  "URL argument",
+ 299 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
TESTS
pkg/cmd/pr/list/list_test.go:77pkg/cmd/pr/list/list_test::TestPRList · Go · 22 lines
func TestPRList(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	http.Register(httpmock.GraphQL(`query PullRequestList\b`), httpmock.FileResponse("./fixtures/prList.json"))

	output, err := runCommand(http, nil, true, "")
	if err != nil {
		t.Fatal(err)
	}

	assert.Equal(t, heredoc.Doc(`

		Showing 3 of 3 open pull requests in OWNER/REPO

		ID   TITLE                  BRANCH         CREATED AT
		#32  New feature            feature        about 3 hours ago
		#29  Fixed bad bug          hubot:bug-fix  about 1 month ago
		#28  Improve documentation  docs           about 2 years ago
	`), output.String())
	assert.Equal(t, ``, output.Stderr())
}
pkg/cmd/pr/list/list_test.go:100pkg/cmd/pr/list/list_test::TestPRList_nontty · Go · 18 lines
func TestPRList_nontty(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	http.Register(httpmock.GraphQL(`query PullRequestList\b`), httpmock.FileResponse("./fixtures/prList.json"))

	output, err := runCommand(http, nil, false, "")
	if err != nil {
		t.Fatal(err)
	}

	assert.Equal(t, "", output.Stderr())

	assert.Equal(t, `32	New feature	feature	DRAFT	2022-08-24T20:01:12Z
29	Fixed bad bug	hubot:bug-fix	OPEN	2022-07-20T19:01:12Z
28	Improve documentation	docs	MERGED	2020-01-26T19:01:12Z
`, output.String())
}
pkg/cmd/pr/list/list_test.go:119pkg/cmd/pr/list/list_test::TestPRList_filtering · Go · 16 lines
func TestPRList_filtering(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	http.Register(
		httpmock.GraphQL(`query PullRequestList\b`),
		httpmock.GraphQLQuery(`{}`, func(_ string, params map[string]interface{}) {
			assert.Equal(t, []interface{}{"OPEN", "CLOSED", "MERGED"}, params["state"].([]interface{}))
		}))

	output, err := runCommand(http, nil, true, `-s all`)
	assert.Error(t, err)

	assert.Equal(t, "", output.String())
	assert.Equal(t, "", output.Stderr())
}
+ 10 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_pr_list.md:27Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_pr_list.md:28Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_pr_list.md:29Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_pr_list.md:30Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_pr_list.md:31Markdown · 4 words
TESTS
pkg/cmd/pr/list/list_test.go:201pkg/cmd/pr/list/list_test::TestPRList_filteringDraft · Go · 36 lines
func TestPRList_filteringDraft(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		expectedQuery string
	}{
		{
			name:          "draft",
			cli:           "--draft",
			expectedQuery: `draft:true repo:OWNER/REPO state:open type:pr`,
		},
		{
			name:          "non-draft",
			cli:           "--draft=false",
			expectedQuery: `draft:false repo:OWNER/REPO state:open type:pr`,
		},
	}

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			http := initFakeHTTP()
			defer http.Verify(t)

			http.Register(
				httpmock.GraphQL(`query PullRequestSearch\b`),
				httpmock.GraphQLQuery(`{}`, func(_ string, params map[string]interface{}) {
					assert.Equal(t, test.expectedQuery, params["q"].(string))
				}))

			// TODO advancedIssueSearchCleanup
+ 6 more lines · read full file
pkg/cmd/pr/list/list_test.go:292pkg/cmd/pr/list/list_test::TestPRList_web · Go · 42 lines
func TestPRList_web(t *testing.T) {
	tests := []struct {
		name               string
		cli                string
		expectedBrowserURL string
	}{
		{
			name:               "filters",
			cli:                "-a peter -l bug -l docs -L 10 -s merged -B trunk",
			expectedBrowserURL: "https://github.com/OWNER/REPO/pulls?q=assignee%3Apeter+base%3Atrunk+is%3Amerged+label%3Abug+label%3Adocs+type%3Apr",
		},
		{
			name:               "draft",
			cli:                "--draft=true",
			expectedBrowserURL: "https://github.com/OWNER/REPO/pulls?q=draft%3Atrue+state%3Aopen+type%3Apr",
		},
		{
			name:               "non-draft",
			cli:                "--draft=0",
			expectedBrowserURL: "https://github.com/OWNER/REPO/pulls?q=draft%3Afalse+state%3Aopen+type%3Apr",
		},
	}

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			http := initFakeHTTP()
			defer http.Verify(t)

			_, cmdTeardown := run.Stub()
			defer cmdTeardown(t)
+ 12 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_pr_list.md:32Markdown · 8 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_pr_list.md:33Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_pr_list.md:35Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_pr_list.md:36Markdown · 6 words
TESTS
pkg/cmd/pr/list/list_test.go:285pkg/cmd/pr/list/list_test::TestPRList_withInvalidLimitFlag · Go · 6 lines
func TestPRList_withInvalidLimitFlag(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)
	_, err := runCommand(http, nil, true, `--limit=0`)
	assert.EqualError(t, err, "invalid value for --limit: 0")
}
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_pr_list.md:38Markdown · 4 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_pr_list.md:39Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr list
short: List pull requests in a GitHub repository. By default, this only lists open PRs.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: assignee
      shorthand: a
      value_type: string
      description: Filter by assignee
DOCS
gh_pr_list.md:40Markdown · 7 words
TESTS
pkg/cmd/pr/list/list_test.go:292pkg/cmd/pr/list/list_test::TestPRList_web · Go · 42 lines
func TestPRList_web(t *testing.T) {
	tests := []struct {
		name               string
		cli                string
		expectedBrowserURL string
	}{
		{
			name:               "filters",
			cli:                "-a peter -l bug -l docs -L 10 -s merged -B trunk",
			expectedBrowserURL: "https://github.com/OWNER/REPO/pulls?q=assignee%3Apeter+base%3Atrunk+is%3Amerged+label%3Abug+label%3Adocs+type%3Apr",
		},
		{
			name:               "draft",
			cli:                "--draft=true",
			expectedBrowserURL: "https://github.com/OWNER/REPO/pulls?q=draft%3Atrue+state%3Aopen+type%3Apr",
		},
		{
			name:               "non-draft",
			cli:                "--draft=0",
			expectedBrowserURL: "https://github.com/OWNER/REPO/pulls?q=draft%3Afalse+state%3Aopen+type%3Apr",
		},
	}

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			http := initFakeHTTP()
			defer http.Verify(t)

			_, cmdTeardown := run.Stub()
			defer cmdTeardown(t)
+ 12 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr lock
short: Lock pull request conversation
pname: gh pr
plink: gh_pr.yaml
options:
    - option: reason
      shorthand: r
      value_type: string
      description: Optional reason for locking conversation (off_topic, resolved, spam, too_heated).
DOCS
gh_pr_lock.md:1Markdown · 18 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr lock
short: Lock pull request conversation
pname: gh pr
plink: gh_pr.yaml
options:
    - option: reason
      shorthand: r
      value_type: string
      description: Optional reason for locking conversation (off_topic, resolved, spam, too_heated).
DOCS
gh_pr_lock.md:19Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
TESTS
pkg/cmd/pr/merge/merge_test.go:33pkg/cmd/pr/merge/merge_test::Test_NewCmdMerge · Go · 202 lines
func Test_NewCmdMerge(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    MergeOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: MergeOptions{
				SelectorArg:             "123",
				DeleteBranch:            false,
				IsDeleteBranchIndicated: false,
				CanDeleteLocalBranch:    true,
				MergeMethod:             PullRequestMergeMethodMerge,
				MergeStrategyEmpty:      true,
				Body:                    "",
				BodySet:                 false,
				AuthorEmail:             "",
			},
		},
		{
+ 172 more lines · read full file
pkg/cmd/pr/merge/merge_test.go:307pkg/cmd/pr/merge/merge_test::TestPrMerge · Go · 40 lines
func TestPrMerge(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"1",
		&api.PullRequest{
			ID:               "THE-ID",
			Number:           1,
			State:            "OPEN",
			Title:            "The title of the PR",
			MergeStateStatus: "CLEAN",
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	http.Register(
		httpmock.GraphQL(`mutation PullRequestMerge\b`),
		httpmock.GraphQLMutation(`{}`, func(input map[string]interface{}) {
			assert.Equal(t, "THE-ID", input["pullRequestId"].(string))
			assert.Equal(t, "MERGE", input["mergeMethod"].(string))
			assert.NotContains(t, input, "commitHeadline")
		}),
	)

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)
	cs.Register(`git rev-parse --verify refs/heads/`, 0, "")

	output, err := runCommand(http, nil, "main", true, "pr merge 1 --merge")
+ 10 more lines · read full file
pkg/cmd/pr/merge/merge_test.go:348pkg/cmd/pr/merge/merge_test::TestPrMerge_blocked · Go · 30 lines
func TestPrMerge_blocked(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"1",
		&api.PullRequest{
			ID:               "THE-ID",
			Number:           1,
			State:            "OPEN",
			Title:            "The title of the PR",
			MergeStateStatus: "BLOCKED",
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)
	cs.Register(`git rev-parse --verify refs/heads/`, 0, "")

	output, err := runCommand(http, nil, "main", true, "pr merge 1 --merge")
	assert.EqualError(t, err, "SilentError")

	assert.Equal(t, "", output.String())
	assert.Equal(t, heredoc.Docf(`
		X Pull request OWNER/REPO#1 is not mergeable: the base branch policy prohibits the merge.
		To have the pull request merged after all the requirements have been met, add the %[1]s--auto%[1]s flag.
		To use administrator privileges to immediately merge the pull request, add the %[1]s--admin%[1]s flag.
		`, "`"), output.Stderr())
}
+ 37 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
DOCS
gh_pr_merge.md:28Markdown · 13 words
TESTS
pkg/cmd/pr/merge/merge_test.go:1925pkg/cmd/pr/merge/merge_test::TestPrAddToMergeQueueAdmin · Go · 68 lines
func TestPrAddToMergeQueueAdmin(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"1",
		&api.PullRequest{
			ID:                  "THE-ID",
			Number:              1,
			State:               "OPEN",
			Title:               "The title of the PR",
			MergeStateStatus:    "CLEAN",
			IsInMergeQueue:      false,
			IsMergeQueueEnabled: true,
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	http.Register(
		httpmock.GraphQL(`query RepositoryInfo\b`),
		httpmock.StringResponse(`
		{ "data": { "repository": {
			"mergeCommitAllowed": true,
			"rebaseMergeAllowed": true,
			"squashMergeAllowed": true
		} } }`))

	http.Register(
		httpmock.GraphQL(`mutation PullRequestMerge\b`),
		httpmock.GraphQLMutation(`{}`, func(input map[string]interface{}) {
+ 38 more lines · read full file
pkg/cmd/pr/merge/merge_test.go:1994pkg/cmd/pr/merge/merge_test::TestPrAddToMergeQueueAdminWithMergeStrategy · Go · 38 lines
func TestPrAddToMergeQueueAdminWithMergeStrategy(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"1",
		&api.PullRequest{
			ID:               "THE-ID",
			Number:           1,
			State:            "OPEN",
			Title:            "The title of the PR",
			MergeStateStatus: "CLEAN",
			IsInMergeQueue:   false,
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	http.Register(
		httpmock.GraphQL(`mutation PullRequestMerge\b`),
		httpmock.GraphQLMutation(`{}`, func(input map[string]interface{}) {
			assert.Equal(t, "THE-ID", input["pullRequestId"].(string))
			assert.Equal(t, "MERGE", input["mergeMethod"].(string))
			assert.NotContains(t, input, "commitHeadline")
		}),
	)

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)
	cs.Register(`git rev-parse --verify refs/heads/`, 0, "")
+ 9 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
DOCS
gh_pr_merge.md:29Markdown · 6 words
TESTS
pkg/cmd/pr/merge/merge_test.go:33pkg/cmd/pr/merge/merge_test::Test_NewCmdMerge · Go · 202 lines
func Test_NewCmdMerge(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    MergeOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: MergeOptions{
				SelectorArg:             "123",
				DeleteBranch:            false,
				IsDeleteBranchIndicated: false,
				CanDeleteLocalBranch:    true,
				MergeMethod:             PullRequestMergeMethodMerge,
				MergeStrategyEmpty:      true,
				Body:                    "",
				BodySet:                 false,
				AuthorEmail:             "",
			},
		},
		{
+ 172 more lines · read full file
pkg/cmd/pr/merge/merge_test.go:570pkg/cmd/pr/merge/merge_test::TestPrMerge_withAuthorFlag · Go · 41 lines
func TestPrMerge_withAuthorFlag(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"1",
		&api.PullRequest{
			ID:               "THE-ID",
			Number:           1,
			State:            "OPEN",
			Title:            "The title of the PR",
			MergeStateStatus: "CLEAN",
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	http.Register(
		httpmock.GraphQL(`mutation PullRequestMerge\b`),
		httpmock.GraphQLMutation(`{}`, func(input map[string]interface{}) {
			assert.Equal(t, "THE-ID", input["pullRequestId"].(string))
			assert.Equal(t, "MERGE", input["mergeMethod"].(string))
			assert.Equal(t, "octocat@github.com", input["authorEmail"].(string))
			assert.NotContains(t, input, "commitHeadline")
		}),
	)

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)
	cs.Register(`git rev-parse --verify refs/heads/`, 0, "")
+ 12 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
DOCS
gh_pr_merge.md:30Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
TESTS
pkg/cmd/pr/merge/merge_test.go:33pkg/cmd/pr/merge/merge_test::Test_NewCmdMerge · Go · 202 lines
func Test_NewCmdMerge(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    MergeOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: MergeOptions{
				SelectorArg:             "123",
				DeleteBranch:            false,
				IsDeleteBranchIndicated: false,
				CanDeleteLocalBranch:    true,
				MergeMethod:             PullRequestMergeMethodMerge,
				MergeStrategyEmpty:      true,
				Body:                    "",
				BodySet:                 false,
				AuthorEmail:             "",
			},
		},
		{
+ 172 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
DOCS
gh_pr_merge.md:32Markdown · 12 words
TESTS
pkg/cmd/pr/merge/merge_test.go:33pkg/cmd/pr/merge/merge_test::Test_NewCmdMerge · Go · 202 lines
func Test_NewCmdMerge(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    MergeOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: MergeOptions{
				SelectorArg:             "123",
				DeleteBranch:            false,
				IsDeleteBranchIndicated: false,
				CanDeleteLocalBranch:    true,
				MergeMethod:             PullRequestMergeMethodMerge,
				MergeStrategyEmpty:      true,
				Body:                    "",
				BodySet:                 false,
				AuthorEmail:             "",
			},
		},
		{
+ 172 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
TESTS
pkg/cmd/pr/merge/merge_test.go:33pkg/cmd/pr/merge/merge_test::Test_NewCmdMerge · Go · 202 lines
func Test_NewCmdMerge(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    MergeOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: MergeOptions{
				SelectorArg:             "123",
				DeleteBranch:            false,
				IsDeleteBranchIndicated: false,
				CanDeleteLocalBranch:    true,
				MergeMethod:             PullRequestMergeMethodMerge,
				MergeStrategyEmpty:      true,
				Body:                    "",
				BodySet:                 false,
				AuthorEmail:             "",
			},
		},
		{
+ 172 more lines · read full file
pkg/cmd/pr/merge/merge_test.go:760pkg/cmd/pr/merge/merge_test::TestPrMerge_deleteBranch_mergeQueue · Go · 22 lines
func TestPrMerge_deleteBranch_mergeQueue(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"",
		&api.PullRequest{
			ID:                  "PR_10",
			Number:              10,
			State:               "OPEN",
			Title:               "Blueberries are a good fruit",
			HeadRefName:         "blueberries",
			BaseRefName:         "main",
			MergeStateStatus:    "CLEAN",
			IsMergeQueueEnabled: true,
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	_, err := runCommand(http, nil, "blueberries", true, `pr merge --merge --delete-branch`)
	assert.Contains(t, err.Error(), "X Cannot use `-d` or `--delete-branch` when merge queue enabled")
}
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
DOCS
gh_pr_merge.md:34Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
DOCS
gh_pr_merge.md:35Markdown · 12 words
TESTS
pkg/cmd/pr/merge/merge_test.go:33pkg/cmd/pr/merge/merge_test::Test_NewCmdMerge · Go · 202 lines
func Test_NewCmdMerge(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    MergeOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: MergeOptions{
				SelectorArg:             "123",
				DeleteBranch:            false,
				IsDeleteBranchIndicated: false,
				CanDeleteLocalBranch:    true,
				MergeMethod:             PullRequestMergeMethodMerge,
				MergeStrategyEmpty:      true,
				Body:                    "",
				BodySet:                 false,
				AuthorEmail:             "",
			},
		},
		{
+ 172 more lines · read full file
pkg/cmd/pr/merge/merge_test.go:529pkg/cmd/pr/merge/merge_test::TestPrMerge_withMatchCommitHeadFlag · Go · 40 lines
func TestPrMerge_withMatchCommitHeadFlag(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"1",
		&api.PullRequest{
			ID:               "THE-ID",
			Number:           1,
			State:            "OPEN",
			Title:            "The title of the PR",
			MergeStateStatus: "CLEAN",
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	http.Register(
		httpmock.GraphQL(`mutation PullRequestMerge\b`),
		httpmock.GraphQLMutation(`{}`, func(input map[string]interface{}) {
			assert.Equal(t, 3, len(input))
			assert.Equal(t, "THE-ID", input["pullRequestId"].(string))
			assert.Equal(t, "MERGE", input["mergeMethod"].(string))
			assert.Equal(t, "285ed5ab740f53ff6b0b4b629c59a9df23b9c6db", input["expectedHeadOid"].(string))
		}))

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)
	cs.Register(`git rev-parse --verify refs/heads/`, 0, "")

	output, err := runCommand(http, nil, "main", true, "pr merge 1 --merge --match-head-commit 285ed5ab740f53ff6b0b4b629c59a9df23b9c6db")
+ 10 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
DOCS
gh_pr_merge.md:36Markdown · 7 words
TESTS
pkg/cmd/pr/merge/merge_test.go:33pkg/cmd/pr/merge/merge_test::Test_NewCmdMerge · Go · 202 lines
func Test_NewCmdMerge(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    MergeOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: MergeOptions{
				SelectorArg:             "123",
				DeleteBranch:            false,
				IsDeleteBranchIndicated: false,
				CanDeleteLocalBranch:    true,
				MergeMethod:             PullRequestMergeMethodMerge,
				MergeStrategyEmpty:      true,
				Body:                    "",
				BodySet:                 false,
				AuthorEmail:             "",
			},
		},
		{
+ 172 more lines · read full file
pkg/cmd/pr/merge/merge_test.go:307pkg/cmd/pr/merge/merge_test::TestPrMerge · Go · 40 lines
func TestPrMerge(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"1",
		&api.PullRequest{
			ID:               "THE-ID",
			Number:           1,
			State:            "OPEN",
			Title:            "The title of the PR",
			MergeStateStatus: "CLEAN",
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	http.Register(
		httpmock.GraphQL(`mutation PullRequestMerge\b`),
		httpmock.GraphQLMutation(`{}`, func(input map[string]interface{}) {
			assert.Equal(t, "THE-ID", input["pullRequestId"].(string))
			assert.Equal(t, "MERGE", input["mergeMethod"].(string))
			assert.NotContains(t, input, "commitHeadline")
		}),
	)

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)
	cs.Register(`git rev-parse --verify refs/heads/`, 0, "")

	output, err := runCommand(http, nil, "main", true, "pr merge 1 --merge")
+ 10 more lines · read full file
pkg/cmd/pr/merge/merge_test.go:348pkg/cmd/pr/merge/merge_test::TestPrMerge_blocked · Go · 30 lines
func TestPrMerge_blocked(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"1",
		&api.PullRequest{
			ID:               "THE-ID",
			Number:           1,
			State:            "OPEN",
			Title:            "The title of the PR",
			MergeStateStatus: "BLOCKED",
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)
	cs.Register(`git rev-parse --verify refs/heads/`, 0, "")

	output, err := runCommand(http, nil, "main", true, "pr merge 1 --merge")
	assert.EqualError(t, err, "SilentError")

	assert.Equal(t, "", output.String())
	assert.Equal(t, heredoc.Docf(`
		X Pull request OWNER/REPO#1 is not mergeable: the base branch policy prohibits the merge.
		To have the pull request merged after all the requirements have been met, add the %[1]s--auto%[1]s flag.
		To use administrator privileges to immediately merge the pull request, add the %[1]s--admin%[1]s flag.
		`, "`"), output.Stderr())
}
+ 15 more tests · open all in source
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
DOCS
gh_pr_merge.md:37Markdown · 7 words
TESTS
pkg/cmd/pr/merge/merge_test.go:33pkg/cmd/pr/merge/merge_test::Test_NewCmdMerge · Go · 202 lines
func Test_NewCmdMerge(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    MergeOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: MergeOptions{
				SelectorArg:             "123",
				DeleteBranch:            false,
				IsDeleteBranchIndicated: false,
				CanDeleteLocalBranch:    true,
				MergeMethod:             PullRequestMergeMethodMerge,
				MergeStrategyEmpty:      true,
				Body:                    "",
				BodySet:                 false,
				AuthorEmail:             "",
			},
		},
		{
+ 172 more lines · read full file
pkg/cmd/pr/merge/merge_test.go:1100pkg/cmd/pr/merge/merge_test::TestPrMerge_rebase · Go · 40 lines
func TestPrMerge_rebase(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"2",
		&api.PullRequest{
			ID:               "THE-ID",
			Number:           2,
			Title:            "The title of the PR",
			State:            "OPEN",
			MergeStateStatus: "CLEAN",
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	http.Register(
		httpmock.GraphQL(`mutation PullRequestMerge\b`),
		httpmock.GraphQLMutation(`{}`, func(input map[string]interface{}) {
			assert.Equal(t, "THE-ID", input["pullRequestId"].(string))
			assert.Equal(t, "REBASE", input["mergeMethod"].(string))
			assert.NotContains(t, input, "commitHeadline")
		}))

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	cs.Register(`git rev-parse --verify refs/heads/`, 0, "")

	output, err := runCommand(http, nil, "main", true, "pr merge 2 --rebase")
+ 10 more lines · read full file
pkg/cmd/pr/merge/merge_test.go:1565pkg/cmd/pr/merge/merge_test::TestPRMergeEmptyStrategyNonTTY · Go · 26 lines
func TestPRMergeEmptyStrategyNonTTY(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"1",
		&api.PullRequest{
			ID:               "THE-ID",
			Number:           1,
			State:            "OPEN",
			Title:            "The title of the PR",
			MergeStateStatus: "CLEAN",
			BaseRefName:      "main",
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)
	cs.Register(`git rev-parse --verify refs/heads/`, 0, "")

	output, err := runCommand(http, nil, "blueberries", false, "pr merge 1")
	assert.EqualError(t, err, "--merge, --rebase, or --squash required when not running interactively")
	assert.Equal(t, "", output.String())
	assert.Equal(t, "", output.Stderr())
}
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
TESTS
pkg/cmd/pr/merge/merge_test.go:33pkg/cmd/pr/merge/merge_test::Test_NewCmdMerge · Go · 202 lines
func Test_NewCmdMerge(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    MergeOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: MergeOptions{
				SelectorArg:             "123",
				DeleteBranch:            false,
				IsDeleteBranchIndicated: false,
				CanDeleteLocalBranch:    true,
				MergeMethod:             PullRequestMergeMethodMerge,
				MergeStrategyEmpty:      true,
				Body:                    "",
				BodySet:                 false,
				AuthorEmail:             "",
			},
		},
		{
+ 172 more lines · read full file
pkg/cmd/pr/merge/merge_test.go:1141pkg/cmd/pr/merge/merge_test::TestPrMerge_squash · Go · 39 lines
func TestPrMerge_squash(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"3",
		&api.PullRequest{
			ID:               "THE-ID",
			Number:           3,
			Title:            "The title of the PR",
			State:            "OPEN",
			MergeStateStatus: "CLEAN",
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	http.Register(
		httpmock.GraphQL(`mutation PullRequestMerge\b`),
		httpmock.GraphQLMutation(`{}`, func(input map[string]interface{}) {
			assert.Equal(t, "THE-ID", input["pullRequestId"].(string))
			assert.Equal(t, "SQUASH", input["mergeMethod"].(string))
			assert.NotContains(t, input, "commitHeadline")
		}))

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	cs.Register(`git rev-parse --verify refs/heads/`, 0, "")

	output, err := runCommand(http, nil, "main", true, "pr merge 3 --squash")
+ 9 more lines · read full file
pkg/cmd/pr/merge/merge_test.go:1565pkg/cmd/pr/merge/merge_test::TestPRMergeEmptyStrategyNonTTY · Go · 26 lines
func TestPRMergeEmptyStrategyNonTTY(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t,
		"1",
		&api.PullRequest{
			ID:               "THE-ID",
			Number:           1,
			State:            "OPEN",
			Title:            "The title of the PR",
			MergeStateStatus: "CLEAN",
			BaseRefName:      "main",
		},
		baseRepo("OWNER", "REPO", "main"),
	)

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)
	cs.Register(`git rev-parse --verify refs/heads/`, 0, "")

	output, err := runCommand(http, nil, "blueberries", false, "pr merge 1")
	assert.EqualError(t, err, "--merge, --rebase, or --squash required when not running interactively")
	assert.Equal(t, "", output.String())
	assert.Equal(t, "", output.Stderr())
}
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr merge
short: Merge a pull request on GitHub.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is selected.

    When targeting a branch that requires a merge queue, no merge strategy is required.
    If required checks have not yet passed, auto-merge will be enabled.
    If required checks have passed, the pull request will be added to the merge queue.
    To bypass a merge queue and merge directly, pass the `--admin` flag.
pname: gh pr
plink: gh_pr.yaml
DOCS
gh_pr_merge.md:39Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr ready
short: Mark a pull request as ready for review.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is marked as ready.

    If supported by your plan, convert to draft with `--undo`
pname: gh pr
plink: gh_pr.yaml
options:
    - option: undo
      value_type: bool
DOCS
gh_pr_ready.md:1Markdown · 48 words
TESTS
pkg/cmd/pr/ready/ready_test.go:21pkg/cmd/pr/ready/ready_test::Test_NewCmdReady · Go · 69 lines
func Test_NewCmdReady(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ReadyOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: ReadyOptions{
				SelectorArg: "123",
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: ReadyOptions{
				SelectorArg: "",
			},
		},
		{
			name:    "no argument with --repo override",
			args:    "-R owner/repo",
			isTTY:   true,
			wantErr: "argument required when using the --repo flag",
		},
+ 39 more lines · read full file
pkg/cmd/pr/ready/ready_test.go:123pkg/cmd/pr/ready/ready_test::TestPRReady · Go · 24 lines
func TestPRReady(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:      "THE-ID",
		Number:  123,
		State:   "OPEN",
		IsDraft: true,
	}, ghrepo.New("OWNER", "REPO"))

	http.Register(
		httpmock.GraphQL(`mutation PullRequestReadyForReview\b`),
		httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["pullRequestId"], "THE-ID")
			}),
	)

	output, err := runCommand(http, true, "123")
	assert.NoError(t, err)
	assert.Equal(t, "", output.String())
	assert.Equal(t, "✓ Pull request OWNER/REPO#123 is marked as \"ready for review\"\n", output.Stderr())
}
pkg/cmd/pr/ready/ready_test.go:148pkg/cmd/pr/ready/ready_test::TestPRReady_alreadyReady · Go · 16 lines
func TestPRReady_alreadyReady(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:      "THE-ID",
		Number:  123,
		State:   "OPEN",
		IsDraft: false,
	}, ghrepo.New("OWNER", "REPO"))

	output, err := runCommand(http, true, "123")
	assert.NoError(t, err)
	assert.Equal(t, "", output.String())
	assert.Equal(t, "! Pull request OWNER/REPO#123 is already \"ready for review\"\n", output.Stderr())
}
+ 3 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr ready
short: Mark a pull request as ready for review.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is marked as ready.

    If supported by your plan, convert to draft with `--undo`
pname: gh pr
plink: gh_pr.yaml
options:
    - option: undo
      value_type: bool
DOCS
gh_pr_ready.md:25Markdown · 6 words
TESTS
pkg/cmd/pr/ready/ready_test.go:165pkg/cmd/pr/ready/ready_test::TestPRReadyUndo · Go · 24 lines
func TestPRReadyUndo(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:      "THE-ID",
		Number:  123,
		State:   "OPEN",
		IsDraft: false,
	}, ghrepo.New("OWNER", "REPO"))

	http.Register(
		httpmock.GraphQL(`mutation ConvertPullRequestToDraft\b`),
		httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["pullRequestId"], "THE-ID")
			}),
	)

	output, err := runCommand(http, true, "123 --undo")
	assert.NoError(t, err)
	assert.Equal(t, "", output.String())
	assert.Equal(t, "✓ Pull request OWNER/REPO#123 is converted to \"draft\"\n", output.Stderr())
}
pkg/cmd/pr/ready/ready_test.go:190pkg/cmd/pr/ready/ready_test::TestPRReadyUndo_alreadyDraft · Go · 16 lines
func TestPRReadyUndo_alreadyDraft(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:      "THE-ID",
		Number:  123,
		State:   "OPEN",
		IsDraft: true,
	}, ghrepo.New("OWNER", "REPO"))

	output, err := runCommand(http, true, "123 --undo")
	assert.NoError(t, err)
	assert.Equal(t, "", output.String())
	assert.Equal(t, "! Pull request OWNER/REPO#123 is already \"in draft\"\n", output.Stderr())
}
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr reopen
short: Reopen a pull request
pname: gh pr
plink: gh_pr.yaml
options:
    - option: comment
      shorthand: c
      value_type: string
      description: Add a reopening comment
DOCS
gh_pr_reopen.md:1Markdown · 18 words
TESTS
pkg/cmd/pr/reopen/reopen_test.go:52pkg/cmd/pr/reopen/reopen_test::TestPRReopen · Go · 24 lines
func TestPRReopen(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:     "THE-ID",
		Number: 123,
		State:  "CLOSED",
		Title:  "The title of the PR",
	}, ghrepo.New("OWNER", "REPO"))

	http.Register(
		httpmock.GraphQL(`mutation PullRequestReopen\b`),
		httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["pullRequestId"], "THE-ID")
			}),
	)

	output, err := runCommand(http, true, "123")
	assert.NoError(t, err)
	assert.Equal(t, "", output.String())
	assert.Equal(t, "✓ Reopened pull request OWNER/REPO#123 (The title of the PR)\n", output.Stderr())
}
pkg/cmd/pr/reopen/reopen_test.go:77pkg/cmd/pr/reopen/reopen_test::TestPRReopen_alreadyOpen · Go · 16 lines
func TestPRReopen_alreadyOpen(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:     "THE-ID",
		Number: 123,
		State:  "OPEN",
		Title:  "The title of the PR",
	}, ghrepo.New("OWNER", "REPO"))

	output, err := runCommand(http, true, "123")
	assert.NoError(t, err)
	assert.Equal(t, "", output.String())
	assert.Equal(t, "! Pull request OWNER/REPO#123 (The title of the PR) is already open\n", output.Stderr())
}
pkg/cmd/pr/reopen/reopen_test.go:94pkg/cmd/pr/reopen/reopen_test::TestPRReopen_alreadyMerged · Go · 16 lines
func TestPRReopen_alreadyMerged(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:     "THE-ID",
		Number: 123,
		State:  "MERGED",
		Title:  "The title of the PR",
	}, ghrepo.New("OWNER", "REPO"))

	output, err := runCommand(http, true, "123")
	assert.EqualError(t, err, "SilentError")
	assert.Equal(t, "", output.String())
	assert.Equal(t, "X Pull request OWNER/REPO#123 (The title of the PR) can't be reopened because it was already merged\n", output.Stderr())
}
+ 1 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr reopen
short: Reopen a pull request
pname: gh pr
plink: gh_pr.yaml
options:
    - option: comment
      shorthand: c
      value_type: string
      description: Add a reopening comment
DOCS
gh_pr_reopen.md:19Markdown · 4 words
TESTS
pkg/cmd/pr/reopen/reopen_test.go:111pkg/cmd/pr/reopen/reopen_test::TestPRReopen_withComment · Go · 35 lines
func TestPRReopen_withComment(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:     "THE-ID",
		Number: 123,
		State:  "CLOSED",
		Title:  "The title of the PR",
	}, ghrepo.New("OWNER", "REPO"))

	http.Register(
		httpmock.GraphQL(`mutation CommentCreate\b`),
		httpmock.GraphQLMutation(`
		{ "data": { "addComment": { "commentEdge": { "node": {
			"url": "https://github.com/OWNER/REPO/issues/123#issuecomment-456"
		} } } } }`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, "THE-ID", inputs["subjectId"])
				assert.Equal(t, "reopening comment", inputs["body"])
			}),
	)
	http.Register(
		httpmock.GraphQL(`mutation PullRequestReopen\b`),
		httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["pullRequestId"], "THE-ID")
			}),
	)
+ 6 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr revert
short: Revert a pull request
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: Body for the revert pull request
    - option: body-file
      shorthand: F
      value_type: string
DOCS
gh_pr_revert.md:1Markdown · 18 words
TESTS
pkg/cmd/pr/revert/revert_test.go:52pkg/cmd/pr/revert/revert_test::TestPRRevert_missingArgument · Go · 16 lines
func TestPRRevert_missingArgument(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:     "SOME-ID",
		Number: 123,
		State:  "MERGED",
		Title:  "The title of the PR",
	}, ghrepo.New("OWNER", "REPO"))

	// No arguments provided.
	_, err := runCommand(http, true, "")
	// Exits non-zero and prints an argument error.
	assert.EqualError(t, err, "cannot revert pull request: number, url, or branch required")
}
pkg/cmd/pr/revert/revert_test.go:69pkg/cmd/pr/revert/revert_test::TestPRRevert_acceptedIdentifierFormats · Go · 56 lines
func TestPRRevert_acceptedIdentifierFormats(t *testing.T) {
	tests := []struct {
		name string
		args string
	}{
		{
			name: "Revert by pull request number",
			args: "123",
		},
		{
			name: "Revert by pull request identifier",
			args: "owner/repo#123",
		},
		{
			name: "Revert by pull request URL",
			args: "https://github.com/owner/repo/pull/123",
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {

			http := &httpmock.Registry{}
			defer http.Verify(t)

			shared.StubFinderForRunCommandStyleTests(t, tt.args, &api.PullRequest{
				ID:     "SOME-ID",
				Number: 123,
				State:  "MERGED",
				Title:  "The title of the PR",
+ 26 more lines · read full file
pkg/cmd/pr/revert/revert_test.go:126pkg/cmd/pr/revert/revert_test::TestPRRevert_notRevertable · Go · 19 lines
func TestPRRevert_notRevertable(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:     "SOME-ID",
		Number: 123,
		State:  "OPEN",
		Title:  "The title of the PR",
	}, ghrepo.New("OWNER", "REPO"))

	// Target PR is not merged.
	output, err := runCommand(http, true, "123")
	// API error, non-zero exit.
	assert.EqualError(t, err, "SilentError")
	assert.Equal(t, "X Pull request OWNER/REPO#123 (The title of the PR) can't be reverted because it has not been merged\n", output.Stderr())
	// No URL printed.
	assert.Equal(t, "", output.String())
}
+ 4 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr revert
short: Revert a pull request
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: Body for the revert pull request
    - option: body-file
      shorthand: F
      value_type: string
DOCS
gh_pr_revert.md:19Markdown · 6 words
TESTS
pkg/cmd/pr/revert/revert_test.go:146pkg/cmd/pr/revert/revert_test::TestPRRevert_withTitleAndBody · Go · 36 lines
func TestPRRevert_withTitleAndBody(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:     "SOME-ID",
		Number: 123,
		State:  "MERGED",
		Title:  "The title of the PR",
	}, ghrepo.New("OWNER", "REPO"))

	http.Register(
		httpmock.GraphQL(`mutation PullRequestRevert\b`),
		httpmock.GraphQLMutation(`
			{ "data": { "revertPullRequest": { "pullRequest": {
				"ID": "SOME-ID"
			}, "revertPullRequest": {
               "ID": "NEW-ID",
               "Number": 456,
               "URL": "https://github.com/OWNER/REPO/pull/456"
            } } } }
			`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["pullRequestId"], "SOME-ID")
				assert.Equal(t, inputs["title"], "Revert PR title")
				assert.Equal(t, inputs["body"], "Revert PR body")
			}),
	)

	output, err := runCommand(http, true, "123 --title 'Revert PR title' --body 'Revert PR body'")
+ 6 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr revert
short: Revert a pull request
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: Body for the revert pull request
    - option: body-file
      shorthand: F
      value_type: string
DOCS
gh_pr_revert.md:20Markdown · 12 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr revert
short: Revert a pull request
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: Body for the revert pull request
    - option: body-file
      shorthand: F
      value_type: string
DOCS
gh_pr_revert.md:21Markdown · 7 words
TESTS
pkg/cmd/pr/revert/revert_test.go:183pkg/cmd/pr/revert/revert_test::TestPRRevert_withDraft · Go · 35 lines
func TestPRRevert_withDraft(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:     "SOME-ID",
		Number: 123,
		State:  "MERGED",
		Title:  "The title of the PR",
	}, ghrepo.New("OWNER", "REPO"))

	http.Register(
		httpmock.GraphQL(`mutation PullRequestRevert\b`),
		httpmock.GraphQLMutation(`
			{ "data": { "revertPullRequest": { "pullRequest": {
				"ID": "SOME-ID"
			}, "revertPullRequest": {
               "ID": "NEW-ID",
               "Number": 456,
               "URL": "https://github.com/OWNER/REPO/pull/456"
            } } } }
			`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["pullRequestId"], "SOME-ID")
				assert.Equal(t, inputs["draft"], true)
			}),
	)

	output, err := runCommand(http, true, "123 --draft")
	// Revert PR created as a draft.
+ 5 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr revert
short: Revert a pull request
pname: gh pr
plink: gh_pr.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: Body for the revert pull request
    - option: body-file
      shorthand: F
      value_type: string
DOCS
gh_pr_revert.md:22Markdown · 6 words
TESTS
pkg/cmd/pr/revert/revert_test.go:146pkg/cmd/pr/revert/revert_test::TestPRRevert_withTitleAndBody · Go · 36 lines
func TestPRRevert_withTitleAndBody(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
		ID:     "SOME-ID",
		Number: 123,
		State:  "MERGED",
		Title:  "The title of the PR",
	}, ghrepo.New("OWNER", "REPO"))

	http.Register(
		httpmock.GraphQL(`mutation PullRequestRevert\b`),
		httpmock.GraphQLMutation(`
			{ "data": { "revertPullRequest": { "pullRequest": {
				"ID": "SOME-ID"
			}, "revertPullRequest": {
               "ID": "NEW-ID",
               "Number": 456,
               "URL": "https://github.com/OWNER/REPO/pull/456"
            } } } }
			`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["pullRequestId"], "SOME-ID")
				assert.Equal(t, inputs["title"], "Revert PR title")
				assert.Equal(t, inputs["body"], "Revert PR body")
			}),
	)

	output, err := runCommand(http, true, "123 --title 'Revert PR title' --body 'Revert PR body'")
+ 6 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr review
short: Add a review to a pull request.
long: Without an argument, the pull request that belongs to the current branch is reviewed.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: approve
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Approve pull request
    - option: body
DOCS
gh_pr_review.md:1Markdown · 36 words
TESTS
pkg/cmd/pr/review/review_test.go:28pkg/cmd/pr/review/review_test::Test_NewCmdReview · Go · 140 lines
func Test_NewCmdReview(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    ReviewOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: ReviewOptions{
				SelectorArg: "123",
				ReviewType:  0,
				Body:        "",
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: ReviewOptions{
				SelectorArg: "",
				ReviewType:  0,
+ 110 more lines · read full file
pkg/cmd/pr/review/review_test.go:205pkg/cmd/pr/review/review_test::TestPRReview · Go · 54 lines
func TestPRReview(t *testing.T) {
	tests := []struct {
		args      string
		wantEvent string
		wantBody  string
	}{
		{
			args:      `--request-changes -b"bad"`,
			wantEvent: "REQUEST_CHANGES",
			wantBody:  "bad",
		},
		{
			args:      `--approve`,
			wantEvent: "APPROVE",
			wantBody:  "",
		},
		{
			args:      `--approve -b"hot damn"`,
			wantEvent: "APPROVE",
			wantBody:  "hot damn",
		},
		{
			args:      `--comment --body "i dunno"`,
			wantEvent: "COMMENT",
			wantBody:  "i dunno",
		},
	}

	for _, tt := range tests {
		t.Run(tt.args, func(t *testing.T) {
+ 24 more lines · read full file
pkg/cmd/pr/review/review_test.go:260pkg/cmd/pr/review/review_test::TestPRReview_interactive · Go · 31 lines
func TestPRReview_interactive(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	shared.StubFinderForRunCommandStyleTests(t, "", &api.PullRequest{ID: "THE-ID", Number: 123}, ghrepo.New("OWNER", "REPO"))

	http.Register(
		httpmock.GraphQL(`mutation PullRequestReviewAdd\b`),
		httpmock.GraphQLMutation(`{"data": {} }`,
			func(inputs map[string]interface{}) {
				assert.Equal(t, inputs["event"], "APPROVE")
				assert.Equal(t, inputs["body"], "cool story")
			}),
	)

	pm := &prompter.PrompterMock{
		SelectFunc:         func(_, _ string, _ []string) (int, error) { return 1, nil },
		MarkdownEditorFunc: func(_, _ string, _ bool) (string, error) { return "cool story", nil },
		ConfirmFunc:        func(_ string, _ bool) (bool, error) { return true, nil },
	}

	output, err := runCommand(http, pm, true, "")
	assert.NoError(t, err)
	assert.Equal(t, heredoc.Doc(`
		Got:

		  cool story                                                                  

	`), output.String())
	assert.Equal(t, "✓ Approved pull request OWNER/REPO#123\n", output.Stderr())
+ 1 more lines · read full file
+ 2 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr review
short: Add a review to a pull request.
long: Without an argument, the pull request that belongs to the current branch is reviewed.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: approve
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Approve pull request
    - option: body
DOCS
gh_pr_review.md:22Markdown · 3 words
TESTS
pkg/cmd/pr/review/review_test.go:28pkg/cmd/pr/review/review_test::Test_NewCmdReview · Go · 140 lines
func Test_NewCmdReview(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    ReviewOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: ReviewOptions{
				SelectorArg: "123",
				ReviewType:  0,
				Body:        "",
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: ReviewOptions{
				SelectorArg: "",
				ReviewType:  0,
+ 110 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr review
short: Add a review to a pull request.
long: Without an argument, the pull request that belongs to the current branch is reviewed.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: approve
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Approve pull request
    - option: body
DOCS
gh_pr_review.md:23Markdown · 6 words
TESTS
pkg/cmd/pr/review/review_test.go:28pkg/cmd/pr/review/review_test::Test_NewCmdReview · Go · 140 lines
func Test_NewCmdReview(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    ReviewOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: ReviewOptions{
				SelectorArg: "123",
				ReviewType:  0,
				Body:        "",
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: ReviewOptions{
				SelectorArg: "",
				ReviewType:  0,
+ 110 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr review
short: Add a review to a pull request.
long: Without an argument, the pull request that belongs to the current branch is reviewed.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: approve
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Approve pull request
    - option: body
DOCS
gh_pr_review.md:24Markdown · 12 words
TESTS
pkg/cmd/pr/review/review_test.go:28pkg/cmd/pr/review/review_test::Test_NewCmdReview · Go · 140 lines
func Test_NewCmdReview(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    ReviewOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: ReviewOptions{
				SelectorArg: "123",
				ReviewType:  0,
				Body:        "",
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: ReviewOptions{
				SelectorArg: "",
				ReviewType:  0,
+ 110 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr review
short: Add a review to a pull request.
long: Without an argument, the pull request that belongs to the current branch is reviewed.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: approve
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Approve pull request
    - option: body
DOCS
gh_pr_review.md:25Markdown · 5 words
TESTS
pkg/cmd/pr/review/review_test.go:28pkg/cmd/pr/review/review_test::Test_NewCmdReview · Go · 140 lines
func Test_NewCmdReview(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    ReviewOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: ReviewOptions{
				SelectorArg: "123",
				ReviewType:  0,
				Body:        "",
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: ReviewOptions{
				SelectorArg: "",
				ReviewType:  0,
+ 110 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr review
short: Add a review to a pull request.
long: Without an argument, the pull request that belongs to the current branch is reviewed.
pname: gh pr
plink: gh_pr.yaml
options:
    - option: approve
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Approve pull request
    - option: body
DOCS
gh_pr_review.md:26Markdown · 6 words
TESTS
pkg/cmd/pr/review/review_test.go:28pkg/cmd/pr/review/review_test::Test_NewCmdReview · Go · 140 lines
func Test_NewCmdReview(t *testing.T) {
	tmpFile := filepath.Join(t.TempDir(), "my-body.md")
	err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
	require.NoError(t, err)

	tests := []struct {
		name    string
		args    string
		stdin   string
		isTTY   bool
		want    ReviewOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: ReviewOptions{
				SelectorArg: "123",
				ReviewType:  0,
				Body:        "",
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: ReviewOptions{
				SelectorArg: "",
				ReviewType:  0,
+ 110 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr status
short: Show status of relevant pull requests.
long: |-
    The status shows a summary of pull requests that includes information such as
    pull request number, title, CI checks, reviews, etc.

    To see more details of CI checks, run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh pr
plink: gh_pr.yaml
options:
DOCS
gh_pr_status.md:1Markdown · 100 words
TESTS
pkg/cmd/pr/status/status_test.go:93pkg/cmd/pr/status/status_test::TestPRStatus · Go · 31 lines
func TestPRStatus(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)
	http.Register(httpmock.GraphQL(`query PullRequestStatus\b`), httpmock.FileResponse("./fixtures/prStatus.json"))

	// stub successful git commands
	rs, cleanup := run.Stub()
	defer cleanup(t)
	rs.Register(`git rev-parse --symbolic-full-name blueberries@{push}`, 128, "")
	rs.Register(`git config --get-regexp \^branch\\.`, 0, "")
	rs.Register(`git config remote.pushDefault`, 0, "")
	rs.Register(`git config push.default`, 1, "")

	output, err := runCommand(http, "blueberries", true, "")
	if err != nil {
		t.Errorf("error running command `pr status`: %v", err)
	}

	expectedPrs := []*regexp.Regexp{
		regexp.MustCompile(`#8.*\[strawberries\]`),
		regexp.MustCompile(`#9.*\[apples\].*✓ Auto-merge enabled`),
		regexp.MustCompile(`#10.*\[blueberries\]`),
		regexp.MustCompile(`#11.*\[figs\]`),
	}

	for _, r := range expectedPrs {
		if !r.MatchString(output.String()) {
			t.Errorf("output did not match regexp /%s/", r)
		}
	}
+ 1 more lines · read full file
pkg/cmd/pr/status/status_test.go:125pkg/cmd/pr/status/status_test::TestPRStatus_reviewsAndChecks · Go · 32 lines
func TestPRStatus_reviewsAndChecks(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)
	// status,conclusion matches the old StatusContextRollup query
	http.Register(httpmock.GraphQL(`status,conclusion`), httpmock.FileResponse("./fixtures/prStatusChecks.json"))

	// stub successful git command
	rs, cleanup := run.Stub()
	defer cleanup(t)
	rs.Register(`git config --get-regexp \^branch\\.`, 0, "")
	rs.Register(`git config remote.pushDefault`, 0, "")
	rs.Register(`git rev-parse --symbolic-full-name blueberries@{push}`, 128, "")
	rs.Register(`git config push.default`, 1, "")

	output, err := runCommand(http, "blueberries", true, "")
	if err != nil {
		t.Errorf("error running command `pr status`: %v", err)
	}

	expected := []string{
		"✓ Checks passing + Changes requested ! Merge conflict status unknown",
		"- Checks pending ✓ 2 Approved",
		"× 1/3 checks failing - Review required ✓ No merge conflicts",
		"✓ Checks passing × Merge conflicts",
	}

	for _, line := range expected {
		if !strings.Contains(output.String(), line) {
			t.Errorf("output did not contain %q: %q", line, output.String())
		}
+ 2 more lines · read full file
pkg/cmd/pr/status/status_test.go:158pkg/cmd/pr/status/status_test::TestPRStatus_reviewsAndChecksWithStatesByCount · Go · 32 lines
func TestPRStatus_reviewsAndChecksWithStatesByCount(t *testing.T) {
	http := initFakeHTTP()
	defer http.Verify(t)
	// checkRunCount,checkRunCountsByState matches the new StatusContextRollup query
	http.Register(httpmock.GraphQL(`checkRunCount,checkRunCountsByState`), httpmock.FileResponse("./fixtures/prStatusChecksWithStatesByCount.json"))

	// stub successful git command
	rs, cleanup := run.Stub()
	defer cleanup(t)
	rs.Register(`git config --get-regexp \^branch\\.`, 0, "")
	rs.Register(`git config remote.pushDefault`, 0, "")
	rs.Register(`git rev-parse --symbolic-full-name blueberries@{push}`, 128, "")
	rs.Register(`git config push.default`, 1, "")

	output, err := runCommandWithDetector(http, "blueberries", true, "", &fd.EnabledDetectorMock{})
	if err != nil {
		t.Errorf("error running command `pr status`: %v", err)
	}

	expected := []string{
		"✓ Checks passing + Changes requested ! Merge conflict status unknown",
		"- Checks pending ✓ 2 Approved",
		"× 1/3 checks failing - Review required ✓ No merge conflicts",
		"✓ Checks passing × Merge conflicts",
	}

	for _, line := range expected {
		if !strings.Contains(output.String(), line) {
			t.Errorf("output did not contain %q: %q", line, output.String())
		}
+ 2 more lines · read full file
+ 11 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr status
short: Show status of relevant pull requests.
long: |-
    The status shows a summary of pull requests that includes information such as
    pull request number, title, CI checks, reviews, etc.

    To see more details of CI checks, run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh pr
plink: gh_pr.yaml
options:
DOCS
gh_pr_status.md:25Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr status
short: Show status of relevant pull requests.
long: |-
    The status shows a summary of pull requests that includes information such as
    pull request number, title, CI checks, reviews, etc.

    To see more details of CI checks, run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh pr
plink: gh_pr.yaml
options:
DOCS
gh_pr_status.md:26Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr status
short: Show status of relevant pull requests.
long: |-
    The status shows a summary of pull requests that includes information such as
    pull request number, title, CI checks, reviews, etc.

    To see more details of CI checks, run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh pr
plink: gh_pr.yaml
options:
DOCS
gh_pr_status.md:27Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr status
short: Show status of relevant pull requests.
long: |-
    The status shows a summary of pull requests that includes information such as
    pull request number, title, CI checks, reviews, etc.

    To see more details of CI checks, run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh pr
plink: gh_pr.yaml
options:
DOCS
gh_pr_status.md:28Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr unlock
short: Unlock pull request conversation
pname: gh pr
plink: gh_pr.yaml
DOCS
gh_pr_unlock.md:1Markdown · 17 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr view
short: Display the title, body, and other information about a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is displayed.

    With `--web` flag, open the pull request in a web browser instead.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh pr
plink: gh_pr.yaml
options:
DOCS
gh_pr_view.md:1Markdown · 99 words
TESTS
pkg/cmd/pr/view/view_test.go:29pkg/cmd/pr/view/view_test::TestJSONFields · Go · 50 lines
func TestJSONFields(t *testing.T) {
	jsonfieldstest.ExpectCommandToSupportJSONFields(t, NewCmdView, []string{
		"additions",
		"assignees",
		"author",
		"autoMergeRequest",
		"baseRefName",
		"baseRefOid",
		"body",
		"changedFiles",
		"closed",
		"closedAt",
		"closingIssuesReferences",
		"comments",
		"commits",
		"createdAt",
		"deletions",
		"files",
		"fullDatabaseId",
		"headRefName",
		"headRefOid",
		"headRepository",
		"headRepositoryOwner",
		"id",
		"isCrossRepository",
		"isDraft",
		"labels",
		"latestReviews",
		"maintainerCanModify",
		"mergeCommit",
+ 20 more lines · read full file
pkg/cmd/pr/view/view_test.go:80pkg/cmd/pr/view/view_test::Test_NewCmdView · Go · 89 lines
func Test_NewCmdView(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ViewOptions
		wantErr string
	}{
		{
			name:  "number argument",
			args:  "123",
			isTTY: true,
			want: ViewOptions{
				SelectorArg: "123",
				BrowserMode: false,
			},
		},
		{
			name:  "no argument",
			args:  "",
			isTTY: true,
			want: ViewOptions{
				SelectorArg: "",
				BrowserMode: false,
			},
		},
		{
			name:  "web mode",
			args:  "123 -w",
			isTTY: true,
+ 59 more lines · read full file
pkg/cmd/pr/view/view_test.go:249pkg/cmd/pr/view/view_test::TestPRView_Preview_nontty · Go · 176 lines
func TestPRView_Preview_nontty(t *testing.T) {
	tests := map[string]struct {
		branch          string
		args            string
		fixtures        map[string]string
		expectedOutputs []string
	}{
		"Open PR without metadata": {
			branch: "master",
			args:   "12",
			fixtures: map[string]string{
				"PullRequestByNumber": "./fixtures/prViewPreview.json",
			},
			expectedOutputs: []string{
				`title:\tBlueberries are from a fork\n`,
				`state:\tOPEN\n`,
				`author:\tnobody\n`,
				`labels:\t\n`,
				`assignees:\t\n`,
				`reviewers:\t\n`,
				`projects:\t\n`,
				`milestone:\t\n`,
				`url:\thttps://github.com/OWNER/REPO/pull/12\n`,
				`additions:\t100\n`,
				`deletions:\t10\n`,
				`number:\t12\n`,
				`blueberries taste good`,
			},
		},
		"Open PR with metadata by number": {
+ 146 more lines · read full file
+ 8 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh pr view
short: Display the title, body, and other information about a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is displayed.

    With `--web` flag, open the pull request in a web browser instead.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh pr
plink: gh_pr.yaml
options:
DOCS
gh_pr_view.md:25Markdown · 4 words
TESTS
pkg/cmd/pr/view/view_test.go:668pkg/cmd/pr/view/view_test::TestPRView_tty_Comments · Go · 98 lines
func TestPRView_tty_Comments(t *testing.T) {
	tests := map[string]struct {
		branch          string
		cli             string
		fixtures        map[string]string
		expectedOutputs []string
		wantsErr        bool
	}{
		"without comments flag": {
			branch: "master",
			cli:    "123",
			fixtures: map[string]string{
				"PullRequestByNumber":   "./fixtures/prViewPreviewSingleComment.json",
				"ReviewsForPullRequest": "./fixtures/prViewPreviewReviews.json",
			},
			expectedOutputs: []string{
				`some title OWNER/REPO#12`,
				`1 \x{1f615} • 2 \x{1f440} • 3 \x{2764}\x{fe0f}`,
				`some body`,
				`———————— Not showing 9 comments ————————`,
				`marseilles \(Collaborator\) • Jan  9, 2020 • Newest comment`,
				`4 \x{1f389} • 5 \x{1f604} • 6 \x{1f680}`,
				`Comment 5`,
				`Use --comments to view the full conversation`,
				`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
			},
		},
		"with comments flag": {
			branch: "master",
			cli:    "123 --comments",
+ 68 more lines · read full file
pkg/cmd/pr/view/view_test.go:767pkg/cmd/pr/view/view_test::TestPRView_nontty_Comments · Go · 110 lines
func TestPRView_nontty_Comments(t *testing.T) {
	tests := map[string]struct {
		branch          string
		cli             string
		fixtures        map[string]string
		expectedOutputs []string
		wantsErr        bool
	}{
		"without comments flag": {
			branch: "master",
			cli:    "123",
			fixtures: map[string]string{
				"PullRequestByNumber":   "./fixtures/prViewPreviewSingleComment.json",
				"ReviewsForPullRequest": "./fixtures/prViewPreviewReviews.json",
			},
			expectedOutputs: []string{
				`title:\tsome title`,
				`state:\tOPEN`,
				`author:\tnobody`,
				`url:\thttps://github.com/OWNER/REPO/pull/12`,
				`some body`,
			},
		},
		"with comments flag": {
			branch: "master",
			cli:    "123 --comments",
			fixtures: map[string]string{
				"PullRequestByNumber":    "./fixtures/prViewPreviewSingleComment.json",
				"ReviewsForPullRequest":  "./fixtures/prViewPreviewReviews.json",
				"CommentsForPullRequest": "./fixtures/prViewPreviewFullComments.json",
+ 80 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr view
short: Display the title, body, and other information about a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is displayed.

    With `--web` flag, open the pull request in a web browser instead.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh pr
plink: gh_pr.yaml
options:
DOCS
gh_pr_view.md:26Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr view
short: Display the title, body, and other information about a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is displayed.

    With `--web` flag, open the pull request in a web browser instead.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh pr
plink: gh_pr.yaml
options:
DOCS
gh_pr_view.md:27Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr view
short: Display the title, body, and other information about a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is displayed.

    With `--web` flag, open the pull request in a web browser instead.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh pr
plink: gh_pr.yaml
options:
DOCS
gh_pr_view.md:28Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh pr view
short: Display the title, body, and other information about a pull request.
long: |-
    Without an argument, the pull request that belongs to the current branch
    is displayed.

    With `--web` flag, open the pull request in a web browser instead.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh pr
plink: gh_pr.yaml
options:
DOCS
gh_pr_view.md:29Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh preview
short: Preview commands are for testing, demonstrative, and development purposes only.
long: They should be considered unstable and can change at any time.
pname: gh
plink: gh.yaml
DOCS
gh_preview.md:1Markdown · 33 words
TESTS
pkg/cmd/skills/preview/preview_test.go:24pkg/cmd/skills/preview/preview_test::TestNewCmdPreview · Go · 87 lines
func TestNewCmdPreview(t *testing.T) {
	tests := []struct {
		name                string
		input               string
		wantRepo            string
		wantSkillName       string
		wantVersion         string
		wantAllowHiddenDirs bool
		wantErr             bool
	}{
		{
			name:          "repo and skill",
			input:         "github/awesome-copilot my-skill",
			wantRepo:      "github/awesome-copilot",
			wantSkillName: "my-skill",
		},
		{
			name:          "repo and skill with version",
			input:         "github/awesome-copilot my-skill@v1.2.0",
			wantRepo:      "github/awesome-copilot",
			wantSkillName: "my-skill",
			wantVersion:   "v1.2.0",
		},
		{
			name:          "repo and skill with SHA",
			input:         "github/awesome-copilot my-skill@abc123def456",
			wantRepo:      "github/awesome-copilot",
			wantSkillName: "my-skill",
			wantVersion:   "abc123def456",
		},
+ 57 more lines · read full file
pkg/cmd/skills/preview/preview_test.go:112pkg/cmd/skills/preview/preview_test::TestPreviewRun · Go · 295 lines
func TestPreviewRun(t *testing.T) {
	skillContent := heredoc.Doc(`
		---
		name: my-skill
		description: A test skill
		---
		# My Skill

		This is the skill content.
	`)
	encodedContent := base64.StdEncoding.EncodeToString([]byte(skillContent))

	tests := []struct {
		name       string
		opts       *PreviewOptions
		tty        bool
		httpStubs  func(*httpmock.Registry)
		wantStdout string
		wantErr    string
	}{
		{
			name: "preview specific skill",
			tty:  true,
			opts: &PreviewOptions{
				repo:      ghrepo.New("github", "awesome-copilot"),
				SkillName: "my-skill",
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "repos/github/awesome-copilot/releases/latest"),
+ 265 more lines · read full file
pkg/cmd/skills/preview/preview_test.go:408pkg/cmd/skills/preview/preview_test::TestPreviewRun_UnsupportedHost · Go · 10 lines
func TestPreviewRun_UnsupportedHost(t *testing.T) {
	ios, _, _, _ := iostreams.Test()
	err := previewRun(&PreviewOptions{
		IO:         ios,
		HttpClient: func() (*http.Client, error) { return &http.Client{}, nil },
		repo:       ghrepo.NewWithHost("github", "awesome-copilot", "acme.ghes.com"),
		Telemetry:  &telemetry.NoOpService{},
	})
	require.ErrorContains(t, err, "does not currently support GitHub Enterprise Server")
}
+ 16 more tests · open all in source
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh preview prompter
short: Execute a test program to preview the prompter.
long: Without an argument, all prompts will be run.
pname: gh preview
plink: gh_preview.yaml
DOCS
gh_preview_prompter.md:1Markdown · 47 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project
short: Work with GitHub Projects.
long: |-
    The minimum required scope for the token is: `project`.
    You can verify your token scope by running `gh auth status` and
    add the `project` scope by running `gh auth refresh -s project`.
pname: gh
plink: gh.yaml
DOCS
gh_project.md:1Markdown · 121 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project close
short: Close a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_close.md:1Markdown · 13 words
TESTS
pkg/cmd/project/close/close_test.go:14pkg/cmd/project/close/close_test::TestNewCmdClose · Go · 76 lines
func TestNewCmdClose(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         closeOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "number",
			cli:  "123",
			wants: closeOpts{
				number: 123,
			},
		},
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: closeOpts{
				owner: "monalisa",
			},
		},
		{
+ 46 more lines · read full file
pkg/cmd/project/close/close_test.go:91pkg/cmd/project/close/close_test::TestRunClose_User · Go · 95 lines
func TestRunClose_User(t *testing.T) {
	defer gock.Off()
	// gock.Observe(gock.DumpRequest)

	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "monalisa",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})

	// get user project ID
+ 65 more lines · read full file
pkg/cmd/project/close/close_test.go:187pkg/cmd/project/close/close_test::TestRunClose_Org · Go · 90 lines
func TestRunClose_Org(t *testing.T) {
	defer gock.Off()
	// gock.Observe(gock.DumpRequest)

	// get org ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "github",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"organization": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"user"},
				},
			},
		})

	// get org project ID
+ 60 more lines · read full file
+ 3 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh project close
short: Close a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_close.md:19Markdown · 3 words
TESTS
pkg/cmd/project/close/close_test.go:14pkg/cmd/project/close/close_test::TestNewCmdClose · Go · 76 lines
func TestNewCmdClose(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         closeOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "number",
			cli:  "123",
			wants: closeOpts{
				number: 123,
			},
		},
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: closeOpts{
				owner: "monalisa",
			},
		},
		{
+ 46 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project close
short: Close a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_close.md:20Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project close
short: Close a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_close.md:21Markdown · 10 words
TESTS
pkg/cmd/project/close/close_test.go:14pkg/cmd/project/close/close_test::TestNewCmdClose · Go · 76 lines
func TestNewCmdClose(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         closeOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "number",
			cli:  "123",
			wants: closeOpts{
				number: 123,
			},
		},
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: closeOpts{
				owner: "monalisa",
			},
		},
		{
+ 46 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project close
short: Close a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_close.md:22Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project close
short: Close a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_close.md:23Markdown · 4 words
TESTS
pkg/cmd/project/close/close_test.go:14pkg/cmd/project/close/close_test::TestNewCmdClose · Go · 76 lines
func TestNewCmdClose(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         closeOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "number",
			cli:  "123",
			wants: closeOpts{
				number: 123,
			},
		},
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: closeOpts{
				owner: "monalisa",
			},
		},
		{
+ 46 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project copy
short: Copy a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: drafts
      value_type: bool
      default_value: "false"
      description: Include draft issues when copying
    - option: format
      value_type: string
DOCS
gh_project_copy.md:1Markdown · 13 words
TESTS
pkg/cmd/project/copy/copy_test.go:14pkg/cmd/project/copy/copy_test::TestNewCmdCopy · Go · 100 lines
func TestNewCmdCopy(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         copyOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x --title t",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "title",
			cli:  "--title t",
			wants: copyOpts{
				title: "t",
			},
		},
		{
			name: "number",
			cli:  "123 --title t",
			wants: copyOpts{
				number: 123,
				title:  "t",
			},
		},
+ 70 more lines · read full file
pkg/cmd/project/copy/copy_test.go:115pkg/cmd/project/copy/copy_test::TestRunCopy_User · Go · 121 lines
func TestRunCopy_User(t *testing.T) {
	defer gock.Off()
	// gock.Observe(gock.DumpRequest)

	// get user project ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserProject.*",
			"variables": map[string]interface{}{
				"login":       "monalisa",
				"number":      1,
				"firstItems":  0,
				"afterItems":  nil,
				"firstFields": 0,
				"afterFields": nil,
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"projectV2": map[string]string{
						"id": "an ID",
					},
				},
			},
		})
+ 92 more lines · read full file
pkg/cmd/project/copy/copy_test.go:237pkg/cmd/project/copy/copy_test::TestRunCopy_Org · Go · 120 lines
func TestRunCopy_Org(t *testing.T) {
	defer gock.Off()
	// gock.Observe(gock.DumpRequest)

	// get org project ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query OrgProject.*",
			"variables": map[string]interface{}{
				"login":       "github",
				"number":      1,
				"firstItems":  0,
				"afterItems":  nil,
				"firstFields": 0,
				"afterFields": nil,
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"organization": map[string]interface{}{
					"projectV2": map[string]string{
						"id": "an ID",
					},
				},
			},
		})
	// get source org ID
+ 90 more lines · read full file
+ 2 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project copy
short: Copy a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: drafts
      value_type: bool
      default_value: "false"
      description: Include draft issues when copying
    - option: format
      value_type: string
DOCS
gh_project_copy.md:19Markdown · 5 words
TESTS
pkg/cmd/project/copy/copy_test.go:14pkg/cmd/project/copy/copy_test::TestNewCmdCopy · Go · 100 lines
func TestNewCmdCopy(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         copyOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x --title t",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "title",
			cli:  "--title t",
			wants: copyOpts{
				title: "t",
			},
		},
		{
			name: "number",
			cli:  "123 --title t",
			wants: copyOpts{
				number: 123,
				title:  "t",
			},
		},
+ 70 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project copy
short: Copy a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: drafts
      value_type: bool
      default_value: "false"
      description: Include draft issues when copying
    - option: format
      value_type: string
DOCS
gh_project_copy.md:20Markdown · 3 words
TESTS
pkg/cmd/project/copy/copy_test.go:14pkg/cmd/project/copy/copy_test::TestNewCmdCopy · Go · 100 lines
func TestNewCmdCopy(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         copyOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x --title t",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "title",
			cli:  "--title t",
			wants: copyOpts{
				title: "t",
			},
		},
		{
			name: "number",
			cli:  "123 --title t",
			wants: copyOpts{
				number: 123,
				title:  "t",
			},
		},
+ 70 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project copy
short: Copy a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: drafts
      value_type: bool
      default_value: "false"
      description: Include draft issues when copying
    - option: format
      value_type: string
DOCS
gh_project_copy.md:21Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project copy
short: Copy a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: drafts
      value_type: bool
      default_value: "false"
      description: Include draft issues when copying
    - option: format
      value_type: string
DOCS
gh_project_copy.md:22Markdown · 11 words
TESTS
pkg/cmd/project/copy/copy_test.go:14pkg/cmd/project/copy/copy_test::TestNewCmdCopy · Go · 100 lines
func TestNewCmdCopy(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         copyOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x --title t",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "title",
			cli:  "--title t",
			wants: copyOpts{
				title: "t",
			},
		},
		{
			name: "number",
			cli:  "123 --title t",
			wants: copyOpts{
				number: 123,
				title:  "t",
			},
		},
+ 70 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project copy
short: Copy a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: drafts
      value_type: bool
      default_value: "false"
      description: Include draft issues when copying
    - option: format
      value_type: string
DOCS
gh_project_copy.md:23Markdown · 11 words
TESTS
pkg/cmd/project/copy/copy_test.go:14pkg/cmd/project/copy/copy_test::TestNewCmdCopy · Go · 100 lines
func TestNewCmdCopy(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         copyOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x --title t",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "title",
			cli:  "--title t",
			wants: copyOpts{
				title: "t",
			},
		},
		{
			name: "number",
			cli:  "123 --title t",
			wants: copyOpts{
				number: 123,
				title:  "t",
			},
		},
+ 70 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project copy
short: Copy a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: drafts
      value_type: bool
      default_value: "false"
      description: Include draft issues when copying
    - option: format
      value_type: string
DOCS
gh_project_copy.md:24Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project copy
short: Copy a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: drafts
      value_type: bool
      default_value: "false"
      description: Include draft issues when copying
    - option: format
      value_type: string
DOCS
gh_project_copy.md:25Markdown · 5 words
TESTS
pkg/cmd/project/copy/copy_test.go:14pkg/cmd/project/copy/copy_test::TestNewCmdCopy · Go · 100 lines
func TestNewCmdCopy(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         copyOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x --title t",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "title",
			cli:  "--title t",
			wants: copyOpts{
				title: "t",
			},
		},
		{
			name: "number",
			cli:  "123 --title t",
			wants: copyOpts{
				number: 123,
				title:  "t",
			},
		},
+ 70 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project create
short: Create a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_create.md:1Markdown · 13 words
TESTS
pkg/cmd/issue/create/create_test.go:1175pkg/cmd/issue/create/create_test::TestIssueCreate_projectsV2 · Go · 87 lines
func TestIssueCreate_projectsV2(t *testing.T) {
	http := &httpmock.Registry{}
	defer http.Verify(t)

	http.StubIssueRepoInfoResponse("OWNER", "REPO")
	http.Register(
		httpmock.GraphQL(`query RepositoryProjectList\b`),
		httpmock.StringResponse(`
		{ "data": { "repository": { "projects": {
			"nodes": [],
			"pageInfo": { "hasNextPage": false }
		} } } }
		`))
	http.Register(
		httpmock.GraphQL(`query OrganizationProjectList\b`),
		httpmock.StringResponse(`
		{	"data": { "organization": { "projects": {
			"nodes": [],
			"pageInfo": { "hasNextPage": false }
		} } } }
		`))
	http.Register(
		httpmock.GraphQL(`query RepositoryProjectV2List\b`),
		httpmock.StringResponse(`
		{ "data": { "repository": { "projectsV2": {
			"nodes": [
				{ "title": "CleanupV2", "id": "CLEANUPV2ID" },
				{ "title": "RoadmapV2", "id": "ROADMAPV2ID" }
			],
			"pageInfo": { "hasNextPage": false }
+ 57 more lines · read full file
pkg/cmd/issue/create/create_test.go:1265pkg/cmd/issue/create/create_test::TestProjectsV1Deprecation · Go · 140 lines
func TestProjectsV1Deprecation(t *testing.T) {

	t.Run("non-interactive submission", func(t *testing.T) {
		t.Run("when projects v1 is supported, queries for it", func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()

			reg := &httpmock.Registry{}
			reg.StubIssueRepoInfoResponse("OWNER", "REPO")
			reg.Register(
				// ( is required to avoid matching projectsV2
				httpmock.GraphQL(`projects\(`),
				// Simulate a GraphQL error to early exit the test.
				httpmock.StatusStringResponse(500, ""),
			)

			_, cmdTeardown := run.Stub()
			defer cmdTeardown(t)

			// Ignore the error because we have no way to really stub it without
			// fully stubbing a GQL error structure in the request body.
			_ = createRun(&CreateOptions{
				IO: ios,
				HttpClient: func() (*http.Client, error) {
					return &http.Client{Transport: reg}, nil
				},
				BaseRepo: func() (ghrepo.Interface, error) {
					return ghrepo.New("OWNER", "REPO"), nil
				},

				Detector: &fd.EnabledDetectorMock{},
+ 110 more lines · read full file
pkg/cmd/issue/create/create_test.go:1339pkg/cmd/issue/create/create_test::when projects v1 is supported, queries for it · Go · 34 lines
t.Run("when projects v1 is supported, queries for it", func(t *testing.T) {
	ios, _, _, _ := iostreams.Test()

	reg := &httpmock.Registry{}
	reg.Register(
		// ( is required to avoid matching projectsV2
		httpmock.GraphQL(`projects\(`),
		// Simulate a GraphQL error to early exit the test.
		httpmock.StatusStringResponse(500, ""),
	)

	_, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	// Ignore the error because we have no way to really stub it without
	// fully stubbing a GQL error structure in the request body.
	_ = createRun(&CreateOptions{
		IO: ios,
		HttpClient: func() (*http.Client, error) {
			return &http.Client{Transport: reg}, nil
		},
		BaseRepo: func() (ghrepo.Interface, error) {
			return ghrepo.New("OWNER", "REPO"), nil
		},

		Detector: &fd.EnabledDetectorMock{},
		WebMode:  true,
		// Required to force a lookup of projects
		Projects: []string{"Project"},
	})
+ 4 more lines · read full file
+ 9 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh project create
short: Create a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_create.md:19Markdown · 3 words
TESTS
pkg/cmd/project/create/create_test.go:14pkg/cmd/project/create/create_test::TestNewCmdCreate · Go · 67 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         createOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name: "title",
			cli:  "--title t",
			wants: createOpts{
				title: "t",
			},
		},
		{
			name: "owner",
			cli:  "--title t --owner monalisa",
			wants: createOpts{
				owner: "monalisa",
				title: "t",
			},
		},
		{
			name: "json",
			cli:  "--title t --format json",
			wants: createOpts{
				title: "t",
			},
+ 37 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project create
short: Create a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_create.md:20Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project create
short: Create a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_create.md:21Markdown · 10 words
TESTS
pkg/cmd/project/create/create_test.go:14pkg/cmd/project/create/create_test::TestNewCmdCreate · Go · 67 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         createOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name: "title",
			cli:  "--title t",
			wants: createOpts{
				title: "t",
			},
		},
		{
			name: "owner",
			cli:  "--title t --owner monalisa",
			wants: createOpts{
				owner: "monalisa",
				title: "t",
			},
		},
		{
			name: "json",
			cli:  "--title t --format json",
			wants: createOpts{
				title: "t",
			},
+ 37 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project create
short: Create a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_create.md:22Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project create
short: Create a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_create.md:23Markdown · 4 words
TESTS
pkg/cmd/project/create/create_test.go:14pkg/cmd/project/create/create_test::TestNewCmdCreate · Go · 67 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         createOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name: "title",
			cli:  "--title t",
			wants: createOpts{
				title: "t",
			},
		},
		{
			name: "owner",
			cli:  "--title t --owner monalisa",
			wants: createOpts{
				owner: "monalisa",
				title: "t",
			},
		},
		{
			name: "json",
			cli:  "--title t --format json",
			wants: createOpts{
				title: "t",
			},
+ 37 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project delete
short: Delete a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_delete.md:1Markdown · 13 words
TESTS
pkg/cmd/project/delete/delete_test.go:14pkg/cmd/project/delete/delete_test::TestNewCmdDelete · Go · 69 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         deleteOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "number",
			cli:  "123",
			wants: deleteOpts{
				number: 123,
			},
		},
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: deleteOpts{
				owner: "monalisa",
			},
		},
		{
+ 39 more lines · read full file
pkg/cmd/project/delete/delete_test.go:84pkg/cmd/project/delete/delete_test::TestRunDelete_User · Go · 91 lines
func TestRunDelete_User(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "monalisa",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})

	// get project ID
+ 61 more lines · read full file
pkg/cmd/project/delete/delete_test.go:176pkg/cmd/project/delete/delete_test::TestRunDelete_Org · Go · 91 lines
func TestRunDelete_Org(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// get org ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "github",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"organization": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"user"},
				},
			},
		})

	// get project ID
+ 61 more lines · read full file
+ 2 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh project delete
short: Delete a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_delete.md:19Markdown · 3 words
TESTS
pkg/cmd/project/delete/delete_test.go:14pkg/cmd/project/delete/delete_test::TestNewCmdDelete · Go · 69 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         deleteOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "number",
			cli:  "123",
			wants: deleteOpts{
				number: 123,
			},
		},
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: deleteOpts{
				owner: "monalisa",
			},
		},
		{
+ 39 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project delete
short: Delete a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_delete.md:20Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project delete
short: Delete a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_delete.md:21Markdown · 10 words
TESTS
pkg/cmd/project/delete/delete_test.go:14pkg/cmd/project/delete/delete_test::TestNewCmdDelete · Go · 69 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         deleteOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "number",
			cli:  "123",
			wants: deleteOpts{
				number: 123,
			},
		},
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: deleteOpts{
				owner: "monalisa",
			},
		},
		{
+ 39 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project delete
short: Delete a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_delete.md:22Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project edit
short: Edit a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: description
      shorthand: d
      value_type: string
      description: New description of the project
    - option: format
      value_type: string
DOCS
gh_project_edit.md:1Markdown · 13 words
TESTS
pkg/cmd/issue/edit/edit_test.go:1019pkg/cmd/issue/edit/edit_test::TestProjectsV1Deprecation · Go · 82 lines
func TestProjectsV1Deprecation(t *testing.T) {
	t.Run("when projects v1 is supported, is included in query", func(t *testing.T) {
		ios, _, _, _ := iostreams.Test()

		reg := &httpmock.Registry{}
		reg.Register(
			httpmock.GraphQL(`projectCards`),
			// Simulate a GraphQL error to early exit the test.
			httpmock.StatusStringResponse(500, ""),
		)

		_, cmdTeardown := run.Stub()
		defer cmdTeardown(t)

		// Ignore the error because we have no way to really stub it without
		// fully stubbing a GQL error structure in the request body.
		_ = editRun(&EditOptions{
			IO: ios,
			HttpClient: func() (*http.Client, error) {
				return &http.Client{Transport: reg}, nil
			},
			BaseRepo: func() (ghrepo.Interface, error) {
				return ghrepo.New("OWNER", "REPO"), nil
			},
			Detector: &fd.EnabledDetectorMock{},

			IssueNumbers: []int{123},
			Editable: prShared.Editable{
				Projects: prShared.EditableProjects{
					EditableSlice: prShared.EditableSlice{
+ 52 more lines · read full file
pkg/cmd/issue/edit/edit_test.go:1020pkg/cmd/issue/edit/edit_test::when projects v1 is supported, is included in query · Go · 39 lines
t.Run("when projects v1 is supported, is included in query", func(t *testing.T) {
	ios, _, _, _ := iostreams.Test()

	reg := &httpmock.Registry{}
	reg.Register(
		httpmock.GraphQL(`projectCards`),
		// Simulate a GraphQL error to early exit the test.
		httpmock.StatusStringResponse(500, ""),
	)

	_, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	// Ignore the error because we have no way to really stub it without
	// fully stubbing a GQL error structure in the request body.
	_ = editRun(&EditOptions{
		IO: ios,
		HttpClient: func() (*http.Client, error) {
			return &http.Client{Transport: reg}, nil
		},
		BaseRepo: func() (ghrepo.Interface, error) {
			return ghrepo.New("OWNER", "REPO"), nil
		},
		Detector: &fd.EnabledDetectorMock{},

		IssueNumbers: []int{123},
		Editable: prShared.Editable{
			Projects: prShared.EditableProjects{
				EditableSlice: prShared.EditableSlice{
					Add:    []string{"Test Project"},
+ 9 more lines · read full file
pkg/cmd/issue/edit/edit_test.go:1060pkg/cmd/issue/edit/edit_test::when projects v1 is not supported, is not included in query · Go · 40 lines
t.Run("when projects v1 is not supported, is not included in query", func(t *testing.T) {
	ios, _, _, _ := iostreams.Test()

	reg := &httpmock.Registry{}
	reg.Exclude(t, httpmock.GraphQL(`projectCards`))

	reg.Register(
		httpmock.GraphQL(`.*`),
		// Simulate a GraphQL error to early exit the test.
		httpmock.StatusStringResponse(500, ""),
	)

	_, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	// Ignore the error because we're not really interested in it.
	_ = editRun(&EditOptions{
		IO: ios,
		HttpClient: func() (*http.Client, error) {
			return &http.Client{Transport: reg}, nil
		},
		BaseRepo: func() (ghrepo.Interface, error) {
			return ghrepo.New("OWNER", "REPO"), nil
		},
		Detector: &fd.DisabledDetectorMock{},

		IssueNumbers: []int{123},
		Editable: prShared.Editable{
			Projects: prShared.EditableProjects{
				EditableSlice: prShared.EditableSlice{
+ 10 more lines · read full file
+ 9 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project edit
short: Edit a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: description
      shorthand: d
      value_type: string
      description: New description of the project
    - option: format
      value_type: string
DOCS
gh_project_edit.md:19Markdown · 5 words
TESTS
pkg/cmd/project/edit/edit_test.go:14pkg/cmd/project/edit/edit_test::TestNewCmdEdit · Go · 118 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         editOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "visibility-error",
			cli:         "--visibility v",
			wantsErr:    true,
			wantsErrMsg: "invalid argument \"v\" for \"--visibility\" flag: valid values are {PUBLIC|PRIVATE}",
		},
		{
			name:        "no-args",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "no fields to edit",
		},
		{
			name: "title",
			cli:  "--title t",
+ 88 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project edit
short: Edit a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: description
      shorthand: d
      value_type: string
      description: New description of the project
    - option: format
      value_type: string
DOCS
gh_project_edit.md:20Markdown · 3 words
TESTS
pkg/cmd/project/edit/edit_test.go:14pkg/cmd/project/edit/edit_test::TestNewCmdEdit · Go · 118 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         editOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "visibility-error",
			cli:         "--visibility v",
			wantsErr:    true,
			wantsErrMsg: "invalid argument \"v\" for \"--visibility\" flag: valid values are {PUBLIC|PRIVATE}",
		},
		{
			name:        "no-args",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "no fields to edit",
		},
		{
			name: "title",
			cli:  "--title t",
+ 88 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project edit
short: Edit a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: description
      shorthand: d
      value_type: string
      description: New description of the project
    - option: format
      value_type: string
DOCS
gh_project_edit.md:21Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project edit
short: Edit a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: description
      shorthand: d
      value_type: string
      description: New description of the project
    - option: format
      value_type: string
DOCS
gh_project_edit.md:22Markdown · 10 words
TESTS
pkg/cmd/project/edit/edit_test.go:14pkg/cmd/project/edit/edit_test::TestNewCmdEdit · Go · 118 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         editOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "visibility-error",
			cli:         "--visibility v",
			wantsErr:    true,
			wantsErrMsg: "invalid argument \"v\" for \"--visibility\" flag: valid values are {PUBLIC|PRIVATE}",
		},
		{
			name:        "no-args",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "no fields to edit",
		},
		{
			name: "title",
			cli:  "--title t",
+ 88 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project edit
short: Edit a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: description
      shorthand: d
      value_type: string
      description: New description of the project
    - option: format
      value_type: string
DOCS
gh_project_edit.md:23Markdown · 5 words
TESTS
pkg/cmd/project/edit/edit_test.go:14pkg/cmd/project/edit/edit_test::TestNewCmdEdit · Go · 118 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         editOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "visibility-error",
			cli:         "--visibility v",
			wantsErr:    true,
			wantsErrMsg: "invalid argument \"v\" for \"--visibility\" flag: valid values are {PUBLIC|PRIVATE}",
		},
		{
			name:        "no-args",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "no fields to edit",
		},
		{
			name: "title",
			cli:  "--title t",
+ 88 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project edit
short: Edit a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: description
      shorthand: d
      value_type: string
      description: New description of the project
    - option: format
      value_type: string
DOCS
gh_project_edit.md:24Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project edit
short: Edit a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: description
      shorthand: d
      value_type: string
      description: New description of the project
    - option: format
      value_type: string
DOCS
gh_project_edit.md:25Markdown · 5 words
TESTS
pkg/cmd/project/edit/edit_test.go:14pkg/cmd/project/edit/edit_test::TestNewCmdEdit · Go · 118 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         editOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "visibility-error",
			cli:         "--visibility v",
			wantsErr:    true,
			wantsErrMsg: "invalid argument \"v\" for \"--visibility\" flag: valid values are {PUBLIC|PRIVATE}",
		},
		{
			name:        "no-args",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "no fields to edit",
		},
		{
			name: "title",
			cli:  "--title t",
+ 88 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project edit
short: Edit a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: description
      shorthand: d
      value_type: string
      description: New description of the project
    - option: format
      value_type: string
DOCS
gh_project_edit.md:26Markdown · 4 words
TESTS
pkg/cmd/project/edit/edit_test.go:14pkg/cmd/project/edit/edit_test::TestNewCmdEdit · Go · 118 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         editOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "visibility-error",
			cli:         "--visibility v",
			wantsErr:    true,
			wantsErrMsg: "invalid argument \"v\" for \"--visibility\" flag: valid values are {PUBLIC|PRIVATE}",
		},
		{
			name:        "no-args",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "no fields to edit",
		},
		{
			name: "title",
			cli:  "--title t",
+ 88 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-create
short: Create a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: data-type
      value_type: string
      description: 'DataType of the new field.: {TEXT|SINGLE_SELECT|DATE|NUMBER}'
DOCS
gh_project_field-create.md:1Markdown · 16 words
TESTS
pkg/cmd/project/field-create/field_create_test.go:14pkg/cmd/project/field-create/field_create_test::TestNewCmdCreateField · Go · 104 lines
func TestNewCmdCreateField(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         createFieldOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "missing-name-and-data-type",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "required flag(s) \"data-type\", \"name\" not set",
		},
		{
			name:        "not-a-number",
			cli:         "x  --name n --data-type TEXT",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "single-select-no-options",
			cli:         "123 --name n --data-type SINGLE_SELECT",
			wantsErr:    true,
			wantsErrMsg: "passing `--single-select-options` is required for SINGLE_SELECT data type",
		},
		{
			name: "number",
			cli:  "123 --name n --data-type TEXT",
+ 74 more lines · read full file
pkg/cmd/project/field-create/field_create_test.go:119pkg/cmd/project/field-create/field_create_test::TestRunCreateField_User · Go · 92 lines
func TestRunCreateField_User(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "monalisa",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})

	// get project ID
+ 62 more lines · read full file
pkg/cmd/project/field-create/field_create_test.go:212pkg/cmd/project/field-create/field_create_test::TestRunCreateField_Org · Go · 92 lines
func TestRunCreateField_Org(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// get org ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "github",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"organization": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"user"},
				},
			},
		})

	// get project ID
+ 62 more lines · read full file
+ 5 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh project field-create
short: Create a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: data-type
      value_type: string
      description: 'DataType of the new field.: {TEXT|SINGLE_SELECT|DATE|NUMBER}'
DOCS
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-create
short: Create a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: data-type
      value_type: string
      description: 'DataType of the new field.: {TEXT|SINGLE_SELECT|DATE|NUMBER}'
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-create
short: Create a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: data-type
      value_type: string
      description: 'DataType of the new field.: {TEXT|SINGLE_SELECT|DATE|NUMBER}'
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-create
short: Create a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: data-type
      value_type: string
      description: 'DataType of the new field.: {TEXT|SINGLE_SELECT|DATE|NUMBER}'
DOCS
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-create
short: Create a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: data-type
      value_type: string
      description: 'DataType of the new field.: {TEXT|SINGLE_SELECT|DATE|NUMBER}'
DOCS
gh_project_field-create.md:23Markdown · 10 words
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-create
short: Create a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: data-type
      value_type: string
      description: 'DataType of the new field.: {TEXT|SINGLE_SELECT|DATE|NUMBER}'
DOCS
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-create
short: Create a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: data-type
      value_type: string
      description: 'DataType of the new field.: {TEXT|SINGLE_SELECT|DATE|NUMBER}'
DOCS
gh_project_field-create.md:25Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-delete
short: Delete a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_field-delete.md:1Markdown · 15 words
TESTS
pkg/cmd/project/field-delete/field_delete_test.go:14pkg/cmd/project/field-delete/field_delete_test::TestNewCmdDeleteField · Go · 64 lines
func TestNewCmdDeleteField(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         deleteFieldOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "no id",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "required flag(s) \"id\" not set",
		},
		{
			name: "id",
			cli:  "--id 123",
			wants: deleteFieldOpts{
				fieldID: "123",
			},
		},
		{
			name: "json",
			cli:  "--id 123 --format json",
			wants: deleteFieldOpts{
				fieldID: "123",
			},
			wantsExporter: true,
		},
+ 34 more lines · read full file
pkg/cmd/project/field-delete/field_delete_test.go:79pkg/cmd/project/field-delete/field_delete_test::TestRunDeleteField · Go · 38 lines
func TestRunDeleteField(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// delete Field
	gock.New("https://api.github.com").
		Post("/graphql").
		BodyString(`{"query":"mutation DeleteField.*","variables":{"input":{"fieldId":"an ID"}}}`).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"deleteProjectV2Field": map[string]interface{}{
					"projectV2Field": map[string]interface{}{
						"id": "Field ID",
					},
				},
			},
		})

	client := queries.NewTestClient()

	ios, _, stdout, _ := iostreams.Test()
	ios.SetStdoutTTY(true)
	config := deleteFieldConfig{
		opts: deleteFieldOpts{
			fieldID: "an ID",
		},
		client: client,
		io:     ios,
	}
+ 8 more lines · read full file
pkg/cmd/project/field-delete/field_delete_test.go:118pkg/cmd/project/field-delete/field_delete_test::TestRunDeleteField_JSON · Go · 40 lines
func TestRunDeleteField_JSON(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// delete Field
	gock.New("https://api.github.com").
		Post("/graphql").
		BodyString(`{"query":"mutation DeleteField.*","variables":{"input":{"fieldId":"an ID"}}}`).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"deleteProjectV2Field": map[string]interface{}{
					"projectV2Field": map[string]interface{}{
						"__typename": "ProjectV2Field",
						"id":         "Field ID",
						"name":       "a name",
					},
				},
			},
		})

	client := queries.NewTestClient()

	ios, _, stdout, _ := iostreams.Test()
	config := deleteFieldConfig{
		opts: deleteFieldOpts{
			fieldID:  "an ID",
			exporter: cmdutil.NewJSONExporter(),
		},
		client: client,
+ 10 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh project field-delete
short: Delete a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-delete
short: Delete a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-delete
short: Delete a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-delete
short: Delete a field in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_field-delete.md:22Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-list
short: List the fields in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_field-list.md:1Markdown · 16 words
TESTS
pkg/cmd/project/field-list/field_list_test.go:15pkg/cmd/project/field-list/field_list_test::TestNewCmdList · Go · 75 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         listOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "number",
			cli:  "123",
			wants: listOpts{
				number: 123,
				limit:  30,
			},
		},
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: listOpts{
				owner: "monalisa",
				limit: 30,
			},
+ 45 more lines · read full file
pkg/cmd/project/field-list/field_list_test.go:91pkg/cmd/project/field-list/field_list_test::TestRunList_User_tty · Go · 94 lines
func TestRunList_User_tty(t *testing.T) {
	defer gock.Off()
	// gock.Observe(gock.DumpRequest)

	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "monalisa",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})

	// list project fields
+ 64 more lines · read full file
pkg/cmd/project/field-list/field_list_test.go:186pkg/cmd/project/field-list/field_list_test::TestRunList_User · Go · 91 lines
func TestRunList_User(t *testing.T) {
	defer gock.Off()
	// gock.Observe(gock.DumpRequest)

	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "monalisa",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})

	// list project fields
+ 61 more lines · read full file
+ 4 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh project field-list
short: List the fields in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_field-list.md:19Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-list
short: List the fields in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_field-list.md:20Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-list
short: List the fields in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_field-list.md:21Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project field-list
short: List the fields in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_field-list.md:22Markdown · 10 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project field-list
short: List the fields in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_field-list.md:23Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-add
short: Add a pull request or an issue to a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-add.md:1Markdown · 20 words
TESTS
pkg/cmd/project/item-add/item_add_test.go:14pkg/cmd/project/item-add/item_add_test::TestNewCmdaddItem · Go · 88 lines
func TestNewCmdaddItem(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         addItemOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "missing-url",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "required flag(s) \"url\" not set",
		},
		{
			name:        "not-a-number",
			cli:         "x --url github.com/cli/cli",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "url",
			cli:  "--url github.com/cli/cli",
			wants: addItemOpts{
				itemURL: "github.com/cli/cli",
			},
		},
		{
			name: "number",
+ 58 more lines · read full file
pkg/cmd/project/item-add/item_add_test.go:103pkg/cmd/project/item-add/item_add_test::TestRunAddItem_User · Go · 111 lines
func TestRunAddItem_User(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "monalisa",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})

	// get project ID
+ 81 more lines · read full file
pkg/cmd/project/item-add/item_add_test.go:215pkg/cmd/project/item-add/item_add_test::TestRunAddItem_Org · Go · 110 lines
func TestRunAddItem_Org(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)
	// get org ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "github",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"organization": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"user"},
				},
			},
		})

	// get project ID
	gock.New("https://api.github.com").
+ 80 more lines · read full file
+ 2 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh project item-add
short: Add a pull request or an issue to a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-add.md:19Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-add
short: Add a pull request or an issue to a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-add.md:20Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-add
short: Add a pull request or an issue to a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-add.md:21Markdown · 10 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-add
short: Add a pull request or an issue to a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-add.md:22Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-add
short: Add a pull request or an issue to a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-add.md:23Markdown · 12 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-archive
short: Archive an item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-archive.md:1Markdown · 16 words
TESTS
pkg/cmd/project/item-archive/item_archive_test.go:14pkg/cmd/project/item-archive/item_archive_test::TestNewCmdarchiveItem · Go · 97 lines
func TestNewCmdarchiveItem(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         archiveItemOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "missing-id",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "required flag(s) \"id\" not set",
		},
		{
			name:        "not-a-number",
			cli:         "x --id 123",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "id",
			cli:  "--id 123",
			wants: archiveItemOpts{
				itemID: "123",
			},
		},
		{
			name: "number",
+ 67 more lines · read full file
pkg/cmd/project/item-archive/item_archive_test.go:112pkg/cmd/project/item-archive/item_archive_test::TestRunArchive_User · Go · 91 lines
func TestRunArchive_User(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "monalisa",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})

	// get project ID
+ 61 more lines · read full file
pkg/cmd/project/item-archive/item_archive_test.go:204pkg/cmd/project/item-archive/item_archive_test::TestRunArchive_Org · Go · 90 lines
func TestRunArchive_Org(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)
	// get org ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "github",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"organization": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"user"},
				},
			},
		})

	// get project ID
	gock.New("https://api.github.com").
+ 60 more lines · read full file
+ 5 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh project item-archive
short: Archive an item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-archive
short: Archive an item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-archive
short: Archive an item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-archive
short: Archive an item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-archive.md:22Markdown · 10 words
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-archive
short: Archive an item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-archive.md:23Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-archive
short: Archive an item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-create
short: Create a draft issue item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
      value_type: string
      description: Body for the draft issue
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-create.md:1Markdown · 18 words
TESTS
pkg/cmd/project/item-create/item_create_test.go:14pkg/cmd/project/item-create/item_create_test::TestNewCmdCreateItem · Go · 96 lines
func TestNewCmdCreateItem(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         createItemOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "missing-title",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "required flag(s) \"title\" not set",
		},
		{
			name:        "not-a-number",
			cli:         "x --title t",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "title",
			cli:  "--title t",
			wants: createItemOpts{
				title: "t",
			},
		},
		{
			name: "number",
+ 66 more lines · read full file
pkg/cmd/project/item-create/item_create_test.go:111pkg/cmd/project/item-create/item_create_test::TestRunCreateItem_Draft_User · Go · 90 lines
func TestRunCreateItem_Draft_User(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)
	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "monalisa",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})

	// get project ID
	gock.New("https://api.github.com").
+ 60 more lines · read full file
pkg/cmd/project/item-create/item_create_test.go:202pkg/cmd/project/item-create/item_create_test::TestRunCreateItem_Draft_Org · Go · 90 lines
func TestRunCreateItem_Draft_Org(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)
	// get org ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "github",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"organization": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"user"},
				},
			},
		})

	// get project ID
	gock.New("https://api.github.com").
+ 60 more lines · read full file
+ 2 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh project item-create
short: Create a draft issue item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
      value_type: string
      description: Body for the draft issue
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-create.md:19Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-create
short: Create a draft issue item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
      value_type: string
      description: Body for the draft issue
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-create.md:20Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-create
short: Create a draft issue item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
      value_type: string
      description: Body for the draft issue
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-create.md:21Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-create
short: Create a draft issue item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
      value_type: string
      description: Body for the draft issue
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-create.md:22Markdown · 10 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-create
short: Create a draft issue item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
      value_type: string
      description: Body for the draft issue
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-create.md:23Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-create
short: Create a draft issue item in a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
      value_type: string
      description: Body for the draft issue
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-create.md:24Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-delete
short: Delete an item from a project by ID
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-delete.md:1Markdown · 18 words
TESTS
pkg/cmd/project/item-delete/item_delete_test.go:14pkg/cmd/project/item-delete/item_delete_test::TestNewCmdDeleteItem · Go · 88 lines
func TestNewCmdDeleteItem(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         deleteItemOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "missing-id",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "required flag(s) \"id\" not set",
		},
		{
			name:        "not-a-number",
			cli:         "x --id 123",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "item-id",
			cli:  "--id 123",
			wants: deleteItemOpts{
				itemID: "123",
			},
		},
		{
			name: "number",
+ 58 more lines · read full file
pkg/cmd/project/item-delete/item_delete_test.go:103pkg/cmd/project/item-delete/item_delete_test::TestRunDelete_User · Go · 88 lines
func TestRunDelete_User(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)
	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "monalisa",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})

	// get project ID
	gock.New("https://api.github.com").
+ 58 more lines · read full file
pkg/cmd/project/item-delete/item_delete_test.go:192pkg/cmd/project/item-delete/item_delete_test::TestRunDelete_Org · Go · 88 lines
func TestRunDelete_Org(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)
	// get org ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "github",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"organization": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"user"},
				},
			},
		})

	// get project ID
	gock.New("https://api.github.com").
+ 58 more lines · read full file
+ 2 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh project item-delete
short: Delete an item from a project by ID
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-delete.md:19Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-delete
short: Delete an item from a project by ID
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-delete.md:20Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-delete
short: Delete an item from a project by ID
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-delete.md:21Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-delete
short: Delete an item from a project by ID
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-delete.md:22Markdown · 10 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-delete
short: Delete an item from a project by ID
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_item-delete.md:23Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:1Markdown · 59 words
TESTS
pkg/cmd/project/item-edit/item_edit_test.go:14pkg/cmd/project/item-edit/item_edit_test::TestNewCmdeditItem · Go · 174 lines
func TestNewCmdeditItem(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         editItemOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "missing-id",
			cli:         "",
			wantsErr:    true,
			wantsErrMsg: "required flag(s) \"id\" not set",
		},
		{
			name:        "invalid-flags",
			cli:         "--id 123 --text t --date 2023-01-01",
			wantsErr:    true,
			wantsErrMsg: "only one of `--text`, `--number`, `--date`, `--single-select-option-id` or `--iteration-id` may be used",
		},
		{
			name: "item-id",
			cli:  "--id 123",
			wants: editItemOpts{
				itemID: "123",
			},
		},
		{
			name: "number",
+ 144 more lines · read full file
pkg/cmd/project/item-edit/item_edit_test.go:189pkg/cmd/project/item-edit/item_edit_test::TestRunItemEdit_Draft · Go · 44 lines
func TestRunItemEdit_Draft(t *testing.T) {
	defer gock.Off()
	// gock.Observe(gock.DumpRequest)

	// edit item
	gock.New("https://api.github.com").
		Post("/graphql").
		BodyString(`{"query":"mutation EditDraftIssueItem.*","variables":{"input":{"draftIssueId":"DI_item_id","title":"a title","body":"a new body"}}}`).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"updateProjectV2DraftIssue": map[string]interface{}{
					"draftIssue": map[string]interface{}{
						"title": "a title",
						"body":  "a new body",
					},
				},
			},
		})

	client := queries.NewTestClient()

	ios, _, stdout, _ := iostreams.Test()
	ios.SetStdoutTTY(true)

	config := editItemConfig{
		io: ios,
		opts: editItemOpts{
			title:        "a title",
			titleChanged: true,
+ 14 more lines · read full file
pkg/cmd/project/item-edit/item_edit_test.go:234pkg/cmd/project/item-edit/item_edit_test::TestRunItemEdit_DraftTitleOnly · Go · 55 lines
func TestRunItemEdit_DraftTitleOnly(t *testing.T) {
	defer gock.Off()

	gock.New("https://api.github.com").
		Post("/graphql").
		BodyString(`{"query":"query DraftIssueByID.*","variables":{"id":"DI_item_id"}}`).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"node": map[string]interface{}{
					"id":    "DI_item_id",
					"title": "existing title",
					"body":  "existing body",
				},
			},
		})

	gock.New("https://api.github.com").
		Post("/graphql").
		BodyString(`{"query":"mutation EditDraftIssueItem.*","variables":{"input":{"draftIssueId":"DI_item_id","title":"new title","body":"existing body"}}}`).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"updateProjectV2DraftIssue": map[string]interface{}{
					"draftIssue": map[string]interface{}{
						"title": "new title",
						"body":  "existing body",
					},
				},
			},
+ 25 more lines · read full file
+ 12 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:24Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:25Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:26Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:27Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:28Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:29Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:30Markdown · 10 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:31Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:32Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:33Markdown · 10 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:34Markdown · 12 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:35Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:36Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-edit
short: Edit either a draft issue or a project item. Both usages require the ID of the item to edit.
long: |-
    For non-draft issues, the ID of the project is also required, and only a single field value can be updated per invocation.

    Remove project item field value using `--clear` flag.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: body
DOCS
gh_project_item-edit.md:37Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-list
short: List the items in a project.
long: |-
    If supported by the API host (github.com and GHES 3.20+), the --query option can
DOCS
gh_project_item-list.md:1Markdown · 42 words
TESTS
pkg/cmd/issue/list/list_test.go:506pkg/cmd/issue/list/list_test::TestIssueList_withProjectItems · Go · 73 lines
func TestIssueList_withProjectItems(t *testing.T) {
	reg := &httpmock.Registry{}
	defer reg.Verify(t)

	reg.Register(
		httpmock.GraphQL(`query IssueList\b`),
		httpmock.GraphQLQuery(`{
			"data": {
			  "repository": {
				"hasIssuesEnabled": true,
				"issues": {
				  "totalCount": 1,
				  "nodes": [
					{
					  "projectItems": {
						"nodes": [
						  {
							"id": "PVTI_lAHOAA3WC84AW6WNzgJ8rnQ",
							"project": {
							  "id": "PVT_kwHOAA3WC84AW6WN",
							  "title": "Test Public Project"
							},
							"status": {
							  "optionId": "47fc9ee4",
							  "name": "In Progress"
							}
						  }
						],
						"totalCount": 1
					  }
+ 43 more lines · read full file
pkg/cmd/issue/list/list_test.go:580pkg/cmd/issue/list/list_test::TestIssueList_Search_withProjectItems · Go · 77 lines
func TestIssueList_Search_withProjectItems(t *testing.T) {
	reg := &httpmock.Registry{}
	defer reg.Verify(t)

	reg.Register(
		httpmock.GraphQL(`query IssueSearch\b`),
		httpmock.GraphQLQuery(`{
			"data": {
			  "repository": {
				"hasIssuesEnabled": true
			  },
			  "search": {
				"issueCount": 1,
				"nodes": [
				  {
					"projectItems": {
					  "nodes": [
						{
						  "id": "PVTI_lAHOAA3WC84AW6WNzgJ8rl0",
						  "project": {
							"id": "PVT_kwHOAA3WC84AW6WN",
							"title": "Test Public Project"
						  },
						  "status": {
							"optionId": "47fc9ee4",
							"name": "In Progress"
						  }
						}
					  ],
					  "totalCount": 1
+ 47 more lines · read full file
pkg/cmd/pr/list/list_test.go:335pkg/cmd/pr/list/list_test::TestPRList_withProjectItems · Go · 73 lines
func TestPRList_withProjectItems(t *testing.T) {
	reg := &httpmock.Registry{}
	defer reg.Verify(t)

	reg.Register(
		httpmock.GraphQL(`query PullRequestList\b`),
		httpmock.GraphQLQuery(`{
			"data": {
			  "repository": {
				"pullRequests": {
				  "totalCount": 1,
				  "nodes": [
					{
					  "projectItems": {
						"nodes": [
						  {
							"id": "PVTI_lAHOAA3WC84AW6WNzgJ8rnQ",
							"project": {
							  "id": "PVT_kwHOAA3WC84AW6WN",
							  "title": "Test Public Project"
							},
							"status": {
							  "optionId": "47fc9ee4",
							  "name": "In Progress"
							}
						  }
						],
						"totalCount": 1
					  }
					}
+ 43 more lines · read full file
+ 9 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh project item-list
short: List the items in a project.
long: |-
    If supported by the API host (github.com and GHES 3.20+), the --query option can
DOCS
gh_project_item-list.md:24Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-list
short: List the items in a project.
long: |-
    If supported by the API host (github.com and GHES 3.20+), the --query option can
DOCS
gh_project_item-list.md:25Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-list
short: List the items in a project.
long: |-
    If supported by the API host (github.com and GHES 3.20+), the --query option can
DOCS
gh_project_item-list.md:26Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project item-list
short: List the items in a project.
long: |-
    If supported by the API host (github.com and GHES 3.20+), the --query option can
DOCS
gh_project_item-list.md:27Markdown · 10 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-list
short: List the items in a project.
long: |-
    If supported by the API host (github.com and GHES 3.20+), the --query option can
DOCS
gh_project_item-list.md:28Markdown · 10 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project item-list
short: List the items in a project.
long: |-
    If supported by the API host (github.com and GHES 3.20+), the --query option can
DOCS
gh_project_item-list.md:29Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project link
short: Link a project to a repository or a team
pname: gh project
plink: gh_project.yaml
options:
    - option: owner
      value_type: string
      description: Login of the owner. Use "@me" for the current user.
    - option: repo
      shorthand: R
      value_type: string
      description: The repository to be linked to this project
DOCS
gh_project_link.md:1Markdown · 19 words
TESTS
pkg/cmd/project/link/link_test.go:18pkg/cmd/project/link/link_test::TestNewCmdLink · Go · 167 lines
func TestNewCmdLink(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         linkOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "specify-repo-and-team",
			cli:         "--repo my-repo --team my-team",
			wantsErr:    true,
			wantsErrMsg: "specify only one of `--repo` or `--team`",
		},
		{
			name: "specify-nothing",
			cli:  "",
			wants: linkOpts{
				owner: "OWNER",
				repo:  "REPO",
			},
		},
		{
+ 137 more lines · read full file
pkg/cmd/project/link/link_test.go:186pkg/cmd/project/link/link_test::TestRunLink_Repo · Go · 109 lines
func TestRunLink_Repo(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]string{
				"login": "monalisa",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id":    "an ID",
					"login": "monalisa",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})
+ 80 more lines · read full file
pkg/cmd/project/link/link_test.go:296pkg/cmd/project/link/link_test::TestRunLink_Team · Go · 111 lines
func TestRunLink_Team(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]string{
				"login": "monalisa-org",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id":    "an ID",
					"login": "monalisa-org",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})
+ 82 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project link
short: Link a project to a repository or a team
pname: gh project
plink: gh_project.yaml
options:
    - option: owner
      value_type: string
      description: Login of the owner. Use "@me" for the current user.
    - option: repo
      shorthand: R
      value_type: string
      description: The repository to be linked to this project
DOCS
gh_project_link.md:19Markdown · 10 words
TESTS
pkg/cmd/project/link/link_test.go:18pkg/cmd/project/link/link_test::TestNewCmdLink · Go · 167 lines
func TestNewCmdLink(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         linkOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "specify-repo-and-team",
			cli:         "--repo my-repo --team my-team",
			wantsErr:    true,
			wantsErrMsg: "specify only one of `--repo` or `--team`",
		},
		{
			name: "specify-nothing",
			cli:  "",
			wants: linkOpts{
				owner: "OWNER",
				repo:  "REPO",
			},
		},
		{
+ 137 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project link
short: Link a project to a repository or a team
pname: gh project
plink: gh_project.yaml
options:
    - option: owner
      value_type: string
      description: Login of the owner. Use "@me" for the current user.
    - option: repo
      shorthand: R
      value_type: string
      description: The repository to be linked to this project
DOCS
gh_project_link.md:20Markdown · 8 words
TESTS
pkg/cmd/project/link/link_test.go:18pkg/cmd/project/link/link_test::TestNewCmdLink · Go · 167 lines
func TestNewCmdLink(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         linkOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "specify-repo-and-team",
			cli:         "--repo my-repo --team my-team",
			wantsErr:    true,
			wantsErrMsg: "specify only one of `--repo` or `--team`",
		},
		{
			name: "specify-nothing",
			cli:  "",
			wants: linkOpts{
				owner: "OWNER",
				repo:  "REPO",
			},
		},
		{
+ 137 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project link
short: Link a project to a repository or a team
pname: gh project
plink: gh_project.yaml
options:
    - option: owner
      value_type: string
      description: Login of the owner. Use "@me" for the current user.
    - option: repo
      shorthand: R
      value_type: string
      description: The repository to be linked to this project
DOCS
gh_project_link.md:21Markdown · 8 words
TESTS
pkg/cmd/project/link/link_test.go:18pkg/cmd/project/link/link_test::TestNewCmdLink · Go · 167 lines
func TestNewCmdLink(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         linkOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "specify-repo-and-team",
			cli:         "--repo my-repo --team my-team",
			wantsErr:    true,
			wantsErrMsg: "specify only one of `--repo` or `--team`",
		},
		{
			name: "specify-nothing",
			cli:  "",
			wants: linkOpts{
				owner: "OWNER",
				repo:  "REPO",
			},
		},
		{
+ 137 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project list
short: List the projects for an owner
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: closed
      value_type: bool
      default_value: "false"
      description: Include closed projects
    - option: format
      value_type: string
DOCS
gh_project_list.md:1Markdown · 20 words
TESTS
pkg/cmd/issue/list/list_test.go:506pkg/cmd/issue/list/list_test::TestIssueList_withProjectItems · Go · 73 lines
func TestIssueList_withProjectItems(t *testing.T) {
	reg := &httpmock.Registry{}
	defer reg.Verify(t)

	reg.Register(
		httpmock.GraphQL(`query IssueList\b`),
		httpmock.GraphQLQuery(`{
			"data": {
			  "repository": {
				"hasIssuesEnabled": true,
				"issues": {
				  "totalCount": 1,
				  "nodes": [
					{
					  "projectItems": {
						"nodes": [
						  {
							"id": "PVTI_lAHOAA3WC84AW6WNzgJ8rnQ",
							"project": {
							  "id": "PVT_kwHOAA3WC84AW6WN",
							  "title": "Test Public Project"
							},
							"status": {
							  "optionId": "47fc9ee4",
							  "name": "In Progress"
							}
						  }
						],
						"totalCount": 1
					  }
+ 43 more lines · read full file
pkg/cmd/issue/list/list_test.go:580pkg/cmd/issue/list/list_test::TestIssueList_Search_withProjectItems · Go · 77 lines
func TestIssueList_Search_withProjectItems(t *testing.T) {
	reg := &httpmock.Registry{}
	defer reg.Verify(t)

	reg.Register(
		httpmock.GraphQL(`query IssueSearch\b`),
		httpmock.GraphQLQuery(`{
			"data": {
			  "repository": {
				"hasIssuesEnabled": true
			  },
			  "search": {
				"issueCount": 1,
				"nodes": [
				  {
					"projectItems": {
					  "nodes": [
						{
						  "id": "PVTI_lAHOAA3WC84AW6WNzgJ8rl0",
						  "project": {
							"id": "PVT_kwHOAA3WC84AW6WN",
							"title": "Test Public Project"
						  },
						  "status": {
							"optionId": "47fc9ee4",
							"name": "In Progress"
						  }
						}
					  ],
					  "totalCount": 1
+ 47 more lines · read full file
pkg/cmd/pr/list/list_test.go:335pkg/cmd/pr/list/list_test::TestPRList_withProjectItems · Go · 73 lines
func TestPRList_withProjectItems(t *testing.T) {
	reg := &httpmock.Registry{}
	defer reg.Verify(t)

	reg.Register(
		httpmock.GraphQL(`query PullRequestList\b`),
		httpmock.GraphQLQuery(`{
			"data": {
			  "repository": {
				"pullRequests": {
				  "totalCount": 1,
				  "nodes": [
					{
					  "projectItems": {
						"nodes": [
						  {
							"id": "PVTI_lAHOAA3WC84AW6WNzgJ8rnQ",
							"project": {
							  "id": "PVT_kwHOAA3WC84AW6WN",
							  "title": "Test Public Project"
							},
							"status": {
							  "optionId": "47fc9ee4",
							  "name": "In Progress"
							}
						  }
						],
						"totalCount": 1
					  }
					}
+ 43 more lines · read full file
+ 16 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project list
short: List the projects for an owner
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: closed
      value_type: bool
      default_value: "false"
      description: Include closed projects
    - option: format
      value_type: string
DOCS
gh_project_list.md:19Markdown · 3 words
TESTS
pkg/cmd/project/list/list_test.go:16pkg/cmd/project/list/list_test::TestNewCmdlist · Go · 78 lines
func TestNewCmdlist(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         listOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: listOpts{
				owner: "monalisa",
				limit: 30,
			},
		},
		{
			name: "closed",
			cli:  "--closed",
			wants: listOpts{
				closed: true,
				limit:  30,
			},
		},
		{
			name: "web",
			cli:  "--web",
			wants: listOpts{
				web:   true,
+ 48 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project list
short: List the projects for an owner
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: closed
      value_type: bool
      default_value: "false"
      description: Include closed projects
    - option: format
      value_type: string
DOCS
gh_project_list.md:20Markdown · 3 words
TESTS
pkg/cmd/project/list/list_test.go:16pkg/cmd/project/list/list_test::TestNewCmdlist · Go · 78 lines
func TestNewCmdlist(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         listOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: listOpts{
				owner: "monalisa",
				limit: 30,
			},
		},
		{
			name: "closed",
			cli:  "--closed",
			wants: listOpts{
				closed: true,
				limit:  30,
			},
		},
		{
			name: "web",
			cli:  "--web",
			wants: listOpts{
				web:   true,
+ 48 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project list
short: List the projects for an owner
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: closed
      value_type: bool
      default_value: "false"
      description: Include closed projects
    - option: format
      value_type: string
DOCS
gh_project_list.md:21Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project list
short: List the projects for an owner
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: closed
      value_type: bool
      default_value: "false"
      description: Include closed projects
    - option: format
      value_type: string
DOCS
gh_project_list.md:22Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project list
short: List the projects for an owner
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: closed
      value_type: bool
      default_value: "false"
      description: Include closed projects
    - option: format
      value_type: string
DOCS
gh_project_list.md:23Markdown · 4 words
TESTS
pkg/cmd/project/list/list_test.go:16pkg/cmd/project/list/list_test::TestNewCmdlist · Go · 78 lines
func TestNewCmdlist(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         listOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: listOpts{
				owner: "monalisa",
				limit: 30,
			},
		},
		{
			name: "closed",
			cli:  "--closed",
			wants: listOpts{
				closed: true,
				limit:  30,
			},
		},
		{
			name: "web",
			cli:  "--web",
			wants: listOpts{
				web:   true,
+ 48 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project list
short: List the projects for an owner
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: closed
      value_type: bool
      default_value: "false"
      description: Include closed projects
    - option: format
      value_type: string
DOCS
gh_project_list.md:24Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project list
short: List the projects for an owner
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: closed
      value_type: bool
      default_value: "false"
      description: Include closed projects
    - option: format
      value_type: string
DOCS
gh_project_list.md:25Markdown · 6 words
TESTS
pkg/cmd/project/list/list_test.go:16pkg/cmd/project/list/list_test::TestNewCmdlist · Go · 78 lines
func TestNewCmdlist(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         listOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: listOpts{
				owner: "monalisa",
				limit: 30,
			},
		},
		{
			name: "closed",
			cli:  "--closed",
			wants: listOpts{
				closed: true,
				limit:  30,
			},
		},
		{
			name: "web",
			cli:  "--web",
			wants: listOpts{
				web:   true,
+ 48 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project unlink
short: Unlink a project from a repository or a team
pname: gh project
plink: gh_project.yaml
options:
    - option: owner
      value_type: string
      description: Login of the owner. Use "@me" for the current user.
    - option: repo
      shorthand: R
      value_type: string
      description: The repository to be unlinked from this project
DOCS
gh_project_unlink.md:1Markdown · 19 words
TESTS
pkg/cmd/project/unlink/unlink_test.go:18pkg/cmd/project/unlink/unlink_test::TestNewCmdUnlink · Go · 167 lines
func TestNewCmdUnlink(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         unlinkOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "specify-repo-and-team",
			cli:         "--repo my-repo --team my-team",
			wantsErr:    true,
			wantsErrMsg: "specify only one of `--repo` or `--team`",
		},
		{
			name: "specify-nothing",
			cli:  "",
			wants: unlinkOpts{
				repo:  "REPO",
				owner: "OWNER",
			},
		},
		{
+ 137 more lines · read full file
pkg/cmd/project/unlink/unlink_test.go:186pkg/cmd/project/unlink/unlink_test::TestRunUnlink_Repo · Go · 109 lines
func TestRunUnlink_Repo(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]string{
				"login": "monalisa",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id":    "an ID",
					"login": "monalisa",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})
+ 80 more lines · read full file
pkg/cmd/project/unlink/unlink_test.go:296pkg/cmd/project/unlink/unlink_test::TestRunUnlink_Team · Go · 111 lines
func TestRunUnlink_Team(t *testing.T) {
	defer gock.Off()
	gock.Observe(gock.DumpRequest)

	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]string{
				"login": "monalisa-org",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id":    "an ID",
					"login": "monalisa-org",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})
+ 82 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh project unlink
short: Unlink a project from a repository or a team
pname: gh project
plink: gh_project.yaml
options:
    - option: owner
      value_type: string
      description: Login of the owner. Use "@me" for the current user.
    - option: repo
      shorthand: R
      value_type: string
      description: The repository to be unlinked from this project
DOCS
gh_project_unlink.md:19Markdown · 10 words
TESTS
pkg/cmd/project/unlink/unlink_test.go:18pkg/cmd/project/unlink/unlink_test::TestNewCmdUnlink · Go · 167 lines
func TestNewCmdUnlink(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         unlinkOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "specify-repo-and-team",
			cli:         "--repo my-repo --team my-team",
			wantsErr:    true,
			wantsErrMsg: "specify only one of `--repo` or `--team`",
		},
		{
			name: "specify-nothing",
			cli:  "",
			wants: unlinkOpts{
				repo:  "REPO",
				owner: "OWNER",
			},
		},
		{
+ 137 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project unlink
short: Unlink a project from a repository or a team
pname: gh project
plink: gh_project.yaml
options:
    - option: owner
      value_type: string
      description: Login of the owner. Use "@me" for the current user.
    - option: repo
      shorthand: R
      value_type: string
      description: The repository to be unlinked from this project
DOCS
gh_project_unlink.md:20Markdown · 8 words
TESTS
pkg/cmd/project/unlink/unlink_test.go:18pkg/cmd/project/unlink/unlink_test::TestNewCmdUnlink · Go · 167 lines
func TestNewCmdUnlink(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         unlinkOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "specify-repo-and-team",
			cli:         "--repo my-repo --team my-team",
			wantsErr:    true,
			wantsErrMsg: "specify only one of `--repo` or `--team`",
		},
		{
			name: "specify-nothing",
			cli:  "",
			wants: unlinkOpts{
				repo:  "REPO",
				owner: "OWNER",
			},
		},
		{
+ 137 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project unlink
short: Unlink a project from a repository or a team
pname: gh project
plink: gh_project.yaml
options:
    - option: owner
      value_type: string
      description: Login of the owner. Use "@me" for the current user.
    - option: repo
      shorthand: R
      value_type: string
      description: The repository to be unlinked from this project
DOCS
gh_project_unlink.md:21Markdown · 8 words
TESTS
pkg/cmd/project/unlink/unlink_test.go:18pkg/cmd/project/unlink/unlink_test::TestNewCmdUnlink · Go · 167 lines
func TestNewCmdUnlink(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         unlinkOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name:        "specify-repo-and-team",
			cli:         "--repo my-repo --team my-team",
			wantsErr:    true,
			wantsErrMsg: "specify only one of `--repo` or `--team`",
		},
		{
			name: "specify-nothing",
			cli:  "",
			wants: unlinkOpts{
				repo:  "REPO",
				owner: "OWNER",
			},
		},
		{
+ 137 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project view
short: View a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_view.md:1Markdown · 13 words
TESTS
pkg/cmd/issue/view/view_test.go:531pkg/cmd/issue/view/view_test::TestProjectsV1Deprecation · Go · 60 lines
func TestProjectsV1Deprecation(t *testing.T) {
	t.Run("when projects v1 is supported, is included in query", func(t *testing.T) {
		ios, _, _, _ := iostreams.Test()

		reg := &httpmock.Registry{}
		reg.Register(
			httpmock.GraphQL(`projectCards`),
			// Simulate a GraphQL error to early exit the test.
			httpmock.StatusStringResponse(500, ""),
		)

		_, cmdTeardown := run.Stub()
		defer cmdTeardown(t)

		// Ignore the error because we have no way to really stub it without
		// fully stubbing a GQL error structure in the request body.
		_ = viewRun(&ViewOptions{
			IO: ios,
			HttpClient: func() (*http.Client, error) {
				return &http.Client{Transport: reg}, nil
			},
			BaseRepo: func() (ghrepo.Interface, error) {
				return ghrepo.New("OWNER", "REPO"), nil
			},

			Detector:    &fd.EnabledDetectorMock{},
			IssueNumber: 123,
		})

		// Verify that our request contained projectCards
+ 30 more lines · read full file
pkg/cmd/issue/view/view_test.go:532pkg/cmd/issue/view/view_test::when projects v1 is supported, is included in query · Go · 31 lines
t.Run("when projects v1 is supported, is included in query", func(t *testing.T) {
	ios, _, _, _ := iostreams.Test()

	reg := &httpmock.Registry{}
	reg.Register(
		httpmock.GraphQL(`projectCards`),
		// Simulate a GraphQL error to early exit the test.
		httpmock.StatusStringResponse(500, ""),
	)

	_, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	// Ignore the error because we have no way to really stub it without
	// fully stubbing a GQL error structure in the request body.
	_ = viewRun(&ViewOptions{
		IO: ios,
		HttpClient: func() (*http.Client, error) {
			return &http.Client{Transport: reg}, nil
		},
		BaseRepo: func() (ghrepo.Interface, error) {
			return ghrepo.New("OWNER", "REPO"), nil
		},

		Detector:    &fd.EnabledDetectorMock{},
		IssueNumber: 123,
	})

	// Verify that our request contained projectCards
	reg.Verify(t)
+ 1 more lines · read full file
pkg/cmd/issue/view/view_test.go:564pkg/cmd/issue/view/view_test::when projects v1 is not supported, is not included in query · Go · 26 lines
t.Run("when projects v1 is not supported, is not included in query", func(t *testing.T) {
	ios, _, _, _ := iostreams.Test()

	reg := &httpmock.Registry{}
	reg.Exclude(t, httpmock.GraphQL(`projectCards`))

	_, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	// Ignore the error because we're not really interested in it.
	_ = viewRun(&ViewOptions{
		IO: ios,
		HttpClient: func() (*http.Client, error) {
			return &http.Client{Transport: reg}, nil
		},
		BaseRepo: func() (ghrepo.Interface, error) {
			return ghrepo.New("OWNER", "REPO"), nil
		},

		Detector:    &fd.DisabledDetectorMock{},
		IssueNumber: 123,
	})

	// Verify that our request contained projectCards
	reg.Verify(t)
})
+ 11 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project view
short: View a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_view.md:19Markdown · 3 words
TESTS
pkg/cmd/project/view/view_test.go:16pkg/cmd/project/view/view_test::TestNewCmdview · Go · 77 lines
func TestNewCmdview(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         viewOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "number",
			cli:  "123",
			wants: viewOpts{
				number: 123,
			},
		},
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: viewOpts{
				owner: "monalisa",
			},
		},
		{
+ 47 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project view
short: View a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_view.md:20Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project view
short: View a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_view.md:21Markdown · 10 words
TESTS
pkg/cmd/project/view/view_test.go:16pkg/cmd/project/view/view_test::TestNewCmdview · Go · 77 lines
func TestNewCmdview(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         viewOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "number",
			cli:  "123",
			wants: viewOpts{
				number: 123,
			},
		},
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: viewOpts{
				owner: "monalisa",
			},
		},
		{
+ 47 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh project view
short: View a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_view.md:22Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh project view
short: View a project
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh project
plink: gh_project.yaml
options:
    - option: format
      value_type: string
      description: 'Output format: {json}'
DOCS
gh_project_view.md:23Markdown · 6 words
TESTS
pkg/cmd/project/view/view_test.go:16pkg/cmd/project/view/view_test::TestNewCmdview · Go · 77 lines
func TestNewCmdview(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wants         viewOpts
		wantsErr      bool
		wantsErrMsg   string
		wantsExporter bool
	}{
		{
			name:        "not-a-number",
			cli:         "x",
			wantsErr:    true,
			wantsErrMsg: "invalid number: x",
		},
		{
			name: "number",
			cli:  "123",
			wants: viewOpts{
				number: 123,
			},
		},
		{
			name: "owner",
			cli:  "--owner monalisa",
			wants: viewOpts{
				owner: "monalisa",
			},
		},
		{
+ 47 more lines · read full file
pkg/cmd/project/view/view_test.go:532pkg/cmd/project/view/view_test::TestRunViewWeb_TTY · Go · 218 lines
func TestRunViewWeb_TTY(t *testing.T) {
	tests := []struct {
		name           string
		setup          func(*viewOpts, *testing.T) func()
		promptStubs    func(*prompter.PrompterMock)
		gqlStubs       func(*testing.T)
		expectedBrowse string
		tty            bool
	}{
		{
			name: "Org project --web with tty",
			tty:  true,
			setup: func(vo *viewOpts, t *testing.T) func() {
				return func() {
					vo.web = true
				}
			},
			gqlStubs: func(t *testing.T) {
				gock.New("https://api.github.com").
					Post("/graphql").
					MatchType("json").
					JSON(map[string]interface{}{
						"query": "query ViewerLoginAndOrgs.*",
						"variables": map[string]interface{}{
							"after": nil,
						},
					}).
					Reply(200).
					JSON(map[string]interface{}{
						"data": map[string]interface{}{
+ 188 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release
short: Manage releases
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release
short: Manage releases
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_release.md:33Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
TESTS
pkg/cmd/release/create/create_test.go:29pkg/cmd/release/create/create_test::Test_NewCmdCreate · Go · 401 lines
func Test_NewCmdCreate(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()
	af1, err := os.Create(filepath.Join(tempDir, "windows.zip"))
	require.NoError(t, err)
	af1.Close()
	af2, err := os.Create(filepath.Join(tempDir, "linux.tgz"))
	require.NoError(t, err)
	af2.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    CreateOptions
		wantErr string
	}{
		{
			name:  "no arguments tty",
			args:  "",
			isTTY: true,
			want: CreateOptions{
				TagName:         "",
				Target:          "",
				Name:            "",
				Body:            "",
+ 371 more lines · read full file
pkg/cmd/release/create/create_test.go:431pkg/cmd/release/create/create_test::Test_createRun · Go · 875 lines
func Test_createRun(t *testing.T) {
	const contentCmd = `git tag --list .* --format=%\(contents\)`
	const signatureCmd = `git tag --list .* --format=%\(contents:signature\)`

	defaultRunStubs := func(rs *run.CommandStubber) {
		rs.Register(contentCmd, 0, "")
		rs.Register(signatureCmd, 0, "")
	}

	tests := []struct {
		name       string
		isTTY      bool
		opts       CreateOptions
		httpStubs  func(t *testing.T, reg *httpmock.Registry)
		runStubs   func(rs *run.CommandStubber)
		wantErr    string
		wantStdout string
		wantStderr string
	}{
		{
			name:  "create a release",
			isTTY: true,
			opts: CreateOptions{
				TagName:      "v1.2.3",
				Name:         "The Big 1.2",
				Body:         "* Fixed bugs",
				BodyProvided: true,
				Target:       "",
			},
			runStubs: defaultRunStubs,
+ 845 more lines · read full file
pkg/cmd/release/create/create_test.go:1307pkg/cmd/release/create/create_test::Test_createRun_interactive · Go · 603 lines
func Test_createRun_interactive(t *testing.T) {
	const contentCmd = `git tag --list .* --format=%\(contents\)`
	const signatureCmd = `git tag --list .* --format=%\(contents:signature\)`

	defaultRunStubs := func(rs *run.CommandStubber) {
		rs.Register(contentCmd, 1, "")
	}

	tests := []struct {
		name          string
		httpStubs     func(*httpmock.Registry)
		prompterStubs func(*testing.T, *prompter.MockPrompter)
		runStubs      func(*run.CommandStubber)
		opts          *CreateOptions
		wantParams    map[string]interface{}
		wantOut       string
		wantErr       string
	}{
		{
			name: "create a release from existing tag",
			opts: &CreateOptions{},
			prompterStubs: func(t *testing.T, pm *prompter.MockPrompter) {
				pm.RegisterSelect("Choose a tag",
					[]string{"v1.2.3", "v1.2.2", "v1.0.0", "v0.1.2", "Create a new tag"},
					func(_, _ string, opts []string) (int, error) {
						return prompter.IndexFor(opts, "v1.2.3")
					})
				pm.RegisterSelect("Release notes",
					[]string{"Write my own", "Write using generated notes as template", "Leave blank"},
					func(_, _ string, opts []string) (int, error) {
+ 573 more lines · read full file
+ 1 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
DOCS
gh_release_create.md:57Markdown · 7 words
TESTS
pkg/cmd/release/create/create_test.go:29pkg/cmd/release/create/create_test::Test_NewCmdCreate · Go · 401 lines
func Test_NewCmdCreate(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()
	af1, err := os.Create(filepath.Join(tempDir, "windows.zip"))
	require.NoError(t, err)
	af1.Close()
	af2, err := os.Create(filepath.Join(tempDir, "linux.tgz"))
	require.NoError(t, err)
	af2.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    CreateOptions
		wantErr string
	}{
		{
			name:  "no arguments tty",
			args:  "",
			isTTY: true,
			want: CreateOptions{
				TagName:         "",
				Target:          "",
				Name:            "",
				Body:            "",
+ 371 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
DOCS
gh_release_create.md:58Markdown · 10 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
DOCS
gh_release_create.md:59Markdown · 16 words
TESTS
pkg/cmd/release/create/create_test.go:29pkg/cmd/release/create/create_test::Test_NewCmdCreate · Go · 401 lines
func Test_NewCmdCreate(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()
	af1, err := os.Create(filepath.Join(tempDir, "windows.zip"))
	require.NoError(t, err)
	af1.Close()
	af2, err := os.Create(filepath.Join(tempDir, "linux.tgz"))
	require.NoError(t, err)
	af2.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    CreateOptions
		wantErr string
	}{
		{
			name:  "no arguments tty",
			args:  "",
			isTTY: true,
			want: CreateOptions{
				TagName:         "",
				Target:          "",
				Name:            "",
				Body:            "",
+ 371 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
DOCS
gh_release_create.md:60Markdown · 13 words
TESTS
pkg/cmd/release/create/create_test.go:29pkg/cmd/release/create/create_test::Test_NewCmdCreate · Go · 401 lines
func Test_NewCmdCreate(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()
	af1, err := os.Create(filepath.Join(tempDir, "windows.zip"))
	require.NoError(t, err)
	af1.Close()
	af2, err := os.Create(filepath.Join(tempDir, "linux.tgz"))
	require.NoError(t, err)
	af2.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    CreateOptions
		wantErr string
	}{
		{
			name:  "no arguments tty",
			args:  "",
			isTTY: true,
			want: CreateOptions{
				TagName:         "",
				Target:          "",
				Name:            "",
				Body:            "",
+ 371 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
DOCS
gh_release_create.md:61Markdown · 19 words
TESTS
pkg/cmd/release/create/create_test.go:29pkg/cmd/release/create/create_test::Test_NewCmdCreate · Go · 401 lines
func Test_NewCmdCreate(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()
	af1, err := os.Create(filepath.Join(tempDir, "windows.zip"))
	require.NoError(t, err)
	af1.Close()
	af2, err := os.Create(filepath.Join(tempDir, "linux.tgz"))
	require.NoError(t, err)
	af2.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    CreateOptions
		wantErr string
	}{
		{
			name:  "no arguments tty",
			args:  "",
			isTTY: true,
			want: CreateOptions{
				TagName:         "",
				Target:          "",
				Name:            "",
				Body:            "",
+ 371 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
DOCS
gh_release_create.md:63Markdown · 12 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
DOCS
gh_release_create.md:64Markdown · 13 words
TESTS
pkg/cmd/release/create/create_test.go:29pkg/cmd/release/create/create_test::Test_NewCmdCreate · Go · 401 lines
func Test_NewCmdCreate(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()
	af1, err := os.Create(filepath.Join(tempDir, "windows.zip"))
	require.NoError(t, err)
	af1.Close()
	af2, err := os.Create(filepath.Join(tempDir, "linux.tgz"))
	require.NoError(t, err)
	af2.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    CreateOptions
		wantErr string
	}{
		{
			name:  "no arguments tty",
			args:  "",
			isTTY: true,
			want: CreateOptions{
				TagName:         "",
				Target:          "",
				Name:            "",
				Body:            "",
+ 371 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
DOCS
gh_release_create.md:65Markdown · 11 words
TESTS
pkg/cmd/release/create/create_test.go:29pkg/cmd/release/create/create_test::Test_NewCmdCreate · Go · 401 lines
func Test_NewCmdCreate(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()
	af1, err := os.Create(filepath.Join(tempDir, "windows.zip"))
	require.NoError(t, err)
	af1.Close()
	af2, err := os.Create(filepath.Join(tempDir, "linux.tgz"))
	require.NoError(t, err)
	af2.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    CreateOptions
		wantErr string
	}{
		{
			name:  "no arguments tty",
			args:  "",
			isTTY: true,
			want: CreateOptions{
				TagName:         "",
				Target:          "",
				Name:            "",
				Body:            "",
+ 371 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
DOCS
gh_release_create.md:67Markdown · 9 words
TESTS
pkg/cmd/release/create/create_test.go:1307pkg/cmd/release/create/create_test::Test_createRun_interactive · Go · 603 lines
func Test_createRun_interactive(t *testing.T) {
	const contentCmd = `git tag --list .* --format=%\(contents\)`
	const signatureCmd = `git tag --list .* --format=%\(contents:signature\)`

	defaultRunStubs := func(rs *run.CommandStubber) {
		rs.Register(contentCmd, 1, "")
	}

	tests := []struct {
		name          string
		httpStubs     func(*httpmock.Registry)
		prompterStubs func(*testing.T, *prompter.MockPrompter)
		runStubs      func(*run.CommandStubber)
		opts          *CreateOptions
		wantParams    map[string]interface{}
		wantOut       string
		wantErr       string
	}{
		{
			name: "create a release from existing tag",
			opts: &CreateOptions{},
			prompterStubs: func(t *testing.T, pm *prompter.MockPrompter) {
				pm.RegisterSelect("Choose a tag",
					[]string{"v1.2.3", "v1.2.2", "v1.0.0", "v0.1.2", "Create a new tag"},
					func(_, _ string, opts []string) (int, error) {
						return prompter.IndexFor(opts, "v1.2.3")
					})
				pm.RegisterSelect("Release notes",
					[]string{"Write my own", "Write using generated notes as template", "Leave blank"},
					func(_, _ string, opts []string) (int, error) {
+ 573 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release create
short: Create a new GitHub Release for a repository.
long: |-
    A list of asset files may be given to upload to the new release. To define a
    display label for an asset, append text starting with `#` after the file name.

    If a matching git tag does not yet exist, one will automatically get created
    from the latest state of the default branch.
    Use `--target` to point to a different branch or commit for the automatic tag creation.
    Use `--verify-tag` to abort the release if the tag doesn't already exist.
    To fetch the new tag locally after the release, do `git fetch --tags origin`.
DOCS
gh_release_create.md:69Markdown · 13 words
TESTS
pkg/cmd/release/create/create_test.go:29pkg/cmd/release/create/create_test::Test_NewCmdCreate · Go · 401 lines
func Test_NewCmdCreate(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()
	af1, err := os.Create(filepath.Join(tempDir, "windows.zip"))
	require.NoError(t, err)
	af1.Close()
	af2, err := os.Create(filepath.Join(tempDir, "linux.tgz"))
	require.NoError(t, err)
	af2.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    CreateOptions
		wantErr string
	}{
		{
			name:  "no arguments tty",
			args:  "",
			isTTY: true,
			want: CreateOptions{
				TagName:         "",
				Target:          "",
				Name:            "",
				Body:            "",
+ 371 more lines · read full file
pkg/cmd/release/create/create_test.go:1307pkg/cmd/release/create/create_test::Test_createRun_interactive · Go · 603 lines
func Test_createRun_interactive(t *testing.T) {
	const contentCmd = `git tag --list .* --format=%\(contents\)`
	const signatureCmd = `git tag --list .* --format=%\(contents:signature\)`

	defaultRunStubs := func(rs *run.CommandStubber) {
		rs.Register(contentCmd, 1, "")
	}

	tests := []struct {
		name          string
		httpStubs     func(*httpmock.Registry)
		prompterStubs func(*testing.T, *prompter.MockPrompter)
		runStubs      func(*run.CommandStubber)
		opts          *CreateOptions
		wantParams    map[string]interface{}
		wantOut       string
		wantErr       string
	}{
		{
			name: "create a release from existing tag",
			opts: &CreateOptions{},
			prompterStubs: func(t *testing.T, pm *prompter.MockPrompter) {
				pm.RegisterSelect("Choose a tag",
					[]string{"v1.2.3", "v1.2.2", "v1.0.0", "v0.1.2", "Create a new tag"},
					func(_, _ string, opts []string) (int, error) {
						return prompter.IndexFor(opts, "v1.2.3")
					})
				pm.RegisterSelect("Release notes",
					[]string{"Write my own", "Write using generated notes as template", "Leave blank"},
					func(_, _ string, opts []string) (int, error) {
+ 573 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release delete
short: Delete a release
pname: gh release
plink: gh_release.yaml
options:
    - option: cleanup-tag
      value_type: bool
      default_value: "false"
      description: Delete the specified tag in addition to its release
    - option: "yes"
      shorthand: "y"
      value_type: bool
TESTS
pkg/cmd/release/delete/delete_test.go:23pkg/cmd/release/delete/delete_test::Test_NewCmdDelete · Go · 85 lines
func Test_NewCmdDelete(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DeleteOptions
		wantErr string
	}{
		{
			name:  "version argument",
			args:  "v1.2.3",
			isTTY: true,
			want: DeleteOptions{
				TagName:     "v1.2.3",
				SkipConfirm: false,
				CleanupTag:  false,
			},
		},
		{
			name:  "skip confirm",
			args:  "v1.2.3 -y",
			isTTY: true,
			want: DeleteOptions{
				TagName:     "v1.2.3",
				SkipConfirm: true,
				CleanupTag:  false,
			},
		},
		{
			name:  "cleanup tag",
+ 55 more lines · read full file
pkg/cmd/release/delete/delete_test.go:109pkg/cmd/release/delete/delete_test::Test_deleteRun · Go · 135 lines
func Test_deleteRun(t *testing.T) {
	tests := []struct {
		name          string
		isTTY         bool
		opts          DeleteOptions
		prompterStubs func(*prompter.PrompterMock)
		runStubs      func(*run.CommandStubber)
		wantErr       string
		wantStdout    string
		wantStderr    string
	}{
		{
			name:  "interactive confirm",
			isTTY: true,
			opts: DeleteOptions{
				TagName: "v1.2.3",
			},
			wantStdout: "",
			wantStderr: "✓ Deleted release v1.2.3\n! Note that the v1.2.3 git tag still remains in the repository\n",
			prompterStubs: func(pm *prompter.PrompterMock) {
				pm.ConfirmFunc = func(p string, d bool) (bool, error) {
					if p == "Delete release v1.2.3 in OWNER/REPO?" {
						return true, nil
					}
					return false, prompter.NoSuchPromptErr(p)
				}
			},
		},
		{
			name:  "skipping confirmation",
+ 105 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release delete
short: Delete a release
pname: gh release
plink: gh_release.yaml
options:
    - option: cleanup-tag
      value_type: bool
      default_value: "false"
      description: Delete the specified tag in addition to its release
    - option: "yes"
      shorthand: "y"
      value_type: bool
DOCS
gh_release_delete.md:19Markdown · 9 words
TESTS
pkg/cmd/release/delete/delete_test.go:23pkg/cmd/release/delete/delete_test::Test_NewCmdDelete · Go · 85 lines
func Test_NewCmdDelete(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DeleteOptions
		wantErr string
	}{
		{
			name:  "version argument",
			args:  "v1.2.3",
			isTTY: true,
			want: DeleteOptions{
				TagName:     "v1.2.3",
				SkipConfirm: false,
				CleanupTag:  false,
			},
		},
		{
			name:  "skip confirm",
			args:  "v1.2.3 -y",
			isTTY: true,
			want: DeleteOptions{
				TagName:     "v1.2.3",
				SkipConfirm: true,
				CleanupTag:  false,
			},
		},
		{
			name:  "cleanup tag",
+ 55 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release delete
short: Delete a release
pname: gh release
plink: gh_release.yaml
options:
    - option: cleanup-tag
      value_type: bool
      default_value: "false"
      description: Delete the specified tag in addition to its release
    - option: "yes"
      shorthand: "y"
      value_type: bool
DOCS
gh_release_delete.md:20Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release delete-asset
short: Delete an asset from a release
pname: gh release
plink: gh_release.yaml
options:
    - option: "yes"
      shorthand: "y"
      value_type: bool
      default_value: "false"
      description: Skip the confirmation prompt
DOCS
gh_release_delete-asset.md:1Markdown · 20 words
TESTS
pkg/cmd/release/delete-asset/delete_asset_test.go:20pkg/cmd/release/delete-asset/delete_asset_test::Test_NewCmdDeleteAsset · Go · 80 lines
func Test_NewCmdDeleteAsset(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DeleteAssetOptions
		wantErr string
	}{
		{
			name:  "tag and asset arguments",
			args:  "v1.2.3 test-asset",
			isTTY: true,
			want: DeleteAssetOptions{
				TagName:     "v1.2.3",
				SkipConfirm: false,
				AssetName:   "test-asset",
			},
		},
		{
			name:  "skip confirm",
			args:  "v1.2.3 test-asset -y",
			isTTY: true,
			want: DeleteAssetOptions{
				TagName:     "v1.2.3",
				SkipConfirm: true,
				AssetName:   "test-asset",
			},
		},
		{
			name:    "no arguments",
+ 50 more lines · read full file
pkg/cmd/release/delete-asset/delete_asset_test.go:101pkg/cmd/release/delete-asset/delete_asset_test::Test_deleteAssetRun · Go · 101 lines
func Test_deleteAssetRun(t *testing.T) {
	tests := []struct {
		name          string
		isTTY         bool
		opts          DeleteAssetOptions
		prompterStubs func(*prompter.PrompterMock)
		wantErr       string
		wantStdout    string
		wantStderr    string
	}{
		{
			name:  "interactive confirm",
			isTTY: true,
			opts: DeleteAssetOptions{
				TagName:   "v1.2.3",
				AssetName: "test-asset",
			},
			prompterStubs: func(pm *prompter.PrompterMock) {
				pm.ConfirmFunc = func(p string, d bool) (bool, error) {
					if p == "Delete asset test-asset in release v1.2.3 in OWNER/REPO?" {
						return true, nil
					}
					return false, prompter.NoSuchPromptErr(p)
				}
			},
			wantStdout: ``,
			wantStderr: "✓ Deleted asset test-asset from release v1.2.3\n",
		},
		{
			name:  "skipping confirmation",
+ 71 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh release delete-asset
short: Delete an asset from a release
pname: gh release
plink: gh_release.yaml
options:
    - option: "yes"
      shorthand: "y"
      value_type: bool
      default_value: "false"
      description: Skip the confirmation prompt
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release download
short: Download assets from a GitHub release.
long: |-
    Without an explicit tag name argument, assets are downloaded from the
    latest release in the project. In this case, `--pattern` or `--archive`
    is required.
pname: gh release
plink: gh_release.yaml
options:
    - option: archive
      shorthand: A
      value_type: string
DOCS
gh_release_download.md:1Markdown · 45 words
TESTS
pkg/cmd/release/download/download_test.go:21pkg/cmd/release/download/download_test::Test_NewCmdDownload · Go · 154 lines
func Test_NewCmdDownload(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DownloadOptions
		wantErr string
	}{
		{
			name:  "version argument",
			args:  "v1.2.3",
			isTTY: true,
			want: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string(nil),
				Destination:  ".",
				Concurrency:  5,
			},
		},
		{
			name:  "version and file pattern",
			args:  "v1.2.3 -p *.tgz",
			isTTY: true,
			want: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string{"*.tgz"},
				Destination:  ".",
				Concurrency:  5,
			},
		},
+ 124 more lines · read full file
pkg/cmd/release/download/download_test.go:176pkg/cmd/release/download/download_test::Test_downloadRun · Go · 399 lines
func Test_downloadRun(t *testing.T) {
	tests := []struct {
		name       string
		isTTY      bool
		opts       DownloadOptions
		httpStubs  func(*httpmock.Registry)
		wantErr    string
		wantStdout string
		wantStderr string
		wantFiles  []string
	}{
		{
			name:  "download all assets",
			isTTY: true,
			opts: DownloadOptions{
				TagName:     "v1.2.3",
				Destination: ".",
				Concurrency: 2,
			},
			httpStubs: func(reg *httpmock.Registry) {
				shared.StubFetchRelease(t, reg, "OWNER", "REPO", "v1.2.3", `{
					"assets": [
						{ "name": "windows-32bit.zip", "size": 12,
						"url": "https://api.github.com/assets/1234" },
						{ "name": "windows-64bit.zip", "size": 34,
						"url": "https://api.github.com/assets/3456" },
						{ "name": "linux.tgz", "size": 56,
						"url": "https://api.github.com/assets/5678" }
					],
					"tarball_url": "https://api.github.com/repos/OWNER/REPO/tarball/v1.2.3",
+ 369 more lines · read full file
pkg/cmd/release/download/download_test.go:576pkg/cmd/release/download/download_test::Test_downloadRun_cloberAndSkip · Go · 155 lines
func Test_downloadRun_cloberAndSkip(t *testing.T) {
	oldAssetContents := "older copy to be clobbered"
	oldZipballContents := "older zipball to be clobbered"
	// this should be shorter than oldAssetContents and oldZipballContents
	newContents := "somedata"

	tests := []struct {
		name            string
		opts            DownloadOptions
		httpStubs       func(*httpmock.Registry)
		wantErr         string
		wantFileSize    int64
		wantArchiveSize int64
	}{
		{
			name: "no clobber or skip",
			opts: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string{"windows-64bit.zip"},
				Destination:  "tmp/packages",
				Concurrency:  2,
			},
			wantErr:         "already exists (use `--clobber` to overwrite file or `--skip-existing` to skip file)",
			wantFileSize:    int64(len(oldAssetContents)),
			wantArchiveSize: int64(len(oldZipballContents)),
		},
		{
			name: "clobber",
			opts: DownloadOptions{
				TagName:           "v1.2.3",
+ 125 more lines · read full file
+ 2 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh release download
short: Download assets from a GitHub release.
long: |-
    Without an explicit tag name argument, assets are downloaded from the
    latest release in the project. In this case, `--pattern` or `--archive`
    is required.
pname: gh release
plink: gh_release.yaml
options:
    - option: archive
      shorthand: A
      value_type: string
DOCS
gh_release_download.md:24Markdown · 12 words
TESTS
pkg/cmd/release/download/download_test.go:21pkg/cmd/release/download/download_test::Test_NewCmdDownload · Go · 154 lines
func Test_NewCmdDownload(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DownloadOptions
		wantErr string
	}{
		{
			name:  "version argument",
			args:  "v1.2.3",
			isTTY: true,
			want: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string(nil),
				Destination:  ".",
				Concurrency:  5,
			},
		},
		{
			name:  "version and file pattern",
			args:  "v1.2.3 -p *.tgz",
			isTTY: true,
			want: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string{"*.tgz"},
				Destination:  ".",
				Concurrency:  5,
			},
		},
+ 124 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release download
short: Download assets from a GitHub release.
long: |-
    Without an explicit tag name argument, assets are downloaded from the
    latest release in the project. In this case, `--pattern` or `--archive`
    is required.
pname: gh release
plink: gh_release.yaml
options:
    - option: archive
      shorthand: A
      value_type: string
DOCS
gh_release_download.md:25Markdown · 7 words
TESTS
pkg/cmd/release/download/download_test.go:576pkg/cmd/release/download/download_test::Test_downloadRun_cloberAndSkip · Go · 155 lines
func Test_downloadRun_cloberAndSkip(t *testing.T) {
	oldAssetContents := "older copy to be clobbered"
	oldZipballContents := "older zipball to be clobbered"
	// this should be shorter than oldAssetContents and oldZipballContents
	newContents := "somedata"

	tests := []struct {
		name            string
		opts            DownloadOptions
		httpStubs       func(*httpmock.Registry)
		wantErr         string
		wantFileSize    int64
		wantArchiveSize int64
	}{
		{
			name: "no clobber or skip",
			opts: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string{"windows-64bit.zip"},
				Destination:  "tmp/packages",
				Concurrency:  2,
			},
			wantErr:         "already exists (use `--clobber` to overwrite file or `--skip-existing` to skip file)",
			wantFileSize:    int64(len(oldAssetContents)),
			wantArchiveSize: int64(len(oldZipballContents)),
		},
		{
			name: "clobber",
			opts: DownloadOptions{
				TagName:           "v1.2.3",
+ 125 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release download
short: Download assets from a GitHub release.
long: |-
    Without an explicit tag name argument, assets are downloaded from the
    latest release in the project. In this case, `--pattern` or `--archive`
    is required.
pname: gh release
plink: gh_release.yaml
options:
    - option: archive
      shorthand: A
      value_type: string
DOCS
gh_release_download.md:26Markdown · 6 words
TESTS
pkg/cmd/release/download/download_test.go:21pkg/cmd/release/download/download_test::Test_NewCmdDownload · Go · 154 lines
func Test_NewCmdDownload(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DownloadOptions
		wantErr string
	}{
		{
			name:  "version argument",
			args:  "v1.2.3",
			isTTY: true,
			want: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string(nil),
				Destination:  ".",
				Concurrency:  5,
			},
		},
		{
			name:  "version and file pattern",
			args:  "v1.2.3 -p *.tgz",
			isTTY: true,
			want: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string{"*.tgz"},
				Destination:  ".",
				Concurrency:  5,
			},
		},
+ 124 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release download
short: Download assets from a GitHub release.
long: |-
    Without an explicit tag name argument, assets are downloaded from the
    latest release in the project. In this case, `--pattern` or `--archive`
    is required.
pname: gh release
plink: gh_release.yaml
options:
    - option: archive
      shorthand: A
      value_type: string
DOCS
gh_release_download.md:27Markdown · 15 words
TESTS
pkg/cmd/release/download/download_test.go:21pkg/cmd/release/download/download_test::Test_NewCmdDownload · Go · 154 lines
func Test_NewCmdDownload(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DownloadOptions
		wantErr string
	}{
		{
			name:  "version argument",
			args:  "v1.2.3",
			isTTY: true,
			want: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string(nil),
				Destination:  ".",
				Concurrency:  5,
			},
		},
		{
			name:  "version and file pattern",
			args:  "v1.2.3 -p *.tgz",
			isTTY: true,
			want: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string{"*.tgz"},
				Destination:  ".",
				Concurrency:  5,
			},
		},
+ 124 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release download
short: Download assets from a GitHub release.
long: |-
    Without an explicit tag name argument, assets are downloaded from the
    latest release in the project. In this case, `--pattern` or `--archive`
    is required.
pname: gh release
plink: gh_release.yaml
options:
    - option: archive
      shorthand: A
      value_type: string
DOCS
gh_release_download.md:28Markdown · 8 words
TESTS
pkg/cmd/release/download/download_test.go:21pkg/cmd/release/download/download_test::Test_NewCmdDownload · Go · 154 lines
func Test_NewCmdDownload(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    DownloadOptions
		wantErr string
	}{
		{
			name:  "version argument",
			args:  "v1.2.3",
			isTTY: true,
			want: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string(nil),
				Destination:  ".",
				Concurrency:  5,
			},
		},
		{
			name:  "version and file pattern",
			args:  "v1.2.3 -p *.tgz",
			isTTY: true,
			want: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string{"*.tgz"},
				Destination:  ".",
				Concurrency:  5,
			},
		},
+ 124 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release download
short: Download assets from a GitHub release.
long: |-
    Without an explicit tag name argument, assets are downloaded from the
    latest release in the project. In this case, `--pattern` or `--archive`
    is required.
pname: gh release
plink: gh_release.yaml
options:
    - option: archive
      shorthand: A
      value_type: string
DOCS
gh_release_download.md:29Markdown · 9 words
TESTS
pkg/cmd/release/download/download_test.go:576pkg/cmd/release/download/download_test::Test_downloadRun_cloberAndSkip · Go · 155 lines
func Test_downloadRun_cloberAndSkip(t *testing.T) {
	oldAssetContents := "older copy to be clobbered"
	oldZipballContents := "older zipball to be clobbered"
	// this should be shorter than oldAssetContents and oldZipballContents
	newContents := "somedata"

	tests := []struct {
		name            string
		opts            DownloadOptions
		httpStubs       func(*httpmock.Registry)
		wantErr         string
		wantFileSize    int64
		wantArchiveSize int64
	}{
		{
			name: "no clobber or skip",
			opts: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string{"windows-64bit.zip"},
				Destination:  "tmp/packages",
				Concurrency:  2,
			},
			wantErr:         "already exists (use `--clobber` to overwrite file or `--skip-existing` to skip file)",
			wantFileSize:    int64(len(oldAssetContents)),
			wantArchiveSize: int64(len(oldZipballContents)),
		},
		{
			name: "clobber",
			opts: DownloadOptions{
				TagName:           "v1.2.3",
+ 125 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release edit
short: Edit a release
pname: gh release
plink: gh_release.yaml
options:
    - option: discussion-category
      value_type: string
      description: Start a discussion in the specified category when publishing a draft
    - option: draft
      value_type: bool
      default_value: "false"
      description: Save the release as a draft instead of publishing it
TESTS
pkg/cmd/release/edit/edit_test.go:21pkg/cmd/release/edit/edit_test::Test_NewCmdEdit · Go · 184 lines
func Test_NewCmdEdit(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    EditOptions
		wantErr string
	}{
		{
			name:    "no arguments notty",
			args:    "",
			isTTY:   false,
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name:  "provide title and notes",
			args:  "v1.2.3 --title 'Some Title' --notes 'Some Notes'",
			isTTY: false,
			want: EditOptions{
				TagName: "",
				Name:    stringPtr("Some Title"),
				Body:    stringPtr("Some Notes"),
			},
+ 154 more lines · read full file
pkg/cmd/release/edit/edit_test.go:206pkg/cmd/release/edit/edit_test::Test_editRun · Go · 268 lines
func Test_editRun(t *testing.T) {
	tests := []struct {
		name       string
		isTTY      bool
		opts       EditOptions
		httpStubs  func(t *testing.T, reg *httpmock.Registry)
		wantErr    string
		wantStdout string
		wantStderr string
	}{
		{
			name:  "edit the tag name",
			isTTY: true,
			opts: EditOptions{
				TagName: "v1.2.4",
			},
			httpStubs: func(t *testing.T, reg *httpmock.Registry) {
				mockSuccessfulEditResponse(reg, func(params map[string]interface{}) {
					assert.Equal(t, map[string]interface{}{
						"tag_name": "v1.2.4",
					}, params)
				})
			},
			wantStdout: "https://github.com/OWNER/REPO/releases/tag/v1.2.3\n",
			wantStderr: "",
		},
		{
			name:  "edit the target",
			isTTY: true,
			opts: EditOptions{
+ 238 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release edit
short: Edit a release
pname: gh release
plink: gh_release.yaml
options:
    - option: discussion-category
      value_type: string
      description: Start a discussion in the specified category when publishing a draft
    - option: draft
      value_type: bool
      default_value: "false"
      description: Save the release as a draft instead of publishing it
DOCS
gh_release_edit.md:19Markdown · 11 words
TESTS
pkg/cmd/release/edit/edit_test.go:21pkg/cmd/release/edit/edit_test::Test_NewCmdEdit · Go · 184 lines
func Test_NewCmdEdit(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    EditOptions
		wantErr string
	}{
		{
			name:    "no arguments notty",
			args:    "",
			isTTY:   false,
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name:  "provide title and notes",
			args:  "v1.2.3 --title 'Some Title' --notes 'Some Notes'",
			isTTY: false,
			want: EditOptions{
				TagName: "",
				Name:    stringPtr("Some Title"),
				Body:    stringPtr("Some Notes"),
			},
+ 154 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release edit
short: Edit a release
pname: gh release
plink: gh_release.yaml
options:
    - option: discussion-category
      value_type: string
      description: Start a discussion in the specified category when publishing a draft
    - option: draft
      value_type: bool
      default_value: "false"
      description: Save the release as a draft instead of publishing it
DOCS
gh_release_edit.md:20Markdown · 10 words
TESTS
pkg/cmd/release/edit/edit_test.go:21pkg/cmd/release/edit/edit_test::Test_NewCmdEdit · Go · 184 lines
func Test_NewCmdEdit(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    EditOptions
		wantErr string
	}{
		{
			name:    "no arguments notty",
			args:    "",
			isTTY:   false,
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name:  "provide title and notes",
			args:  "v1.2.3 --title 'Some Title' --notes 'Some Notes'",
			isTTY: false,
			want: EditOptions{
				TagName: "",
				Name:    stringPtr("Some Title"),
				Body:    stringPtr("Some Notes"),
			},
+ 154 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release edit
short: Edit a release
pname: gh release
plink: gh_release.yaml
options:
    - option: discussion-category
      value_type: string
      description: Start a discussion in the specified category when publishing a draft
    - option: draft
      value_type: bool
      default_value: "false"
      description: Save the release as a draft instead of publishing it
DOCS
gh_release_edit.md:21Markdown · 6 words
TESTS
pkg/cmd/release/edit/edit_test.go:21pkg/cmd/release/edit/edit_test::Test_NewCmdEdit · Go · 184 lines
func Test_NewCmdEdit(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    EditOptions
		wantErr string
	}{
		{
			name:    "no arguments notty",
			args:    "",
			isTTY:   false,
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name:  "provide title and notes",
			args:  "v1.2.3 --title 'Some Title' --notes 'Some Notes'",
			isTTY: false,
			want: EditOptions{
				TagName: "",
				Name:    stringPtr("Some Title"),
				Body:    stringPtr("Some Notes"),
			},
+ 154 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release edit
short: Edit a release
pname: gh release
plink: gh_release.yaml
options:
    - option: discussion-category
      value_type: string
      description: Start a discussion in the specified category when publishing a draft
    - option: draft
      value_type: bool
      default_value: "false"
      description: Save the release as a draft instead of publishing it
DOCS
gh_release_edit.md:22Markdown · 2 words
TESTS
pkg/cmd/release/edit/edit_test.go:21pkg/cmd/release/edit/edit_test::Test_NewCmdEdit · Go · 184 lines
func Test_NewCmdEdit(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    EditOptions
		wantErr string
	}{
		{
			name:    "no arguments notty",
			args:    "",
			isTTY:   false,
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name:  "provide title and notes",
			args:  "v1.2.3 --title 'Some Title' --notes 'Some Notes'",
			isTTY: false,
			want: EditOptions{
				TagName: "",
				Name:    stringPtr("Some Title"),
				Body:    stringPtr("Some Notes"),
			},
+ 154 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release edit
short: Edit a release
pname: gh release
plink: gh_release.yaml
options:
    - option: discussion-category
      value_type: string
      description: Start a discussion in the specified category when publishing a draft
    - option: draft
      value_type: bool
      default_value: "false"
      description: Save the release as a draft instead of publishing it
DOCS
gh_release_edit.md:23Markdown · 12 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release edit
short: Edit a release
pname: gh release
plink: gh_release.yaml
options:
    - option: discussion-category
      value_type: string
      description: Start a discussion in the specified category when publishing a draft
    - option: draft
      value_type: bool
      default_value: "false"
      description: Save the release as a draft instead of publishing it
DOCS
gh_release_edit.md:24Markdown · 6 words
TESTS
pkg/cmd/release/edit/edit_test.go:21pkg/cmd/release/edit/edit_test::Test_NewCmdEdit · Go · 184 lines
func Test_NewCmdEdit(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    EditOptions
		wantErr string
	}{
		{
			name:    "no arguments notty",
			args:    "",
			isTTY:   false,
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name:  "provide title and notes",
			args:  "v1.2.3 --title 'Some Title' --notes 'Some Notes'",
			isTTY: false,
			want: EditOptions{
				TagName: "",
				Name:    stringPtr("Some Title"),
				Body:    stringPtr("Some Notes"),
			},
+ 154 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release edit
short: Edit a release
pname: gh release
plink: gh_release.yaml
options:
    - option: discussion-category
      value_type: string
      description: Start a discussion in the specified category when publishing a draft
    - option: draft
      value_type: bool
      default_value: "false"
      description: Save the release as a draft instead of publishing it
DOCS
gh_release_edit.md:25Markdown · 5 words
TESTS
pkg/cmd/release/edit/edit_test.go:21pkg/cmd/release/edit/edit_test::Test_NewCmdEdit · Go · 184 lines
func Test_NewCmdEdit(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    EditOptions
		wantErr string
	}{
		{
			name:    "no arguments notty",
			args:    "",
			isTTY:   false,
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name:  "provide title and notes",
			args:  "v1.2.3 --title 'Some Title' --notes 'Some Notes'",
			isTTY: false,
			want: EditOptions{
				TagName: "",
				Name:    stringPtr("Some Title"),
				Body:    stringPtr("Some Notes"),
			},
+ 154 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release edit
short: Edit a release
pname: gh release
plink: gh_release.yaml
options:
    - option: discussion-category
      value_type: string
      description: Start a discussion in the specified category when publishing a draft
    - option: draft
      value_type: bool
      default_value: "false"
      description: Save the release as a draft instead of publishing it
DOCS
gh_release_edit.md:26Markdown · 9 words
TESTS
pkg/cmd/release/edit/edit_test.go:21pkg/cmd/release/edit/edit_test::Test_NewCmdEdit · Go · 184 lines
func Test_NewCmdEdit(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    EditOptions
		wantErr string
	}{
		{
			name:    "no arguments notty",
			args:    "",
			isTTY:   false,
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name:  "provide title and notes",
			args:  "v1.2.3 --title 'Some Title' --notes 'Some Notes'",
			isTTY: false,
			want: EditOptions{
				TagName: "",
				Name:    stringPtr("Some Title"),
				Body:    stringPtr("Some Notes"),
			},
+ 154 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release edit
short: Edit a release
pname: gh release
plink: gh_release.yaml
options:
    - option: discussion-category
      value_type: string
      description: Start a discussion in the specified category when publishing a draft
    - option: draft
      value_type: bool
      default_value: "false"
      description: Save the release as a draft instead of publishing it
DOCS
gh_release_edit.md:27Markdown · 2 words
TESTS
pkg/cmd/release/edit/edit_test.go:21pkg/cmd/release/edit/edit_test::Test_NewCmdEdit · Go · 184 lines
func Test_NewCmdEdit(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    EditOptions
		wantErr string
	}{
		{
			name:    "no arguments notty",
			args:    "",
			isTTY:   false,
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name:  "provide title and notes",
			args:  "v1.2.3 --title 'Some Title' --notes 'Some Notes'",
			isTTY: false,
			want: EditOptions{
				TagName: "",
				Name:    stringPtr("Some Title"),
				Body:    stringPtr("Some Notes"),
			},
+ 154 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release edit
short: Edit a release
pname: gh release
plink: gh_release.yaml
options:
    - option: discussion-category
      value_type: string
      description: Start a discussion in the specified category when publishing a draft
    - option: draft
      value_type: bool
      default_value: "false"
      description: Save the release as a draft instead of publishing it
DOCS
gh_release_edit.md:28Markdown · 13 words
TESTS
pkg/cmd/release/edit/edit_test.go:21pkg/cmd/release/edit/edit_test::Test_NewCmdEdit · Go · 184 lines
func Test_NewCmdEdit(t *testing.T) {
	tempDir := t.TempDir()
	tf, err := os.CreateTemp(tempDir, "release-create")
	require.NoError(t, err)
	fmt.Fprint(tf, "MY NOTES")
	tf.Close()

	tests := []struct {
		name    string
		args    string
		isTTY   bool
		stdin   string
		want    EditOptions
		wantErr string
	}{
		{
			name:    "no arguments notty",
			args:    "",
			isTTY:   false,
			wantErr: "accepts 1 arg(s), received 0",
		},
		{
			name:  "provide title and notes",
			args:  "v1.2.3 --title 'Some Title' --notes 'Some Notes'",
			isTTY: false,
			want: EditOptions{
				TagName: "",
				Name:    stringPtr("Some Title"),
				Body:    stringPtr("Some Notes"),
			},
+ 154 more lines · read full file
pkg/cmd/release/edit/edit_test.go:206pkg/cmd/release/edit/edit_test::Test_editRun · Go · 268 lines
func Test_editRun(t *testing.T) {
	tests := []struct {
		name       string
		isTTY      bool
		opts       EditOptions
		httpStubs  func(t *testing.T, reg *httpmock.Registry)
		wantErr    string
		wantStdout string
		wantStderr string
	}{
		{
			name:  "edit the tag name",
			isTTY: true,
			opts: EditOptions{
				TagName: "v1.2.4",
			},
			httpStubs: func(t *testing.T, reg *httpmock.Registry) {
				mockSuccessfulEditResponse(reg, func(params map[string]interface{}) {
					assert.Equal(t, map[string]interface{}{
						"tag_name": "v1.2.4",
					}, params)
				})
			},
			wantStdout: "https://github.com/OWNER/REPO/releases/tag/v1.2.3\n",
			wantStderr: "",
		},
		{
			name:  "edit the target",
			isTTY: true,
			opts: EditOptions{
+ 238 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release list
short: List releases in a repository
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: exclude-drafts
      value_type: bool
      default_value: "false"
      description: Exclude draft releases
    - option: exclude-pre-releases
      value_type: bool
DOCS
gh_release_list.md:1Markdown · 33 words
TESTS
pkg/cmd/release/list/list_test.go:22pkg/cmd/release/list/list_test::Test_NewCmdList · Go · 96 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ListOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ListOptions{
				LimitResults:       30,
				ExcludeDrafts:      false,
				ExcludePreReleases: false,
				Order:              "desc",
			},
		},
		{
			name: "exclude drafts",
			args: "--exclude-drafts",
			want: ListOptions{
				LimitResults:       30,
				ExcludeDrafts:      true,
				ExcludePreReleases: false,
				Order:              "desc",
			},
		},
		{
+ 66 more lines · read full file
pkg/cmd/release/list/list_test.go:119pkg/cmd/release/list/list_test::Test_listRun · Go · 271 lines
func Test_listRun(t *testing.T) {
	oneDayAgo := time.Now().Add(time.Duration(-24) * time.Hour)

	frozenTime, err := time.Parse(time.RFC3339, "2020-08-31T15:44:24+02:00")
	require.NoError(t, err)

	httpStubs := func(createdAt time.Time) func(t *testing.T, reg *httpmock.Registry) {
		return func(t *testing.T, reg *httpmock.Registry) {
			reg.Register(
				httpmock.GraphQL(`\bRepositoryReleaseList\(`),
				httpmock.GraphQLQuery(
					fmt.Sprintf(`
						{ "data": { "repository": { "releases": {
							"nodes": [
								{
									"name": "",
									"tagName": "v1.1.0",
									"isLatest": false,
									"isDraft": true,
									"isPrerelease": false,
									"immutable": false,
									"createdAt": "%[1]s",
									"publishedAt": "%[1]s"
								},
								{
									"name": "The big 1.0",
									"tagName": "v1.0.0",
									"isLatest": true,
									"isDraft": false,
									"isPrerelease": false,
+ 241 more lines · read full file
pkg/cmd/release/list/list_test.go:391pkg/cmd/release/list/list_test::TestExportReleases · Go · 21 lines
func TestExportReleases(t *testing.T) {
	ios, _, stdout, _ := iostreams.Test()
	createdAt, _ := time.Parse(time.RFC3339, "2024-01-01T00:00:00Z")
	publishedAt, _ := time.Parse(time.RFC3339, "2024-02-01T00:00:00Z")
	rs := []Release{{
		Name:         "v1",
		TagName:      "tag",
		IsDraft:      true,
		IsLatest:     false,
		IsPrerelease: true,
		IsImmutable:  true,
		CreatedAt:    createdAt,
		PublishedAt:  publishedAt,
	}}
	exporter := cmdutil.NewJSONExporter()
	exporter.SetFields(releaseFields)
	require.NoError(t, exporter.Write(ios, rs))
	require.JSONEq(t,
		`[{"createdAt":"2024-01-01T00:00:00Z","isDraft":true,"isLatest":false,"isPrerelease":true,"isImmutable":true,"name":"v1","publishedAt":"2024-02-01T00:00:00Z","tagName":"tag"}]`,
		stdout.String())
}
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release list
short: List releases in a repository
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: exclude-drafts
      value_type: bool
      default_value: "false"
      description: Exclude draft releases
    - option: exclude-pre-releases
      value_type: bool
DOCS
gh_release_list.md:19Markdown · 3 words
TESTS
pkg/cmd/release/list/list_test.go:22pkg/cmd/release/list/list_test::Test_NewCmdList · Go · 96 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ListOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ListOptions{
				LimitResults:       30,
				ExcludeDrafts:      false,
				ExcludePreReleases: false,
				Order:              "desc",
			},
		},
		{
			name: "exclude drafts",
			args: "--exclude-drafts",
			want: ListOptions{
				LimitResults:       30,
				ExcludeDrafts:      true,
				ExcludePreReleases: false,
				Order:              "desc",
			},
		},
		{
+ 66 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release list
short: List releases in a repository
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: exclude-drafts
      value_type: bool
      default_value: "false"
      description: Exclude draft releases
    - option: exclude-pre-releases
      value_type: bool
DOCS
gh_release_list.md:20Markdown · 2 words
TESTS
pkg/cmd/release/list/list_test.go:22pkg/cmd/release/list/list_test::Test_NewCmdList · Go · 96 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ListOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ListOptions{
				LimitResults:       30,
				ExcludeDrafts:      false,
				ExcludePreReleases: false,
				Order:              "desc",
			},
		},
		{
			name: "exclude drafts",
			args: "--exclude-drafts",
			want: ListOptions{
				LimitResults:       30,
				ExcludeDrafts:      true,
				ExcludePreReleases: false,
				Order:              "desc",
			},
		},
		{
+ 66 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release list
short: List releases in a repository
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: exclude-drafts
      value_type: bool
      default_value: "false"
      description: Exclude draft releases
    - option: exclude-pre-releases
      value_type: bool
DOCS
gh_release_list.md:21Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release list
short: List releases in a repository
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: exclude-drafts
      value_type: bool
      default_value: "false"
      description: Exclude draft releases
    - option: exclude-pre-releases
      value_type: bool
DOCS
gh_release_list.md:22Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release list
short: List releases in a repository
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: exclude-drafts
      value_type: bool
      default_value: "false"
      description: Exclude draft releases
    - option: exclude-pre-releases
      value_type: bool
DOCS
gh_release_list.md:23Markdown · 6 words
TESTS
pkg/cmd/release/list/list_test.go:22pkg/cmd/release/list/list_test::Test_NewCmdList · Go · 96 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ListOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ListOptions{
				LimitResults:       30,
				ExcludeDrafts:      false,
				ExcludePreReleases: false,
				Order:              "desc",
			},
		},
		{
			name: "exclude drafts",
			args: "--exclude-drafts",
			want: ListOptions{
				LimitResults:       30,
				ExcludeDrafts:      true,
				ExcludePreReleases: false,
				Order:              "desc",
			},
		},
		{
+ 66 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release list
short: List releases in a repository
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: exclude-drafts
      value_type: bool
      default_value: "false"
      description: Exclude draft releases
    - option: exclude-pre-releases
      value_type: bool
DOCS
gh_release_list.md:24Markdown · 5 words
TESTS
pkg/cmd/release/list/list_test.go:22pkg/cmd/release/list/list_test::Test_NewCmdList · Go · 96 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ListOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ListOptions{
				LimitResults:       30,
				ExcludeDrafts:      false,
				ExcludePreReleases: false,
				Order:              "desc",
			},
		},
		{
			name: "exclude drafts",
			args: "--exclude-drafts",
			want: ListOptions{
				LimitResults:       30,
				ExcludeDrafts:      true,
				ExcludePreReleases: false,
				Order:              "desc",
			},
		},
		{
+ 66 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release list
short: List releases in a repository
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: exclude-drafts
      value_type: bool
      default_value: "false"
      description: Exclude draft releases
    - option: exclude-pre-releases
      value_type: bool
DOCS
gh_release_list.md:25Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release upload
short: Upload asset files to a GitHub Release.
long: |-
    To define a display label for an asset, append text starting with `#` after the
    file name.

    When using `--clobber`, existing assets are deleted before new assets are uploaded.
    If the upload fails, the original assets will be lost.
pname: gh release
plink: gh_release.yaml
options:
    - option: clobber
DOCS
gh_release_upload.md:1Markdown · 60 words
TESTS
pkg/cmd/release/shared/upload_test.go:12pkg/cmd/release/shared/upload_test::Test_typeForFilename · Go · 65 lines
func Test_typeForFilename(t *testing.T) {
	tests := []struct {
		name string
		file string
		want string
	}{
		{
			name: "tar",
			file: "ball.tar",
			want: "application/x-tar",
		},
		{
			name: "tgz",
			file: "ball.tgz",
			want: "application/x-gtar",
		},
		{
			name: "tar.gz",
			file: "ball.tar.gz",
			want: "application/x-gtar",
		},
		{
			name: "bz2",
			file: "ball.tar.bz2",
			want: "application/x-bzip2",
		},
		{
			name: "zip",
			file: "archive.zip",
			want: "application/zip",
+ 35 more lines · read full file
pkg/cmd/release/shared/upload_test.go:78pkg/cmd/release/shared/upload_test::Test_uploadWithDelete_retry · Go · 38 lines
func Test_uploadWithDelete_retry(t *testing.T) {
	retryInterval = 0
	ctx := context.Background()

	tries := 0
	client := funcClient(func(req *http.Request) (*http.Response, error) {
		tries++
		if tries == 1 {
			return nil, errors.New("made up exception")
		} else if tries == 2 {
			return &http.Response{
				Request:    req,
				StatusCode: 500,
				Body:       io.NopCloser(bytes.NewBufferString(`{}`)),
			}, nil
		}
		return &http.Response{
			Request:    req,
			StatusCode: 200,
			Body:       io.NopCloser(bytes.NewBufferString(`{}`)),
		}, nil
	})
	err := uploadWithDelete(ctx, client, "http://example.com/upload", AssetForUpload{
		Name:  "asset",
		Label: "",
		Size:  8,
		Open: func() (io.ReadCloser, error) {
			return io.NopCloser(bytes.NewBufferString(`somebody`)), nil
		},
		MIMEType: "application/octet-stream",
+ 8 more lines · read full file
pkg/cmd/release/upload/upload_test.go:9pkg/cmd/release/upload/upload_test::Test_SanitizeFileName · Go · 44 lines
func Test_SanitizeFileName(t *testing.T) {
	tests := []struct {
		name     string
		expected string
	}{
		{
			name:     "foo",
			expected: "foo",
		},
		{
			name:     "foo bar",
			expected: "foo.bar",
		},
		{
			name:     ".foo",
			expected: "default.foo",
		},
		{
			name:     "Foo bar",
			expected: "Foo.bar",
		},
		{
			name:     "Hello, दुनिया",
			expected: "default.Hello",
		},
		{
			name:     "this+has+plusses.jpg",
			expected: "this+has+plusses.jpg",
		},
		{
+ 14 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release upload
short: Upload asset files to a GitHub Release.
long: |-
    To define a display label for an asset, append text starting with `#` after the
    file name.

    When using `--clobber`, existing assets are deleted before new assets are uploaded.
    If the upload fails, the original assets will be lost.
pname: gh release
plink: gh_release.yaml
options:
    - option: clobber
DOCS
gh_release_upload.md:26Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release verify
short: Verify that a GitHub Release is accompanied by a valid cryptographically signed attestation.
long: "An attestation is a claim made by GitHub regarding a release and its assets.\n\nThis command checks that the specified release (or the latest release, if no tag is given) has a valid attestation. \nIt fetches the attestation for the release and prints metadata about all assets referenced in the attestation, including their digests.\n\nFor more information about output formatting flags, see `gh help formatting`."
DOCS
gh_release_verify.md:1Markdown · 82 words
TESTS
pkg/cmd/release/verify/verify_test.go:20pkg/cmd/release/verify/verify_test::TestNewCmdVerify_Args · Go · 51 lines
func TestNewCmdVerify_Args(t *testing.T) {
	tests := []struct {
		name    string
		args    []string
		wantTag string
		wantErr string
	}{
		{
			name:    "valid tag arg",
			args:    []string{"v1.2.3"},
			wantTag: "v1.2.3",
		},
		{
			name:    "no tag arg",
			args:    []string{},
			wantTag: "",
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			testIO, _, _, _ := iostreams.Test()
			f := &cmdutil.Factory{
				IOStreams: testIO,
				HttpClient: func() (*http.Client, error) {
					return nil, nil
				},
				ExternalHttpClient: func() (*http.Client, error) {
					return nil, nil
				},
				BaseRepo: func() (ghrepo.Interface, error) {
+ 21 more lines · read full file
pkg/cmd/release/verify/verify_test.go:72pkg/cmd/release/verify/verify_test::Test_verifyRun_Success · Go · 36 lines
func Test_verifyRun_Success(t *testing.T) {
	ios, _, _, _ := iostreams.Test()
	tagName := "v6"

	fakeHTTP := &httpmock.Registry{}
	defer fakeHTTP.Verify(t)

	fakeSHA := "1234567890abcdef1234567890abcdef12345678"
	shared.StubFetchRefSHA(t, fakeHTTP, "owner", "repo", tagName, fakeSHA)

	baseRepo, err := ghrepo.FromFullName("owner/repo")
	require.NoError(t, err)

	result := &verification.AttestationProcessingResult{
		Attestation: &api.Attestation{
			Bundle:    data.GitHubReleaseBundle(t),
			BundleURL: "https://example.com",
		},
		VerificationResult: nil,
	}

	cfg := &VerifyConfig{
		Opts: &VerifyOptions{
			TagName:  tagName,
			BaseRepo: baseRepo,
			Exporter: nil,
		},
		IO:          ios,
		HttpClient:  &http.Client{Transport: fakeHTTP},
		AttClient:   api.NewTestClient(),
+ 6 more lines · read full file
pkg/cmd/release/verify/verify_test.go:109pkg/cmd/release/verify/verify_test::Test_verifyRun_FailedNoAttestations_SHA1 · Go · 37 lines
func Test_verifyRun_FailedNoAttestations_SHA1(t *testing.T) {
	ios, _, _, _ := iostreams.Test()
	tagName := "v1"

	fakeHTTP := &httpmock.Registry{}
	defer fakeHTTP.Verify(t)
	fakeSHA := "1234567890abcdef1234567890abcdef12345678"
	shared.StubFetchRefSHA(t, fakeHTTP, "owner", "repo", tagName, fakeSHA)

	baseRepo, err := ghrepo.FromFullName("owner/repo")
	require.NoError(t, err)

	var capturedParams api.FetchParams
	attClient := &api.MockClient{
		OnGetByDigest: func(params api.FetchParams) ([]*api.Attestation, error) {
			capturedParams = params
			return api.OnGetByDigestFailure(params)
		},
	}

	cfg := &VerifyConfig{
		Opts: &VerifyOptions{
			TagName:  tagName,
			BaseRepo: baseRepo,
			Exporter: nil,
		},
		IO:          ios,
		HttpClient:  &http.Client{Transport: fakeHTTP},
		AttClient:   attClient,
		AttVerifier: nil,
+ 7 more lines · read full file
+ 2 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh release verify
short: Verify that a GitHub Release is accompanied by a valid cryptographically signed attestation.
long: "An attestation is a claim made by GitHub regarding a release and its assets.\n\nThis command checks that the specified release (or the latest release, if no tag is given) has a valid attestation. \nIt fetches the attestation for the release and prints metadata about all assets referenced in the attestation, including their digests.\n\nFor more information about output formatting flags, see `gh help formatting`."
DOCS
gh_release_verify.md:25Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release verify
short: Verify that a GitHub Release is accompanied by a valid cryptographically signed attestation.
long: "An attestation is a claim made by GitHub regarding a release and its assets.\n\nThis command checks that the specified release (or the latest release, if no tag is given) has a valid attestation. \nIt fetches the attestation for the release and prints metadata about all assets referenced in the attestation, including their digests.\n\nFor more information about output formatting flags, see `gh help formatting`."
DOCS
gh_release_verify.md:26Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release verify
short: Verify that a GitHub Release is accompanied by a valid cryptographically signed attestation.
long: "An attestation is a claim made by GitHub regarding a release and its assets.\n\nThis command checks that the specified release (or the latest release, if no tag is given) has a valid attestation. \nIt fetches the attestation for the release and prints metadata about all assets referenced in the attestation, including their digests.\n\nFor more information about output formatting flags, see `gh help formatting`."
DOCS
gh_release_verify.md:27Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release verify-asset
short: Verify that a given asset file originated from a specific GitHub Release using cryptographically signed attestations.
long: |-
    An attestation is a claim made by GitHub regarding a release and its assets.

    		This command checks that the asset you provide matches a valid attestation for the specified release (or the latest release, if no tag is given).
DOCS
gh_release_verify-asset.md:1Markdown · 96 words
TESTS
pkg/cmd/release/verify-asset/verify_asset_test.go:22pkg/cmd/release/verify-asset/verify_asset_test::TestNewCmdVerifyAsset_Args · Go · 66 lines
func TestNewCmdVerifyAsset_Args(t *testing.T) {
	tests := []struct {
		name     string
		args     []string
		wantTag  string
		wantFile string
		wantErr  string
	}{
		{
			name:     "valid args",
			args:     []string{"v1.2.3", "../../attestation/test/data/github_release_artifact.zip"},
			wantTag:  "v1.2.3",
			wantFile: test.NormalizeRelativePath("../../attestation/test/data/github_release_artifact.zip"),
		},
		{
			name: "valid flag with no tag",

			args:     []string{"../../attestation/test/data/github_release_artifact.zip"},
			wantFile: test.NormalizeRelativePath("../../attestation/test/data/github_release_artifact.zip"),
		},
		{
			name:    "no args",
			args:    []string{},
			wantErr: "you must specify an asset filepath",
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			testIO, _, _, _ := iostreams.Test()
+ 37 more lines · read full file
pkg/cmd/release/verify-asset/verify_asset_test.go:89pkg/cmd/release/verify-asset/verify_asset_test::Test_verifyAssetRun_Success · Go · 39 lines
func Test_verifyAssetRun_Success(t *testing.T) {
	ios, _, _, _ := iostreams.Test()
	tagName := "v6"

	fakeHTTP := &httpmock.Registry{}
	defer fakeHTTP.Verify(t)

	fakeSHA := "1234567890abcdef1234567890abcdef12345678"
	shared.StubFetchRefSHA(t, fakeHTTP, "owner", "repo", tagName, fakeSHA)

	baseRepo, err := ghrepo.FromFullName("owner/repo")
	require.NoError(t, err)

	result := &verification.AttestationProcessingResult{
		Attestation: &api.Attestation{
			Bundle:    data.GitHubReleaseBundle(t),
			BundleURL: "https://example.com",
		},
		VerificationResult: nil,
	}

	releaseAssetPath := test.NormalizeRelativePath("../../attestation/test/data/github_release_artifact.zip")

	cfg := &VerifyAssetConfig{
		Opts: &VerifyAssetOptions{
			AssetFilePath: releaseAssetPath,
			TagName:       tagName,
			BaseRepo:      baseRepo,
			Exporter:      nil,
		},
+ 9 more lines · read full file
pkg/cmd/release/verify-asset/verify_asset_test.go:129pkg/cmd/release/verify-asset/verify_asset_test::Test_verifyAssetRun_SuccessNoTagArg · Go · 42 lines
func Test_verifyAssetRun_SuccessNoTagArg(t *testing.T) {
	ios, _, _, _ := iostreams.Test()
	tagName := "v6"

	fakeHTTP := &httpmock.Registry{}
	defer fakeHTTP.Verify(t)
	fakeSHA := "1234567890abcdef1234567890abcdef12345678"
	shared.StubFetchRefSHA(t, fakeHTTP, "OWNER", "REPO", tagName, fakeSHA)
	shared.StubFetchRelease(t, fakeHTTP, "OWNER", "REPO", "", `{
				"tag_name": "v6",
				"draft": false,
				"url": "https://api.github.com/repos/OWNER/REPO/releases/23456"
			}`)

	baseRepo, err := ghrepo.FromFullName("OWNER/REPO")
	require.NoError(t, err)
	result := &verification.AttestationProcessingResult{
		Attestation: &api.Attestation{
			Bundle:    data.GitHubReleaseBundle(t),
			BundleURL: "https://example.com",
		},
		VerificationResult: nil,
	}

	releaseAssetPath := test.NormalizeRelativePath("../../attestation/test/data/github_release_artifact.zip")

	cfg := &VerifyAssetConfig{
		Opts: &VerifyAssetOptions{
			AssetFilePath: releaseAssetPath,
			TagName:       "", // No tag argument provided
+ 12 more lines · read full file
+ 6 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh release verify-asset
short: Verify that a given asset file originated from a specific GitHub Release using cryptographically signed attestations.
long: |-
    An attestation is a claim made by GitHub regarding a release and its assets.

    		This command checks that the asset you provide matches a valid attestation for the specified release (or the latest release, if no tag is given).
DOCS
TESTS

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release verify-asset
short: Verify that a given asset file originated from a specific GitHub Release using cryptographically signed attestations.
long: |-
    An attestation is a claim made by GitHub regarding a release and its assets.

    		This command checks that the asset you provide matches a valid attestation for the specified release (or the latest release, if no tag is given).
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release verify-asset
short: Verify that a given asset file originated from a specific GitHub Release using cryptographically signed attestations.
long: |-
    An attestation is a claim made by GitHub regarding a release and its assets.

    		This command checks that the asset you provide matches a valid attestation for the specified release (or the latest release, if no tag is given).
DOCS
gh_release_verify-asset.md:27Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release view
short: View information about a GitHub Release.
long: |-
    Without an explicit tag name argument, the latest release in the project
    is shown.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_release_view.md:1Markdown · 54 words
TESTS
pkg/cmd/release/view/view_test.go:23pkg/cmd/release/view/view_test::TestJSONFields · Go · 22 lines
func TestJSONFields(t *testing.T) {
	jsonfieldstest.ExpectCommandToSupportJSONFields(t, NewCmdView, []string{
		"apiUrl",
		"author",
		"assets",
		"body",
		"createdAt",
		"databaseId",
		"id",
		"isDraft",
		"isPrerelease",
		"isImmutable",
		"name",
		"publishedAt",
		"tagName",
		"tarballUrl",
		"targetCommitish",
		"uploadUrl",
		"url",
		"zipballUrl",
	})
}
pkg/cmd/release/view/view_test.go:46pkg/cmd/release/view/view_test::Test_NewCmdView · Go · 75 lines
func Test_NewCmdView(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ViewOptions
		wantErr string
	}{
		{
			name:  "version argument",
			args:  "v1.2.3",
			isTTY: true,
			want: ViewOptions{
				TagName: "v1.2.3",
				WebMode: false,
			},
		},
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ViewOptions{
				TagName: "",
				WebMode: false,
			},
		},
		{
			name:  "web mode",
			args:  "-w",
			isTTY: true,
+ 45 more lines · read full file
pkg/cmd/release/view/view_test.go:122pkg/cmd/release/view/view_test::Test_viewRun · Go · 161 lines
func Test_viewRun(t *testing.T) {
	oneHourAgo := time.Now().Add(time.Duration(-24) * time.Hour)
	frozenTime, err := time.Parse(time.RFC3339, "2020-08-31T15:44:24+02:00")
	require.NoError(t, err)

	tests := []struct {
		name        string
		isTTY       bool
		releaseBody string
		releasedAt  time.Time
		opts        ViewOptions
		wantErr     string
		wantStdout  string
		wantStderr  string
	}{
		{
			name:        "view specific release",
			isTTY:       true,
			releaseBody: `* Fixed bugs\n`,
			releasedAt:  oneHourAgo,
			opts: ViewOptions{
				TagName: "v1.2.3",
			},
			wantStdout: heredoc.Doc(`
				v1.2.3
				MonaLisa released this about 1 day ago
				
				                                                                              
				  • Fixed bugs                                                                
				
+ 131 more lines · read full file
+ 1 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh release view
short: View information about a GitHub Release.
long: |-
    Without an explicit tag name argument, the latest release in the project
    is shown.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_release_view.md:23Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release view
short: View information about a GitHub Release.
long: |-
    Without an explicit tag name argument, the latest release in the project
    is shown.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_release_view.md:24Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release view
short: View information about a GitHub Release.
long: |-
    Without an explicit tag name argument, the latest release in the project
    is shown.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_release_view.md:25Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh release view
short: View information about a GitHub Release.
long: |-
    Without an explicit tag name argument, the latest release in the project
    is shown.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh release
plink: gh_release.yaml
options:
    - option: jq
      shorthand: q
DOCS
gh_release_view.md:26Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo
short: Work with GitHub repositories.
pname: gh
plink: gh.yaml
TESTS
pkg/cmd/repo/shared/repo_test.go:7pkg/cmd/repo/shared/repo_test::TestNormalizeRepoName · Go · 42 lines
func TestNormalizeRepoName(t *testing.T) {
	// confirmed using GitHub.com/new
	tests := []struct {
		LocalName      string
		NormalizedName string
	}{
		{
			LocalName:      "cli",
			NormalizedName: "cli",
		},
		{
			LocalName:      "cli.git",
			NormalizedName: "cli",
		},
		{
			LocalName:      "@-#$^",
			NormalizedName: "---",
		},
		{
			LocalName:      "[cli]",
			NormalizedName: "-cli-",
		},
		{
			LocalName:      "Hello World, I'm a new repo!",
			NormalizedName: "Hello-World-I-m-a-new-repo-",
		},
		{
			LocalName:      " @E3H*(#$#_$-ZVp,n.7lGq*_eMa-(-zAZSJYg!",
			NormalizedName: "-E3H-_--ZVp-n.7lGq-_eMa---zAZSJYg-",
		},
+ 12 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo archive
short: Archive a GitHub repository.
long: With no argument, archives the current repository.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: "yes"
      shorthand: "y"
      value_type: bool
      default_value: "false"
      description: Skip the confirmation prompt
DOCS
gh_repo_archive.md:1Markdown · 20 words
TESTS
pkg/cmd/repo/archive/archive_test.go:18pkg/cmd/repo/archive/archive_test::TestNewCmdArchive · Go · 49 lines
func TestNewCmdArchive(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		wantErr bool
		output  ArchiveOptions
		errMsg  string
	}{
		{
			name:    "no arguments no tty",
			input:   "",
			errMsg:  "--yes required when not running interactively",
			wantErr: true,
		},
		{
			name:   "repo argument tty",
			input:  "OWNER/REPO --confirm",
			output: ArchiveOptions{RepoArg: "OWNER/REPO", Confirmed: true},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			f := &cmdutil.Factory{
				IOStreams: ios,
			}
			argv, err := shlex.Split(tt.input)
			assert.NoError(t, err)
			var gotOpts *ArchiveOptions
			cmd := NewCmdArchive(f, func(opts *ArchiveOptions) error {
+ 19 more lines · read full file
pkg/cmd/repo/archive/archive_test.go:68pkg/cmd/repo/archive/archive_test::Test_ArchiveRun · Go · 95 lines
func Test_ArchiveRun(t *testing.T) {
	queryResponse := `{ "data": { "repository": { "id": "THE-ID","isArchived": %s} } }`
	tests := []struct {
		name          string
		opts          ArchiveOptions
		httpStubs     func(*httpmock.Registry)
		prompterStubs func(pm *prompter.MockPrompter)
		isTTY         bool
		wantStdout    string
		wantStderr    string
	}{
		{
			name:       "unarchived repo tty",
			wantStdout: "✓ Archived repository OWNER/REPO\n",
			prompterStubs: func(pm *prompter.MockPrompter) {
				pm.RegisterConfirm("Archive OWNER/REPO?", func(_ string, _ bool) (bool, error) {
					return true, nil
				})
			},
			isTTY: true,
			opts:  ArchiveOptions{RepoArg: "OWNER/REPO"},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query RepositoryInfo\b`),
					httpmock.StringResponse(fmt.Sprintf(queryResponse, "false")))
				reg.Register(
					httpmock.GraphQL(`mutation ArchiveRepository\b`),
					httpmock.StringResponse(`{}`))
			},
		},
+ 65 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo archive
short: Archive a GitHub repository.
long: With no argument, archives the current repository.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: "yes"
      shorthand: "y"
      value_type: bool
      default_value: "false"
      description: Skip the confirmation prompt
DOCS
gh_repo_archive.md:21Markdown · 4 words
TESTS
pkg/cmd/repo/archive/archive_test.go:18pkg/cmd/repo/archive/archive_test::TestNewCmdArchive · Go · 49 lines
func TestNewCmdArchive(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		wantErr bool
		output  ArchiveOptions
		errMsg  string
	}{
		{
			name:    "no arguments no tty",
			input:   "",
			errMsg:  "--yes required when not running interactively",
			wantErr: true,
		},
		{
			name:   "repo argument tty",
			input:  "OWNER/REPO --confirm",
			output: ArchiveOptions{RepoArg: "OWNER/REPO", Confirmed: true},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			f := &cmdutil.Factory{
				IOStreams: ios,
			}
			argv, err := shlex.Split(tt.input)
			assert.NoError(t, err)
			var gotOpts *ArchiveOptions
			cmd := NewCmdArchive(f, func(opts *ArchiveOptions) error {
+ 19 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo autolink
short: Autolinks link issues, pull requests, commit messages, and release descriptions to external third-party services.
long: |-
    Autolinks require `admin` role to view or manage.

    For more information, see <https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/configuring-autolinks-to-reference-external-resources>
pname: gh repo
plink: gh_repo.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
DOCS
gh_repo_autolink.md:1Markdown · 58 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo autolink
short: Autolinks link issues, pull requests, commit messages, and release descriptions to external third-party services.
long: |-
    Autolinks require `admin` role to view or manage.

    For more information, see <https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/configuring-autolinks-to-reference-external-resources>
pname: gh repo
plink: gh_repo.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
DOCS
gh_repo_autolink.md:28Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo autolink create
short: Create a new autolink reference for a repository.
long: |-
    The `keyPrefix` argument specifies the prefix that will generate a link when it is appended by certain characters.

    The `urlTemplate` argument specifies the target URL that will be generated when the keyPrefix is found, which
    must contain `<num>` variable for the reference number.

    By default, autolinks are alphanumeric with `--numeric` flag used to create a numeric autolink.

    The `<num>` variable behavior differs depending on whether the autolink is alphanumeric or numeric:
DOCS
gh_repo_autolink_create.md:1Markdown · 128 words
TESTS
pkg/cmd/repo/autolink/create/create_test.go:19pkg/cmd/repo/autolink/create/create_test::TestNewCmdCreate · Go · 75 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  createOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "Cannot create autolink: keyPrefix and urlTemplate arguments are both required",
		},
		{
			name:    "one argument",
			input:   "TEST-",
			wantErr: true,
			errMsg:  "Cannot create autolink: keyPrefix and urlTemplate arguments are both required",
		},
		{
			name:  "two argument",
			input: "TICKET- https://example.com/TICKET?query=<num>",
			output: createOptions{
				KeyPrefix:   "TICKET-",
				URLTemplate: "https://example.com/TICKET?query=<num>",
			},
		},
		{
			name:  "numeric flag",
+ 45 more lines · read full file
pkg/cmd/repo/autolink/create/create_test.go:118pkg/cmd/repo/autolink/create/create_test::TestCreateRun · Go · 73 lines
func TestCreateRun(t *testing.T) {
	tests := []struct {
		name        string
		opts        *createOptions
		stubCreator stubAutolinkCreator
		expectedErr error
		errMsg      string
		wantStdout  string
		wantStderr  string
	}{
		{
			name: "success, alphanumeric",
			opts: &createOptions{
				KeyPrefix:   "TICKET-",
				URLTemplate: "https://example.com/TICKET?query=<num>",
			},
			stubCreator: stubAutolinkCreator{},
			wantStdout:  "✓ Created repository autolink 1 on OWNER/REPO\n",
		},
		{
			name: "success, numeric",
			opts: &createOptions{
				KeyPrefix:   "TICKET-",
				URLTemplate: "https://example.com/TICKET?query=<num>",
				Numeric:     true,
			},
			stubCreator: stubAutolinkCreator{},
			wantStdout:  "✓ Created repository autolink 1 on OWNER/REPO\n",
		},
		{
+ 43 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh repo autolink create
short: Create a new autolink reference for a repository.
long: |-
    The `keyPrefix` argument specifies the prefix that will generate a link when it is appended by certain characters.

    The `urlTemplate` argument specifies the target URL that will be generated when the keyPrefix is found, which
    must contain `<num>` variable for the reference number.

    By default, autolinks are alphanumeric with `--numeric` flag used to create a numeric autolink.

    The `<num>` variable behavior differs depending on whether the autolink is alphanumeric or numeric:
DOCS
TESTS
pkg/cmd/repo/autolink/create/create_test.go:19pkg/cmd/repo/autolink/create/create_test::TestNewCmdCreate · Go · 75 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  createOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "Cannot create autolink: keyPrefix and urlTemplate arguments are both required",
		},
		{
			name:    "one argument",
			input:   "TEST-",
			wantErr: true,
			errMsg:  "Cannot create autolink: keyPrefix and urlTemplate arguments are both required",
		},
		{
			name:  "two argument",
			input: "TICKET- https://example.com/TICKET?query=<num>",
			output: createOptions{
				KeyPrefix:   "TICKET-",
				URLTemplate: "https://example.com/TICKET?query=<num>",
			},
		},
		{
			name:  "numeric flag",
+ 45 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh repo autolink delete
short: Delete an autolink reference for a repository.
pname: gh repo autolink
plink: gh_repo_autolink.yaml
options:
    - option: "yes"
      value_type: bool
      default_value: "false"
      description: Confirm deletion without prompting
DOCS
gh_repo_autolink_delete.md:1Markdown · 23 words
TESTS
pkg/cmd/repo/autolink/delete/delete_test.go:21pkg/cmd/repo/autolink/delete/delete_test::TestNewCmdDelete · Go · 82 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  deleteOptions
		isTTY   bool
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			isTTY:   true,
			wantErr: true,
			errMsg:  "accepts 1 arg(s), received 0",
		},
		{
			name:   "id provided",
			input:  "123",
			isTTY:  true,
			output: deleteOptions{ID: "123"},
		},
		{
			name:   "yes flag",
			input:  "123 --yes",
			isTTY:  true,
			output: deleteOptions{ID: "123", Confirmed: true},
		},
		{
			name:   "non-TTY",
+ 52 more lines · read full file
pkg/cmd/repo/autolink/delete/delete_test.go:125pkg/cmd/repo/autolink/delete/delete_test::TestDeleteRun · Go · 211 lines
func TestDeleteRun(t *testing.T) {
	tests := []struct {
		name          string
		opts          *deleteOptions
		isTTY         bool
		stubDeleter   stubAutolinkDeleter
		stubViewer    stubAutolinkViewer
		prompterStubs func(*prompter.PrompterMock)

		wantStdout     string
		expectedErr    error
		expectedErrMsg string
	}{
		{
			name: "delete",
			opts: &deleteOptions{
				ID: "123",
			},
			isTTY: true,
			stubViewer: stubAutolinkViewer{
				autolink: &shared.Autolink{
					ID:             123,
					KeyPrefix:      "TICKET-",
					URLTemplate:    "https://example.com/TICKET?query=<num>",
					IsAlphanumeric: true,
				},
			},
			stubDeleter: stubAutolinkDeleter{
				err: nil,
			},
+ 181 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo autolink delete
short: Delete an autolink reference for a repository.
pname: gh repo autolink
plink: gh_repo_autolink.yaml
options:
    - option: "yes"
      value_type: bool
      default_value: "false"
      description: Confirm deletion without prompting
DOCS
TESTS
pkg/cmd/repo/autolink/delete/delete_test.go:21pkg/cmd/repo/autolink/delete/delete_test::TestNewCmdDelete · Go · 82 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  deleteOptions
		isTTY   bool
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			isTTY:   true,
			wantErr: true,
			errMsg:  "accepts 1 arg(s), received 0",
		},
		{
			name:   "id provided",
			input:  "123",
			isTTY:  true,
			output: deleteOptions{ID: "123"},
		},
		{
			name:   "yes flag",
			input:  "123 --yes",
			isTTY:  true,
			output: deleteOptions{ID: "123", Confirmed: true},
		},
		{
			name:   "non-TTY",
+ 52 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo autolink list
short: Gets all autolink references that are configured for a repository.
long: |-
    Information about autolinks is only available to repository administrators.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo autolink
plink: gh_repo_autolink.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
DOCS
gh_repo_autolink_list.md:1Markdown · 46 words
TESTS
pkg/cmd/repo/autolink/list/list_test.go:20pkg/cmd/repo/autolink/list/list_test::TestJSONFields · Go · 8 lines
func TestJSONFields(t *testing.T) {
	jsonfieldstest.ExpectCommandToSupportJSONFields(t, NewCmdList, []string{
		"id",
		"isAlphanumeric",
		"keyPrefix",
		"urlTemplate",
	})
}
pkg/cmd/repo/autolink/list/list_test.go:29pkg/cmd/repo/autolink/list/list_test::TestNewCmdList · Go · 69 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name         string
		input        string
		output       listOptions
		wantErr      bool
		wantExporter bool
		errMsg       string
	}{
		{
			name:   "no argument",
			input:  "",
			output: listOptions{},
		},
		{
			name:   "web flag",
			input:  "--web",
			output: listOptions{WebMode: true},
		},
		{
			name:         "json flag",
			input:        "--json id",
			output:       listOptions{},
			wantExporter: true,
		},
		{
			name:    "invalid json flag",
			input:   "--json invalid",
			output:  listOptions{},
			wantErr: true,
+ 39 more lines · read full file
pkg/cmd/repo/autolink/list/list_test.go:114pkg/cmd/repo/autolink/list/list_test::TestListRun · Go · 155 lines
func TestListRun(t *testing.T) {
	tests := []struct {
		name        string
		opts        *listOptions
		isTTY       bool
		stubLister  stubAutolinkLister
		expectedErr error
		wantStdout  string
		wantStderr  string
	}{
		{
			name:  "list tty",
			opts:  &listOptions{},
			isTTY: true,
			stubLister: stubAutolinkLister{
				autolinks: []shared.Autolink{
					{
						ID:             1,
						KeyPrefix:      "TICKET-",
						URLTemplate:    "https://example.com/TICKET?query=<num>",
						IsAlphanumeric: true,
					},
					{
						ID:             2,
						KeyPrefix:      "STORY-",
						URLTemplate:    "https://example.com/STORY?id=<num>",
						IsAlphanumeric: false,
					},
				},
			},
+ 125 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo autolink list
short: Gets all autolink references that are configured for a repository.
long: |-
    Information about autolinks is only available to repository administrators.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo autolink
plink: gh_repo_autolink.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
DOCS
gh_repo_autolink_list.md:22Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo autolink list
short: Gets all autolink references that are configured for a repository.
long: |-
    Information about autolinks is only available to repository administrators.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo autolink
plink: gh_repo_autolink.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
DOCS
gh_repo_autolink_list.md:23Markdown · 6 words
TESTS
pkg/cmd/repo/autolink/list/list_test.go:29pkg/cmd/repo/autolink/list/list_test::TestNewCmdList · Go · 69 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name         string
		input        string
		output       listOptions
		wantErr      bool
		wantExporter bool
		errMsg       string
	}{
		{
			name:   "no argument",
			input:  "",
			output: listOptions{},
		},
		{
			name:   "web flag",
			input:  "--web",
			output: listOptions{WebMode: true},
		},
		{
			name:         "json flag",
			input:        "--json id",
			output:       listOptions{},
			wantExporter: true,
		},
		{
			name:    "invalid json flag",
			input:   "--json invalid",
			output:  listOptions{},
			wantErr: true,
+ 39 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo autolink list
short: Gets all autolink references that are configured for a repository.
long: |-
    Information about autolinks is only available to repository administrators.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo autolink
plink: gh_repo_autolink.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
DOCS
gh_repo_autolink_list.md:24Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo autolink list
short: Gets all autolink references that are configured for a repository.
long: |-
    Information about autolinks is only available to repository administrators.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo autolink
plink: gh_repo_autolink.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
DOCS
gh_repo_autolink_list.md:25Markdown · 7 words
TESTS
pkg/cmd/repo/autolink/list/list_test.go:29pkg/cmd/repo/autolink/list/list_test::TestNewCmdList · Go · 69 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name         string
		input        string
		output       listOptions
		wantErr      bool
		wantExporter bool
		errMsg       string
	}{
		{
			name:   "no argument",
			input:  "",
			output: listOptions{},
		},
		{
			name:   "web flag",
			input:  "--web",
			output: listOptions{WebMode: true},
		},
		{
			name:         "json flag",
			input:        "--json id",
			output:       listOptions{},
			wantExporter: true,
		},
		{
			name:    "invalid json flag",
			input:   "--json invalid",
			output:  listOptions{},
			wantErr: true,
+ 39 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo autolink view
short: View an autolink reference for a repository.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh repo autolink
plink: gh_repo_autolink.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_repo_autolink_view.md:1Markdown · 29 words
TESTS
pkg/cmd/repo/autolink/view/view_test.go:20pkg/cmd/repo/autolink/view/view_test::TestJSONFields · Go · 8 lines
func TestJSONFields(t *testing.T) {
	jsonfieldstest.ExpectCommandToSupportJSONFields(t, NewCmdView, []string{
		"id",
		"isAlphanumeric",
		"keyPrefix",
		"urlTemplate",
	})
}
pkg/cmd/repo/autolink/view/view_test.go:29pkg/cmd/repo/autolink/view/view_test::TestNewCmdView · Go · 69 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name         string
		input        string
		output       viewOptions
		wantErr      bool
		wantExporter bool
		errMsg       string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "accepts 1 arg(s), received 0",
		},
		{
			name:   "id provided",
			input:  "123",
			output: viewOptions{ID: "123"},
		},
		{
			name:         "json flag",
			input:        "123 --json id",
			output:       viewOptions{ID: "123"},
			wantExporter: true,
		},
		{
			name:    "invalid json flag",
			input:   "123 --json invalid",
			wantErr: true,
+ 39 more lines · read full file
pkg/cmd/repo/autolink/view/view_test.go:114pkg/cmd/repo/autolink/view/view_test::TestViewRun · Go · 84 lines
func TestViewRun(t *testing.T) {
	tests := []struct {
		name        string
		opts        *viewOptions
		stubViewer  stubAutolinkViewer
		expectedErr error
		wantStdout  string
	}{
		{
			name: "view",
			opts: &viewOptions{
				ID: "1",
			},
			stubViewer: stubAutolinkViewer{
				autolink: &shared.Autolink{
					ID:             1,
					KeyPrefix:      "TICKET-",
					URLTemplate:    "https://example.com/TICKET?query=<num>",
					IsAlphanumeric: true,
				},
			},
			wantStdout: heredoc.Doc(`
				Autolink in OWNER/REPO

				ID: 1
				Key Prefix: TICKET-
				URL Template: https://example.com/TICKET?query=<num>
				Alphanumeric: true
			`),
		},
+ 54 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo autolink view
short: View an autolink reference for a repository.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh repo autolink
plink: gh_repo_autolink.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_repo_autolink_view.md:19Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo autolink view
short: View an autolink reference for a repository.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh repo autolink
plink: gh_repo_autolink.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_repo_autolink_view.md:20Markdown · 6 words
TESTS
pkg/cmd/repo/autolink/view/view_test.go:29pkg/cmd/repo/autolink/view/view_test::TestNewCmdView · Go · 69 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name         string
		input        string
		output       viewOptions
		wantErr      bool
		wantExporter bool
		errMsg       string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "accepts 1 arg(s), received 0",
		},
		{
			name:   "id provided",
			input:  "123",
			output: viewOptions{ID: "123"},
		},
		{
			name:         "json flag",
			input:        "123 --json id",
			output:       viewOptions{ID: "123"},
			wantExporter: true,
		},
		{
			name:    "invalid json flag",
			input:   "123 --json invalid",
			wantErr: true,
+ 39 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo autolink view
short: View an autolink reference for a repository.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh repo autolink
plink: gh_repo_autolink.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_repo_autolink_view.md:21Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo clone
short: Clone a GitHub repository locally. Pass additional `git clone` flags by listing
long: |-
    them after `--`.

    If the `OWNER/` portion of the `OWNER/REPO` repository argument is omitted, it
    defaults to the name of the authenticating user.

    When a protocol scheme is not provided in the repository argument, the `git_protocol` will be
    chosen from your configuration, which can be checked via `gh config get git_protocol`. If the protocol
    scheme is provided, the repository will be cloned using the specified protocol.
TESTS
pkg/cmd/repo/clone/clone_test.go:21pkg/cmd/repo/clone/clone_test::TestNewCmdClone · Go · 92 lines
func TestNewCmdClone(t *testing.T) {
	testCases := []struct {
		name     string
		args     string
		wantOpts CloneOptions
		wantErr  string
	}{
		{
			name:    "no arguments",
			args:    "",
			wantErr: "cannot clone: repository argument required",
		},
		{
			name: "repo argument",
			args: "OWNER/REPO",
			wantOpts: CloneOptions{
				Repository: "OWNER/REPO",
				GitArgs:    []string{},
			},
		},
		{
			name: "directory argument",
			args: "OWNER/REPO mydir",
			wantOpts: CloneOptions{
				Repository: "OWNER/REPO",
				GitArgs:    []string{"mydir"},
			},
		},
		{
			name: "git clone arguments",
+ 62 more lines · read full file
pkg/cmd/repo/clone/clone_test.go:152pkg/cmd/repo/clone/clone_test::Test_RepoClone · Go · 94 lines
func Test_RepoClone(t *testing.T) {
	tests := []struct {
		name string
		args string
		want string
	}{
		{
			name: "shorthand",
			args: "OWNER/REPO",
			want: "git clone https://github.com/OWNER/REPO.git",
		},
		{
			name: "shorthand with directory",
			args: "OWNER/REPO target_directory",
			want: "git clone https://github.com/OWNER/REPO.git target_directory",
		},
		{
			name: "clone arguments",
			args: "OWNER/REPO -- -o upstream --depth 1",
			want: "git clone -o upstream --depth 1 https://github.com/OWNER/REPO.git",
		},
		{
			name: "clone arguments with directory",
			args: "OWNER/REPO target_directory -- -o upstream --depth 1",
			want: "git clone -o upstream --depth 1 https://github.com/OWNER/REPO.git target_directory",
		},
		{
			name: "HTTPS URL",
			args: "https://github.com/OWNER/REPO",
			want: "git clone https://github.com/OWNER/REPO.git",
+ 64 more lines · read full file
pkg/cmd/repo/clone/clone_test.go:247pkg/cmd/repo/clone/clone_test::Test_RepoClone_hasParent · Go · 39 lines
func Test_RepoClone_hasParent(t *testing.T) {
	reg := &httpmock.Registry{}
	defer reg.Verify(t)
	reg.Register(
		httpmock.GraphQL(`query RepositoryInfo\b`),
		httpmock.StringResponse(`
				{ "data": { "repository": {
					"name": "REPO",
					"owner": {
						"login": "OWNER"
					},
					"parent": {
						"name": "ORIG",
						"owner": {
							"login": "hubot"
						},
						"defaultBranchRef": {
							"name": "trunk"
						}
					}
				} } }
				`))

	httpClient := &http.Client{Transport: reg}

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	cs.Register(`git clone https://github.com/OWNER/REPO.git`, 0, "")
	cs.Register(`git -C REPO remote add -t trunk upstream https://github.com/hubot/ORIG.git`, 0, "")
+ 9 more lines · read full file
+ 5 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo clone
short: Clone a GitHub repository locally. Pass additional `git clone` flags by listing
long: |-
    them after `--`.

    If the `OWNER/` portion of the `OWNER/REPO` repository argument is omitted, it
    defaults to the name of the authenticating user.

    When a protocol scheme is not provided in the repository argument, the `git_protocol` will be
    chosen from your configuration, which can be checked via `gh config get git_protocol`. If the protocol
    scheme is provided, the repository will be cloned using the specified protocol.
DOCS
gh_repo_clone.md:36Markdown · 10 words
TESTS
pkg/cmd/repo/clone/clone_test.go:21pkg/cmd/repo/clone/clone_test::TestNewCmdClone · Go · 92 lines
func TestNewCmdClone(t *testing.T) {
	testCases := []struct {
		name     string
		args     string
		wantOpts CloneOptions
		wantErr  string
	}{
		{
			name:    "no arguments",
			args:    "",
			wantErr: "cannot clone: repository argument required",
		},
		{
			name: "repo argument",
			args: "OWNER/REPO",
			wantOpts: CloneOptions{
				Repository: "OWNER/REPO",
				GitArgs:    []string{},
			},
		},
		{
			name: "directory argument",
			args: "OWNER/REPO mydir",
			wantOpts: CloneOptions{
				Repository: "OWNER/REPO",
				GitArgs:    []string{"mydir"},
			},
		},
		{
			name: "git clone arguments",
+ 62 more lines · read full file
pkg/cmd/repo/clone/clone_test.go:362pkg/cmd/repo/clone/clone_test::Test_RepoClone_hasParent_noUpstream · Go · 36 lines
func Test_RepoClone_hasParent_noUpstream(t *testing.T) {
	reg := &httpmock.Registry{}
	defer reg.Verify(t)
	reg.Register(
		httpmock.GraphQL(`query RepositoryInfo\b`),
		httpmock.StringResponse(`
				{ "data": { "repository": {
					"name": "REPO",
					"owner": {
						"login": "OWNER"
					},
					"parent": {
						"name": "ORIG",
						"owner": {
							"login": "hubot"
						},
						"defaultBranchRef": {
							"name": "trunk"
						}
					}
				} } }
				`))

	httpClient := &http.Client{Transport: reg}

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	cs.Register(`git clone https://github.com/OWNER/REPO.git`, 0, "")
	cs.Register(`git -C REPO config --add remote.origin.gh-resolved base`, 0, "")
+ 6 more lines · read full file
pkg/cmd/repo/clone/clone_test.go:399pkg/cmd/repo/clone/clone_test::Test_RepoClone_noParent_noUpstream · Go · 26 lines
func Test_RepoClone_noParent_noUpstream(t *testing.T) {
	reg := &httpmock.Registry{}
	defer reg.Verify(t)
	reg.Register(
		httpmock.GraphQL(`query RepositoryInfo\b`),
		httpmock.StringResponse(`
				{ "data": { "repository": {
					"name": "REPO",
					"owner": {
						"login": "OWNER"
					}
				} } }
				`))

	httpClient := &http.Client{Transport: reg}

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	cs.Register(`git clone https://github.com/OWNER/REPO.git`, 0, "")

	_, err := runCloneCommand(httpClient, "OWNER/REPO --no-upstream")
	if err != nil {
		t.Fatalf("error running command `repo clone`: %v", err)
	}
}
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo clone
short: Clone a GitHub repository locally. Pass additional `git clone` flags by listing
long: |-
    them after `--`.

    If the `OWNER/` portion of the `OWNER/REPO` repository argument is omitted, it
    defaults to the name of the authenticating user.

    When a protocol scheme is not provided in the repository argument, the `git_protocol` will be
    chosen from your configuration, which can be checked via `gh config get git_protocol`. If the protocol
    scheme is provided, the repository will be cloned using the specified protocol.
DOCS
gh_repo_clone.md:37Markdown · 7 words
TESTS
pkg/cmd/repo/clone/clone_test.go:21pkg/cmd/repo/clone/clone_test::TestNewCmdClone · Go · 92 lines
func TestNewCmdClone(t *testing.T) {
	testCases := []struct {
		name     string
		args     string
		wantOpts CloneOptions
		wantErr  string
	}{
		{
			name:    "no arguments",
			args:    "",
			wantErr: "cannot clone: repository argument required",
		},
		{
			name: "repo argument",
			args: "OWNER/REPO",
			wantOpts: CloneOptions{
				Repository: "OWNER/REPO",
				GitArgs:    []string{},
			},
		},
		{
			name: "directory argument",
			args: "OWNER/REPO mydir",
			wantOpts: CloneOptions{
				Repository: "OWNER/REPO",
				GitArgs:    []string{"mydir"},
			},
		},
		{
			name: "git clone arguments",
+ 62 more lines · read full file
pkg/cmd/repo/clone/clone_test.go:287pkg/cmd/repo/clone/clone_test::Test_RepoClone_hasParent_upstreamRemoteName · Go · 39 lines
func Test_RepoClone_hasParent_upstreamRemoteName(t *testing.T) {
	reg := &httpmock.Registry{}
	defer reg.Verify(t)
	reg.Register(
		httpmock.GraphQL(`query RepositoryInfo\b`),
		httpmock.StringResponse(`
				{ "data": { "repository": {
					"name": "REPO",
					"owner": {
						"login": "OWNER"
					},
					"parent": {
						"name": "ORIG",
						"owner": {
							"login": "hubot"
						},
						"defaultBranchRef": {
							"name": "trunk"
						}
					}
				} } }
				`))

	httpClient := &http.Client{Transport: reg}

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	cs.Register(`git clone https://github.com/OWNER/REPO.git`, 0, "")
	cs.Register(`git -C REPO remote add -t trunk test https://github.com/hubot/ORIG.git`, 0, "")
+ 9 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
TESTS
pkg/cmd/pr/create/create_test.go:2269pkg/cmd/pr/create/create_test::TestNoRepoCanBeDetermined · Go · 66 lines
func TestNoRepoCanBeDetermined(t *testing.T) {
	// Given no head repo can be determined from git config
	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)

	cs.Register(`git status --porcelain`, 0, "")
	cs.Register(`git config --get-regexp \^branch\\\..+\\\.\(remote\|merge\|pushremote\|gh-merge-base\)\$`, 0, "")
	cs.Register(`git rev-parse --symbolic-full-name feature@{push}`, 1, "")
	cs.Register("git config remote.pushDefault", 1, "")
	cs.Register("git config push.default", 1, "")

	// And Given there is no remote on the correct SHA
	cs.Register(`git show-ref --verify -- HEAD refs/remotes/origin/feature`, 0, heredoc.Doc(`
	deadbeef HEAD
	deadb00f refs/remotes/origin/feature`))

	// When the command is run with no TTY
	reg := &httpmock.Registry{}
	reg.StubRepoInfoResponse("OWNER", "REPO", "master")
	defer reg.Verify(t)

	ios, _, _, stderr := iostreams.Test()

	opts := CreateOptions{
		HttpClient: func() (*http.Client, error) {
			return &http.Client{Transport: reg}, nil
		},
		Config: func() (gh.Config, error) {
			return config.NewBlankConfig(), nil
		},
+ 36 more lines · read full file
pkg/cmd/repo/autolink/create/create_test.go:19pkg/cmd/repo/autolink/create/create_test::TestNewCmdCreate · Go · 75 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  createOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "Cannot create autolink: keyPrefix and urlTemplate arguments are both required",
		},
		{
			name:    "one argument",
			input:   "TEST-",
			wantErr: true,
			errMsg:  "Cannot create autolink: keyPrefix and urlTemplate arguments are both required",
		},
		{
			name:  "two argument",
			input: "TICKET- https://example.com/TICKET?query=<num>",
			output: createOptions{
				KeyPrefix:   "TICKET-",
				URLTemplate: "https://example.com/TICKET?query=<num>",
			},
		},
		{
			name:  "numeric flag",
+ 45 more lines · read full file
pkg/cmd/repo/autolink/create/create_test.go:118pkg/cmd/repo/autolink/create/create_test::TestCreateRun · Go · 73 lines
func TestCreateRun(t *testing.T) {
	tests := []struct {
		name        string
		opts        *createOptions
		stubCreator stubAutolinkCreator
		expectedErr error
		errMsg      string
		wantStdout  string
		wantStderr  string
	}{
		{
			name: "success, alphanumeric",
			opts: &createOptions{
				KeyPrefix:   "TICKET-",
				URLTemplate: "https://example.com/TICKET?query=<num>",
			},
			stubCreator: stubAutolinkCreator{},
			wantStdout:  "✓ Created repository autolink 1 on OWNER/REPO\n",
		},
		{
			name: "success, numeric",
			opts: &createOptions{
				KeyPrefix:   "TICKET-",
				URLTemplate: "https://example.com/TICKET?query=<num>",
				Numeric:     true,
			},
			stubCreator: stubAutolinkCreator{},
			wantStdout:  "✓ Created repository autolink 1 on OWNER/REPO\n",
		},
		{
+ 43 more lines · read full file
+ 3 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:39Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:40Markdown · 8 words
TESTS
pkg/cmd/repo/create/create_test.go:24pkg/cmd/repo/create/create_test::TestNewCmdCreate · Go · 164 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name      string
		tty       bool
		cli       string
		wantsErr  bool
		errMsg    string
		wantsOpts CreateOptions
	}{
		{
			name:      "no args tty",
			tty:       true,
			cli:       "",
			wantsOpts: CreateOptions{Interactive: true},
		},
		{
			name:     "no args no-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
			errMsg:   "at least one argument required in non-interactive mode",
		},
		{
			name: "new repo from remote",
			cli:  "NEWREPO --public --clone",
			wantsOpts: CreateOptions{
				Name:   "NEWREPO",
				Public: true,
				Clone:  true},
		},
+ 134 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:41Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:42Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:43Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:44Markdown · 7 words
TESTS
pkg/cmd/repo/create/create_test.go:24pkg/cmd/repo/create/create_test::TestNewCmdCreate · Go · 164 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name      string
		tty       bool
		cli       string
		wantsErr  bool
		errMsg    string
		wantsOpts CreateOptions
	}{
		{
			name:      "no args tty",
			tty:       true,
			cli:       "",
			wantsOpts: CreateOptions{Interactive: true},
		},
		{
			name:     "no args no-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
			errMsg:   "at least one argument required in non-interactive mode",
		},
		{
			name: "new repo from remote",
			cli:  "NEWREPO --public --clone",
			wantsOpts: CreateOptions{
				Name:   "NEWREPO",
				Public: true,
				Clone:  true},
		},
+ 134 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:45Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:46Markdown · 6 words
TESTS
pkg/cmd/repo/create/create_test.go:24pkg/cmd/repo/create/create_test::TestNewCmdCreate · Go · 164 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name      string
		tty       bool
		cli       string
		wantsErr  bool
		errMsg    string
		wantsOpts CreateOptions
	}{
		{
			name:      "no args tty",
			tty:       true,
			cli:       "",
			wantsOpts: CreateOptions{Interactive: true},
		},
		{
			name:     "no args no-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
			errMsg:   "at least one argument required in non-interactive mode",
		},
		{
			name: "new repo from remote",
			cli:  "NEWREPO --public --clone",
			wantsOpts: CreateOptions{
				Name:   "NEWREPO",
				Public: true,
				Clone:  true},
		},
+ 134 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:47Markdown · 5 words
TESTS
pkg/cmd/repo/create/create_test.go:24pkg/cmd/repo/create/create_test::TestNewCmdCreate · Go · 164 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name      string
		tty       bool
		cli       string
		wantsErr  bool
		errMsg    string
		wantsOpts CreateOptions
	}{
		{
			name:      "no args tty",
			tty:       true,
			cli:       "",
			wantsOpts: CreateOptions{Interactive: true},
		},
		{
			name:     "no args no-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
			errMsg:   "at least one argument required in non-interactive mode",
		},
		{
			name: "new repo from remote",
			cli:  "NEWREPO --public --clone",
			wantsOpts: CreateOptions{
				Name:   "NEWREPO",
				Public: true,
				Clone:  true},
		},
+ 134 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:48Markdown · 8 words
TESTS
pkg/cmd/repo/create/create_test.go:24pkg/cmd/repo/create/create_test::TestNewCmdCreate · Go · 164 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name      string
		tty       bool
		cli       string
		wantsErr  bool
		errMsg    string
		wantsOpts CreateOptions
	}{
		{
			name:      "no args tty",
			tty:       true,
			cli:       "",
			wantsOpts: CreateOptions{Interactive: true},
		},
		{
			name:     "no args no-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
			errMsg:   "at least one argument required in non-interactive mode",
		},
		{
			name: "new repo from remote",
			cli:  "NEWREPO --public --clone",
			wantsOpts: CreateOptions{
				Name:   "NEWREPO",
				Public: true,
				Clone:  true},
		},
+ 134 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:49Markdown · 5 words
TESTS
pkg/cmd/repo/create/create_test.go:24pkg/cmd/repo/create/create_test::TestNewCmdCreate · Go · 164 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name      string
		tty       bool
		cli       string
		wantsErr  bool
		errMsg    string
		wantsOpts CreateOptions
	}{
		{
			name:      "no args tty",
			tty:       true,
			cli:       "",
			wantsOpts: CreateOptions{Interactive: true},
		},
		{
			name:     "no args no-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
			errMsg:   "at least one argument required in non-interactive mode",
		},
		{
			name: "new repo from remote",
			cli:  "NEWREPO --public --clone",
			wantsOpts: CreateOptions{
				Name:   "NEWREPO",
				Public: true,
				Clone:  true},
		},
+ 134 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
TESTS
pkg/cmd/repo/create/create_test.go:24pkg/cmd/repo/create/create_test::TestNewCmdCreate · Go · 164 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name      string
		tty       bool
		cli       string
		wantsErr  bool
		errMsg    string
		wantsOpts CreateOptions
	}{
		{
			name:      "no args tty",
			tty:       true,
			cli:       "",
			wantsOpts: CreateOptions{Interactive: true},
		},
		{
			name:     "no args no-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
			errMsg:   "at least one argument required in non-interactive mode",
		},
		{
			name: "new repo from remote",
			cli:  "NEWREPO --public --clone",
			wantsOpts: CreateOptions{
				Name:   "NEWREPO",
				Public: true,
				Clone:  true},
		},
+ 134 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
TESTS
pkg/cmd/repo/create/create_test.go:24pkg/cmd/repo/create/create_test::TestNewCmdCreate · Go · 164 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name      string
		tty       bool
		cli       string
		wantsErr  bool
		errMsg    string
		wantsOpts CreateOptions
	}{
		{
			name:      "no args tty",
			tty:       true,
			cli:       "",
			wantsOpts: CreateOptions{Interactive: true},
		},
		{
			name:     "no args no-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
			errMsg:   "at least one argument required in non-interactive mode",
		},
		{
			name: "new repo from remote",
			cli:  "NEWREPO --public --clone",
			wantsOpts: CreateOptions{
				Name:   "NEWREPO",
				Public: true,
				Clone:  true},
		},
+ 134 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:52Markdown · 7 words
TESTS
pkg/cmd/repo/create/create_test.go:24pkg/cmd/repo/create/create_test::TestNewCmdCreate · Go · 164 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name      string
		tty       bool
		cli       string
		wantsErr  bool
		errMsg    string
		wantsOpts CreateOptions
	}{
		{
			name:      "no args tty",
			tty:       true,
			cli:       "",
			wantsOpts: CreateOptions{Interactive: true},
		},
		{
			name:     "no args no-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
			errMsg:   "at least one argument required in non-interactive mode",
		},
		{
			name: "new repo from remote",
			cli:  "NEWREPO --public --clone",
			wantsOpts: CreateOptions{
				Name:   "NEWREPO",
				Public: true,
				Clone:  true},
		},
+ 134 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
TESTS
pkg/cmd/repo/create/create_test.go:24pkg/cmd/repo/create/create_test::TestNewCmdCreate · Go · 164 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name      string
		tty       bool
		cli       string
		wantsErr  bool
		errMsg    string
		wantsOpts CreateOptions
	}{
		{
			name:      "no args tty",
			tty:       true,
			cli:       "",
			wantsOpts: CreateOptions{Interactive: true},
		},
		{
			name:     "no args no-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
			errMsg:   "at least one argument required in non-interactive mode",
		},
		{
			name: "new repo from remote",
			cli:  "NEWREPO --public --clone",
			wantsOpts: CreateOptions{
				Name:   "NEWREPO",
				Public: true,
				Clone:  true},
		},
+ 134 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:54Markdown · 10 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo create
short: Create a new GitHub repository.
long: |-
    To create a repository interactively, use `gh repo create` with no arguments.

    To create a remote repository non-interactively, supply the repository name and one of `--public`, `--private`, or `--internal`.
    Pass `--clone` to clone the new repository locally.

    If the `OWNER/` portion of the `OWNER/REPO` name argument is omitted, it
    defaults to the name of the authenticating user.

    To create a remote repository from an existing local repository, specify the source directory with `--source`.
DOCS
gh_repo_create.md:55Markdown · 9 words
TESTS
pkg/cmd/repo/create/create_test.go:24pkg/cmd/repo/create/create_test::TestNewCmdCreate · Go · 164 lines
func TestNewCmdCreate(t *testing.T) {
	tests := []struct {
		name      string
		tty       bool
		cli       string
		wantsErr  bool
		errMsg    string
		wantsOpts CreateOptions
	}{
		{
			name:      "no args tty",
			tty:       true,
			cli:       "",
			wantsOpts: CreateOptions{Interactive: true},
		},
		{
			name:     "no args no-tty",
			tty:      false,
			cli:      "",
			wantsErr: true,
			errMsg:   "at least one argument required in non-interactive mode",
		},
		{
			name: "new repo from remote",
			cli:  "NEWREPO --public --clone",
			wantsOpts: CreateOptions{
				Name:   "NEWREPO",
				Public: true,
				Clone:  true},
		},
+ 134 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo delete
short: Delete a GitHub repository.
long: "With no argument, deletes the current repository. Otherwise, deletes the specified repository.\n\nFor safety, when no repository argument is provided, the `--yes` flag is ignored \nand you will be prompted for confirmation. To delete the current repository non-interactively, \nspecify it explicitly (e.g., `gh repo delete owner/repo --yes`).\n\nDeletion requires authorization with the `delete_repo` scope.\nTo authorize, run `gh auth refresh -s delete_repo`"
DOCS
gh_repo_delete.md:1Markdown · 75 words
TESTS
pkg/cmd/repo/autolink/delete/delete_test.go:21pkg/cmd/repo/autolink/delete/delete_test::TestNewCmdDelete · Go · 82 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  deleteOptions
		isTTY   bool
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no argument",
			input:   "",
			isTTY:   true,
			wantErr: true,
			errMsg:  "accepts 1 arg(s), received 0",
		},
		{
			name:   "id provided",
			input:  "123",
			isTTY:  true,
			output: deleteOptions{ID: "123"},
		},
		{
			name:   "yes flag",
			input:  "123 --yes",
			isTTY:  true,
			output: deleteOptions{ID: "123", Confirmed: true},
		},
		{
			name:   "non-TTY",
+ 52 more lines · read full file
pkg/cmd/repo/autolink/delete/delete_test.go:125pkg/cmd/repo/autolink/delete/delete_test::TestDeleteRun · Go · 211 lines
func TestDeleteRun(t *testing.T) {
	tests := []struct {
		name          string
		opts          *deleteOptions
		isTTY         bool
		stubDeleter   stubAutolinkDeleter
		stubViewer    stubAutolinkViewer
		prompterStubs func(*prompter.PrompterMock)

		wantStdout     string
		expectedErr    error
		expectedErrMsg string
	}{
		{
			name: "delete",
			opts: &deleteOptions{
				ID: "123",
			},
			isTTY: true,
			stubViewer: stubAutolinkViewer{
				autolink: &shared.Autolink{
					ID:             123,
					KeyPrefix:      "TICKET-",
					URLTemplate:    "https://example.com/TICKET?query=<num>",
					IsAlphanumeric: true,
				},
			},
			stubDeleter: stubAutolinkDeleter{
				err: nil,
			},
+ 181 more lines · read full file
pkg/cmd/repo/delete/delete_test.go:17pkg/cmd/repo/delete/delete_test::TestNewCmdDelete · Go · 97 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name       string
		input      string
		tty        bool
		output     DeleteOptions
		wantErr    bool
		wantErrMsg string
		wantStderr string
	}{
		{
			name:   "confirm flag",
			tty:    true,
			input:  "OWNER/REPO --confirm",
			output: DeleteOptions{RepoArg: "OWNER/REPO", Confirmed: true},
		},
		{
			name:   "yes flag",
			tty:    true,
			input:  "OWNER/REPO --yes",
			output: DeleteOptions{RepoArg: "OWNER/REPO", Confirmed: true},
		},
		{
			name:       "no confirmation notty",
			input:      "OWNER/REPO",
			output:     DeleteOptions{RepoArg: "OWNER/REPO"},
			wantErr:    true,
			wantErrMsg: "--yes required when not running interactively",
		},
		{
+ 67 more lines · read full file
+ 4 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo delete
short: Delete a GitHub repository.
long: "With no argument, deletes the current repository. Otherwise, deletes the specified repository.\n\nFor safety, when no repository argument is provided, the `--yes` flag is ignored \nand you will be prompted for confirmation. To delete the current repository non-interactively, \nspecify it explicitly (e.g., `gh repo delete owner/repo --yes`).\n\nDeletion requires authorization with the `delete_repo` scope.\nTo authorize, run `gh auth refresh -s delete_repo`"
DOCS
gh_repo_delete.md:29Markdown · 4 words
TESTS
pkg/cmd/repo/delete/delete_test.go:17pkg/cmd/repo/delete/delete_test::TestNewCmdDelete · Go · 97 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name       string
		input      string
		tty        bool
		output     DeleteOptions
		wantErr    bool
		wantErrMsg string
		wantStderr string
	}{
		{
			name:   "confirm flag",
			tty:    true,
			input:  "OWNER/REPO --confirm",
			output: DeleteOptions{RepoArg: "OWNER/REPO", Confirmed: true},
		},
		{
			name:   "yes flag",
			tty:    true,
			input:  "OWNER/REPO --yes",
			output: DeleteOptions{RepoArg: "OWNER/REPO", Confirmed: true},
		},
		{
			name:       "no confirmation notty",
			input:      "OWNER/REPO",
			output:     DeleteOptions{RepoArg: "OWNER/REPO"},
			wantErr:    true,
			wantErrMsg: "--yes required when not running interactively",
		},
		{
+ 67 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo deploy-key
short: Manage deploy keys in a repository
pname: gh repo
plink: gh_repo.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_repo_deploy-key.md:1Markdown · 32 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo deploy-key
short: Manage deploy keys in a repository
pname: gh repo
plink: gh_repo.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_repo_deploy-key.md:22Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo deploy-key add
short: Add a deploy key to a GitHub repository.
long: |-
    Note that any key added by gh will be associated with the current authentication token.
    If you de-authorize the GitHub CLI app or authentication token from your account, any
    deploy keys added by GitHub CLI will be removed as well.
pname: gh repo deploy-key
plink: gh_repo_deploy-key.yaml
options:
    - option: allow-write
      shorthand: w
      value_type: bool
DOCS
gh_repo_deploy-key_add.md:1Markdown · 65 words
TESTS
pkg/cmd/repo/deploy-key/add/add_test.go:12pkg/cmd/repo/deploy-key/add/add_test::Test_addRun · Go · 74 lines
func Test_addRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       AddOptions
		isTTY      bool
		stdin      string
		httpStubs  func(t *testing.T, reg *httpmock.Registry)
		wantStdout string
		wantStderr string
		wantErr    bool
	}{
		{
			name:  "add from stdin",
			isTTY: true,
			opts: AddOptions{
				KeyFile:    "-",
				Title:      "my sacred key",
				AllowWrite: false,
			},
			stdin: "PUBKEY\n",
			httpStubs: func(t *testing.T, reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("POST", "repos/OWNER/REPO/keys"),
					httpmock.RESTPayload(200, `{}`, func(payload map[string]interface{}) {
						if title := payload["title"].(string); title != "my sacred key" {
							t.Errorf("POST title %q, want %q", title, "my sacred key")
						}
						if key := payload["key"].(string); key != "PUBKEY\n" {
							t.Errorf("POST key %q, want %q", key, "PUBKEY\n")
						}
+ 44 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh repo deploy-key add
short: Add a deploy key to a GitHub repository.
long: |-
    Note that any key added by gh will be associated with the current authentication token.
    If you de-authorize the GitHub CLI app or authentication token from your account, any
    deploy keys added by GitHub CLI will be removed as well.
pname: gh repo deploy-key
plink: gh_repo_deploy-key.yaml
options:
    - option: allow-write
      shorthand: w
      value_type: bool
DOCS
gh_repo_deploy-key_add.md:24Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo deploy-key add
short: Add a deploy key to a GitHub repository.
long: |-
    Note that any key added by gh will be associated with the current authentication token.
    If you de-authorize the GitHub CLI app or authentication token from your account, any
    deploy keys added by GitHub CLI will be removed as well.
pname: gh repo deploy-key
plink: gh_repo_deploy-key.yaml
options:
    - option: allow-write
      shorthand: w
      value_type: bool
DOCS
gh_repo_deploy-key_add.md:25Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo deploy-key delete
short: Delete a deploy key from a GitHub repository
pname: gh repo deploy-key
plink: gh_repo_deploy-key.yaml
DOCS
gh_repo_deploy-key_delete.md:1Markdown · 23 words
TESTS
pkg/cmd/repo/deploy-key/delete/delete_test.go:13pkg/cmd/repo/deploy-key/delete/delete_test::Test_deleteRun · Go · 28 lines
func Test_deleteRun(t *testing.T) {
	ios, _, stdout, stderr := iostreams.Test()
	ios.SetStdinTTY(false)
	ios.SetStdoutTTY(true)
	ios.SetStderrTTY(true)

	tr := httpmock.Registry{}
	defer tr.Verify(t)

	tr.Register(
		httpmock.REST("DELETE", "repos/OWNER/REPO/keys/1234"),
		httpmock.StringResponse(`{}`))

	err := deleteRun(&DeleteOptions{
		IO: ios,
		HTTPClient: func() (*http.Client, error) {
			return &http.Client{Transport: &tr}, nil
		},
		BaseRepo: func() (ghrepo.Interface, error) {
			return ghrepo.New("OWNER", "REPO"), nil
		},
		KeyID: "1234",
	})
	assert.NoError(t, err)

	assert.Equal(t, "", stderr.String())
	assert.Equal(t, "✓ Deploy key deleted from OWNER/REPO\n", stdout.String())
}
WORKFLOWS

N/A

CONTRACT
command: gh repo deploy-key list
short: List deploy keys in a GitHub repository
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh repo deploy-key
plink: gh_repo_deploy-key.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_repo_deploy-key_list.md:1Markdown · 35 words
TESTS
pkg/cmd/repo/deploy-key/list/list_test.go:15pkg/cmd/repo/deploy-key/list/list_test::TestListRun · Go · 119 lines
func TestListRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       ListOptions
		isTTY      bool
		httpStubs  func(t *testing.T, reg *httpmock.Registry)
		wantStdout string
		wantStderr string
		wantErr    bool
	}{
		{
			name:  "list tty",
			isTTY: true,
			httpStubs: func(t *testing.T, reg *httpmock.Registry) {
				createdAt := time.Now().Add(time.Duration(-24) * time.Hour)
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/keys"),
					httpmock.StringResponse(fmt.Sprintf(`[
						{
							"id": 1234,
							"key": "ssh-rsa AAAABbBB123",
							"title": "Mac",
							"created_at": "%[1]s",
							"read_only": true
						},
						{
							"id": 5678,
							"key": "ssh-rsa EEEEEEEK247",
							"title": "hubot@Windows",
							"created_at": "%[1]s",
+ 89 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh repo deploy-key list
short: List deploy keys in a GitHub repository
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh repo deploy-key
plink: gh_repo_deploy-key.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo deploy-key list
short: List deploy keys in a GitHub repository
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh repo deploy-key
plink: gh_repo_deploy-key.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo deploy-key list
short: List deploy keys in a GitHub repository
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh repo deploy-key
plink: gh_repo_deploy-key.yaml
options:
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
    - option: json
      value_type: string
DOCS
gh_repo_deploy-key_list.md:21Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:1Markdown · 146 words
TESTS
pkg/cmd/repo/edit/edit_test.go:20pkg/cmd/repo/edit/edit_test::TestNewCmdEdit · Go · 148 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantOpts EditOptions
		wantErr  string
	}{
		{
			name: "change repo description",
			args: "--description hello",
			wantOpts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits: EditRepositoryInput{
					Description: sp("hello"),
				},
			},
		},
		{
			name: "deny public visibility change without accepting consequences",
			args: "--visibility public",
			wantOpts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits:      EditRepositoryInput{},
			},
			wantErr: "use of --visibility flag requires --accept-visibility-change-consequences flag",
		},
		{
			name: "allow public visibility change with accepting consequences",
			args: "--visibility public --accept-visibility-change-consequences",
			wantOpts: EditOptions{
+ 118 more lines · read full file
pkg/cmd/repo/edit/edit_test.go:169pkg/cmd/repo/edit/edit_test::Test_editRun · Go · 170 lines
func Test_editRun(t *testing.T) {
	tests := []struct {
		name        string
		opts        EditOptions
		httpStubs   func(*testing.T, *httpmock.Registry)
		wantsStderr string
		wantsErr    string
	}{
		{
			name: "change name and description",
			opts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits: EditRepositoryInput{
					Homepage:    sp("newURL"),
					Description: sp("hello world!"),
				},
			},
			httpStubs: func(t *testing.T, r *httpmock.Registry) {
				r.Register(
					httpmock.REST("PATCH", "repos/OWNER/REPO"),
					httpmock.RESTPayload(200, `{}`, func(payload map[string]interface{}) {
						assert.Equal(t, 2, len(payload))
						assert.Equal(t, "newURL", payload["homepage"])
						assert.Equal(t, "hello world!", payload["description"])
					}))
			},
		},
		{
			name: "add and remove topics",
			opts: EditOptions{
+ 140 more lines · read full file
pkg/cmd/repo/edit/edit_test.go:340pkg/cmd/repo/edit/edit_test::Test_editRun_interactive · Go · 505 lines
func Test_editRun_interactive(t *testing.T) {
	editList := []string{
		"Default Branch Name",
		"Description",
		"Home Page URL",
		"Issues",
		"Merge Options",
		"Projects",
		"Template Repository",
		"Topics",
		"Visibility",
		"Wikis"}

	tests := []struct {
		name        string
		opts        EditOptions
		promptStubs func(*prompter.MockPrompter)
		httpStubs   func(*testing.T, *httpmock.Registry)
		wantsStderr string
		wantsErr    string
	}{
		{
			name: "forking of org repo",
			opts: EditOptions{
				Repository:      ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				InteractiveMode: true,
			},
			promptStubs: func(pm *prompter.MockPrompter) {
				el := append(editList, optionAllowForking)
				pm.RegisterMultiSelect("What do you want to edit?", nil, el,
+ 475 more lines · read full file
+ 4 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:41Markdown · 8 words
TESTS
pkg/cmd/repo/edit/edit_test.go:20pkg/cmd/repo/edit/edit_test::TestNewCmdEdit · Go · 148 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantOpts EditOptions
		wantErr  string
	}{
		{
			name: "change repo description",
			args: "--description hello",
			wantOpts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits: EditRepositoryInput{
					Description: sp("hello"),
				},
			},
		},
		{
			name: "deny public visibility change without accepting consequences",
			args: "--visibility public",
			wantOpts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits:      EditRepositoryInput{},
			},
			wantErr: "use of --visibility flag requires --accept-visibility-change-consequences flag",
		},
		{
			name: "allow public visibility change with accepting consequences",
			args: "--visibility public --accept-visibility-change-consequences",
			wantOpts: EditOptions{
+ 118 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:42Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:43Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:44Markdown · 15 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:45Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:46Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:47Markdown · 4 words
TESTS
pkg/cmd/repo/edit/edit_test.go:20pkg/cmd/repo/edit/edit_test::TestNewCmdEdit · Go · 148 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantOpts EditOptions
		wantErr  string
	}{
		{
			name: "change repo description",
			args: "--description hello",
			wantOpts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits: EditRepositoryInput{
					Description: sp("hello"),
				},
			},
		},
		{
			name: "deny public visibility change without accepting consequences",
			args: "--visibility public",
			wantOpts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits:      EditRepositoryInput{},
			},
			wantErr: "use of --visibility flag requires --accept-visibility-change-consequences flag",
		},
		{
			name: "allow public visibility change with accepting consequences",
			args: "--visibility public --accept-visibility-change-consequences",
			wantOpts: EditOptions{
+ 118 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:48Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:49Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:50Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:51Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:52Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:53Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:54Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:55Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:56Markdown · 14 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:57Markdown · 7 words
TESTS
pkg/cmd/repo/edit/edit_test.go:20pkg/cmd/repo/edit/edit_test::TestNewCmdEdit · Go · 148 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantOpts EditOptions
		wantErr  string
	}{
		{
			name: "change repo description",
			args: "--description hello",
			wantOpts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits: EditRepositoryInput{
					Description: sp("hello"),
				},
			},
		},
		{
			name: "deny public visibility change without accepting consequences",
			args: "--visibility public",
			wantOpts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits:      EditRepositoryInput{},
			},
			wantErr: "use of --visibility flag requires --accept-visibility-change-consequences flag",
		},
		{
			name: "allow public visibility change with accepting consequences",
			args: "--visibility public --accept-visibility-change-consequences",
			wantOpts: EditOptions{
+ 118 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:58Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:59Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:60Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:61Markdown · 10 words
TESTS
pkg/cmd/repo/edit/edit_test.go:20pkg/cmd/repo/edit/edit_test::TestNewCmdEdit · Go · 148 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantOpts EditOptions
		wantErr  string
	}{
		{
			name: "change repo description",
			args: "--description hello",
			wantOpts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits: EditRepositoryInput{
					Description: sp("hello"),
				},
			},
		},
		{
			name: "deny public visibility change without accepting consequences",
			args: "--visibility public",
			wantOpts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits:      EditRepositoryInput{},
			},
			wantErr: "use of --visibility flag requires --accept-visibility-change-consequences flag",
		},
		{
			name: "allow public visibility change with accepting consequences",
			args: "--visibility public --accept-visibility-change-consequences",
			wantOpts: EditOptions{
+ 118 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:62Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo edit
short: Edit repository settings.
long: To toggle a setting off, use the `--<flag>=false` syntax.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: accept-visibility-change-consequences
      value_type: bool
      default_value: "false"
      description: Accept the consequences of changing the repository visibility
    - option: add-topic
      value_type: stringSlice
DOCS
gh_repo_edit.md:63Markdown · 8 words
TESTS
pkg/cmd/repo/edit/edit_test.go:20pkg/cmd/repo/edit/edit_test::TestNewCmdEdit · Go · 148 lines
func TestNewCmdEdit(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantOpts EditOptions
		wantErr  string
	}{
		{
			name: "change repo description",
			args: "--description hello",
			wantOpts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits: EditRepositoryInput{
					Description: sp("hello"),
				},
			},
		},
		{
			name: "deny public visibility change without accepting consequences",
			args: "--visibility public",
			wantOpts: EditOptions{
				Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
				Edits:      EditRepositoryInput{},
			},
			wantErr: "use of --visibility flag requires --accept-visibility-change-consequences flag",
		},
		{
			name: "allow public visibility change with accepting consequences",
			args: "--visibility public --accept-visibility-change-consequences",
			wantOpts: EditOptions{
+ 118 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo fork
short: Create a fork of a repository.
long: |-
    With no argument, creates a fork of the current repository. Otherwise, forks
    the specified repository.

    By default, the new fork is set to be your `origin` remote and any existing
    origin remote is renamed to `upstream`. To alter this behavior, you can set
    a name for the new fork's remote with `--remote-name`.

    The `upstream` remote will be set as the default remote repository.
TESTS
pkg/cmd/repo/fork/fork_test.go:27pkg/cmd/repo/fork/fork_test::TestNewCmdFork · Go · 169 lines
func TestNewCmdFork(t *testing.T) {
	tests := []struct {
		name    string
		cli     string
		tty     bool
		wants   ForkOptions
		wantErr bool
		errMsg  string
	}{
		{
			name: "repo with git args",
			cli:  "foo/bar -- --foo=bar",
			wants: ForkOptions{
				Repository: "foo/bar",
				GitArgs:    []string{"--foo=bar"},
				RemoteName: "origin",
				Rename:     true,
			},
		},
		{
			name:    "git args without repo",
			cli:     "-- --foo bar",
			wantErr: true,
			errMsg:  "repository argument required when passing git clone flags",
		},
		{
			name: "repo",
			cli:  "foo/bar",
			wants: ForkOptions{
				Repository: "foo/bar",
+ 139 more lines · read full file
pkg/cmd/repo/fork/fork_test.go:197pkg/cmd/repo/fork/fork_test::TestRepoFork · Go · 610 lines
func TestRepoFork(t *testing.T) {
	forkResult := `{
		"node_id": "123",
		"name": "REPO",
		"clone_url": "https://github.com/someone/repo.git",
		"created_at": "2011-01-26T19:01:12Z",
		"owner": {
			"login": "someone"
		}
	}`

	forkPost := func(reg *httpmock.Registry) {
		reg.Register(
			httpmock.REST("POST", "repos/OWNER/REPO/forks"),
			httpmock.StringResponse(forkResult))
	}

	tests := []struct {
		name        string
		opts        *ForkOptions
		tty         bool
		httpStubs   func(*httpmock.Registry)
		execStubs   func(*run.CommandStubber)
		promptStubs func(*prompter.MockPrompter)
		cfgStubs    func(*testing.T, gh.Config)
		remotes     []*context.Remote
		wantOut     string
		wantErrOut  string
		wantErr     bool
		errMsg      string
+ 580 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo fork
short: Create a fork of a repository.
long: |-
    With no argument, creates a fork of the current repository. Otherwise, forks
    the specified repository.

    By default, the new fork is set to be your `origin` remote and any existing
    origin remote is renamed to `upstream`. To alter this behavior, you can set
    a name for the new fork's remote with `--remote-name`.

    The `upstream` remote will be set as the default remote repository.
TESTS
pkg/cmd/repo/fork/fork_test.go:27pkg/cmd/repo/fork/fork_test::TestNewCmdFork · Go · 169 lines
func TestNewCmdFork(t *testing.T) {
	tests := []struct {
		name    string
		cli     string
		tty     bool
		wants   ForkOptions
		wantErr bool
		errMsg  string
	}{
		{
			name: "repo with git args",
			cli:  "foo/bar -- --foo=bar",
			wants: ForkOptions{
				Repository: "foo/bar",
				GitArgs:    []string{"--foo=bar"},
				RemoteName: "origin",
				Rename:     true,
			},
		},
		{
			name:    "git args without repo",
			cli:     "-- --foo bar",
			wantErr: true,
			errMsg:  "repository argument required when passing git clone flags",
		},
		{
			name: "repo",
			cli:  "foo/bar",
			wants: ForkOptions{
				Repository: "foo/bar",
+ 139 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo fork
short: Create a fork of a repository.
long: |-
    With no argument, creates a fork of the current repository. Otherwise, forks
    the specified repository.

    By default, the new fork is set to be your `origin` remote and any existing
    origin remote is renamed to `upstream`. To alter this behavior, you can set
    a name for the new fork's remote with `--remote-name`.

    The `upstream` remote will be set as the default remote repository.
DOCS
gh_repo_fork.md:32Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo fork
short: Create a fork of a repository.
long: |-
    With no argument, creates a fork of the current repository. Otherwise, forks
    the specified repository.

    By default, the new fork is set to be your `origin` remote and any existing
    origin remote is renamed to `upstream`. To alter this behavior, you can set
    a name for the new fork's remote with `--remote-name`.

    The `upstream` remote will be set as the default remote repository.
DOCS
gh_repo_fork.md:33Markdown · 4 words
TESTS
pkg/cmd/repo/fork/fork_test.go:27pkg/cmd/repo/fork/fork_test::TestNewCmdFork · Go · 169 lines
func TestNewCmdFork(t *testing.T) {
	tests := []struct {
		name    string
		cli     string
		tty     bool
		wants   ForkOptions
		wantErr bool
		errMsg  string
	}{
		{
			name: "repo with git args",
			cli:  "foo/bar -- --foo=bar",
			wants: ForkOptions{
				Repository: "foo/bar",
				GitArgs:    []string{"--foo=bar"},
				RemoteName: "origin",
				Rename:     true,
			},
		},
		{
			name:    "git args without repo",
			cli:     "-- --foo bar",
			wantErr: true,
			errMsg:  "repository argument required when passing git clone flags",
		},
		{
			name: "repo",
			cli:  "foo/bar",
			wants: ForkOptions{
				Repository: "foo/bar",
+ 139 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo fork
short: Create a fork of a repository.
long: |-
    With no argument, creates a fork of the current repository. Otherwise, forks
    the specified repository.

    By default, the new fork is set to be your `origin` remote and any existing
    origin remote is renamed to `upstream`. To alter this behavior, you can set
    a name for the new fork's remote with `--remote-name`.

    The `upstream` remote will be set as the default remote repository.
TESTS
pkg/cmd/repo/fork/fork_test.go:27pkg/cmd/repo/fork/fork_test::TestNewCmdFork · Go · 169 lines
func TestNewCmdFork(t *testing.T) {
	tests := []struct {
		name    string
		cli     string
		tty     bool
		wants   ForkOptions
		wantErr bool
		errMsg  string
	}{
		{
			name: "repo with git args",
			cli:  "foo/bar -- --foo=bar",
			wants: ForkOptions{
				Repository: "foo/bar",
				GitArgs:    []string{"--foo=bar"},
				RemoteName: "origin",
				Rename:     true,
			},
		},
		{
			name:    "git args without repo",
			cli:     "-- --foo bar",
			wantErr: true,
			errMsg:  "repository argument required when passing git clone flags",
		},
		{
			name: "repo",
			cli:  "foo/bar",
			wants: ForkOptions{
				Repository: "foo/bar",
+ 139 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo fork
short: Create a fork of a repository.
long: |-
    With no argument, creates a fork of the current repository. Otherwise, forks
    the specified repository.

    By default, the new fork is set to be your `origin` remote and any existing
    origin remote is renamed to `upstream`. To alter this behavior, you can set
    a name for the new fork's remote with `--remote-name`.

    The `upstream` remote will be set as the default remote repository.
TESTS
pkg/cmd/repo/fork/fork_test.go:27pkg/cmd/repo/fork/fork_test::TestNewCmdFork · Go · 169 lines
func TestNewCmdFork(t *testing.T) {
	tests := []struct {
		name    string
		cli     string
		tty     bool
		wants   ForkOptions
		wantErr bool
		errMsg  string
	}{
		{
			name: "repo with git args",
			cli:  "foo/bar -- --foo=bar",
			wants: ForkOptions{
				Repository: "foo/bar",
				GitArgs:    []string{"--foo=bar"},
				RemoteName: "origin",
				Rename:     true,
			},
		},
		{
			name:    "git args without repo",
			cli:     "-- --foo bar",
			wantErr: true,
			errMsg:  "repository argument required when passing git clone flags",
		},
		{
			name: "repo",
			cli:  "foo/bar",
			wants: ForkOptions{
				Repository: "foo/bar",
+ 139 more lines · read full file
pkg/cmd/repo/fork/fork_test.go:197pkg/cmd/repo/fork/fork_test::TestRepoFork · Go · 610 lines
func TestRepoFork(t *testing.T) {
	forkResult := `{
		"node_id": "123",
		"name": "REPO",
		"clone_url": "https://github.com/someone/repo.git",
		"created_at": "2011-01-26T19:01:12Z",
		"owner": {
			"login": "someone"
		}
	}`

	forkPost := func(reg *httpmock.Registry) {
		reg.Register(
			httpmock.REST("POST", "repos/OWNER/REPO/forks"),
			httpmock.StringResponse(forkResult))
	}

	tests := []struct {
		name        string
		opts        *ForkOptions
		tty         bool
		httpStubs   func(*httpmock.Registry)
		execStubs   func(*run.CommandStubber)
		promptStubs func(*prompter.MockPrompter)
		cfgStubs    func(*testing.T, gh.Config)
		remotes     []*context.Remote
		wantOut     string
		wantErrOut  string
		wantErr     bool
		errMsg      string
+ 580 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo fork
short: Create a fork of a repository.
long: |-
    With no argument, creates a fork of the current repository. Otherwise, forks
    the specified repository.

    By default, the new fork is set to be your `origin` remote and any existing
    origin remote is renamed to `upstream`. To alter this behavior, you can set
    a name for the new fork's remote with `--remote-name`.

    The `upstream` remote will be set as the default remote repository.
TESTS
pkg/cmd/repo/fork/fork_test.go:27pkg/cmd/repo/fork/fork_test::TestNewCmdFork · Go · 169 lines
func TestNewCmdFork(t *testing.T) {
	tests := []struct {
		name    string
		cli     string
		tty     bool
		wants   ForkOptions
		wantErr bool
		errMsg  string
	}{
		{
			name: "repo with git args",
			cli:  "foo/bar -- --foo=bar",
			wants: ForkOptions{
				Repository: "foo/bar",
				GitArgs:    []string{"--foo=bar"},
				RemoteName: "origin",
				Rename:     true,
			},
		},
		{
			name:    "git args without repo",
			cli:     "-- --foo bar",
			wantErr: true,
			errMsg:  "repository argument required when passing git clone flags",
		},
		{
			name: "repo",
			cli:  "foo/bar",
			wants: ForkOptions{
				Repository: "foo/bar",
+ 139 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo gitignore
short: List and view available repository gitignore templates
pname: gh repo
plink: gh_repo.yaml
DOCS
gh_repo_gitignore.md:1Markdown · 27 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo gitignore list
short: List available repository gitignore templates
pname: gh repo gitignore
plink: gh_repo_gitignore.yaml
DOCS
gh_repo_gitignore_list.md:1Markdown · 20 words
TESTS
pkg/cmd/repo/gitignore/list/list_test.go:18pkg/cmd/repo/gitignore/list/list_test::TestNewCmdList · Go · 46 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		args    []string
		wantErr bool
		tty     bool
	}{
		{
			name:    "happy path no arguments",
			args:    []string{},
			wantErr: false,
			tty:     false,
		},
		{
			name:    "too many arguments",
			args:    []string{"foo"},
			wantErr: true,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			ios.SetStdinTTY(tt.tty)
			ios.SetStdoutTTY(tt.tty)
			ios.SetStderrTTY(tt.tty)

			f := &cmdutil.Factory{
				IOStreams: ios,
			}
			cmd := NewCmdList(f, func(*ListOptions) error {
+ 16 more lines · read full file
pkg/cmd/repo/gitignore/list/list_test.go:65pkg/cmd/repo/gitignore/list/list_test::TestListRun · Go · 126 lines
func TestListRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       *ListOptions
		isTTY      bool
		httpStubs  func(t *testing.T, reg *httpmock.Registry)
		wantStdout string
		wantStderr string
		wantErr    bool
		errMsg     string
	}{
		{
			name:  "gitignore list tty",
			isTTY: true,
			httpStubs: func(t *testing.T, reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "gitignore/templates"),
					httpmock.StringResponse(`[
						"AL",
						"Actionscript",
						"Ada",
						"Agda",
						"Android",
						"AppEngine",
						"AppceleratorTitanium",
						"ArchLinuxPackages",
						"Autotools",
						"Ballerina",
						"C",
						"C++",
+ 96 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo gitignore view
short: View an available repository `.gitignore` template.
long: |-
    `<template>` is a case-sensitive `.gitignore` template name.

    For a list of available templates, run `gh repo gitignore list`.
pname: gh repo gitignore
plink: gh_repo_gitignore.yaml
DOCS
gh_repo_gitignore_view.md:1Markdown · 35 words
TESTS
pkg/cmd/repo/gitignore/view/view_test.go:18pkg/cmd/repo/gitignore/view/view_test::TestViewRun · Go · 106 lines
func TestViewRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       *ViewOptions
		isTTY      bool
		httpStubs  func(t *testing.T, reg *httpmock.Registry)
		wantStdout string
		wantStderr string
		wantErr    bool
		errMsg     string
	}{
		{
			name:    "No template",
			opts:    &ViewOptions{},
			wantErr: true,
			errMsg:  "no template provided",
		},
		{
			name:    "happy path with template",
			opts:    &ViewOptions{Template: "Go"},
			wantErr: false,
			httpStubs: func(t *testing.T, reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "gitignore/templates/Go"),
					httpmock.StringResponse(`{
						"name": "Go",
						"source": "# If you prefer the allow list template instead of the deny list, see community template:\n# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore\n#\n# Binaries for programs and plugins\n*.exe\n*.exe~\n*.dll\n*.so\n*.dylib\n\n# Test binary, built with go test -c\n*.test\n\n# Output of the go coverage tool, specifically when used with LiteIDE\n*.out\n\n# Dependency directories (remove the comment below to include it)\n# vendor/\n\n# Go workspace file\ngo.work\ngo.work.sum\n\n# env file\n.env\n"
						}`,
					))
			},
+ 76 more lines · read full file
pkg/cmd/repo/gitignore/view/view_test.go:125pkg/cmd/repo/gitignore/view/view_test::TestNewCmdView · Go · 62 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name     string
		args     []string
		wantErr  bool
		wantOpts *ViewOptions
		tty      bool
	}{
		{
			name:    "No template",
			args:    []string{},
			wantErr: true,
			wantOpts: &ViewOptions{
				Template: "",
			},
		},
		{
			name:    "Happy path single template",
			args:    []string{"Go"},
			wantErr: false,
			wantOpts: &ViewOptions{
				Template: "Go",
			},
		},
		{
			name:    "Happy path too many templates",
			args:    []string{"Go", "Ruby"},
			wantErr: true,
			wantOpts: &ViewOptions{
				Template: "",
+ 32 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh repo license
short: Explore repository licenses
pname: gh repo
plink: gh_repo.yaml
DOCS
gh_repo_license.md:1Markdown · 23 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo license list
short: List common repository licenses.
long: For even more licenses, visit <https://choosealicense.com/appendix>
pname: gh repo license
plink: gh_repo_license.yaml
DOCS
gh_repo_license_list.md:1Markdown · 25 words
TESTS
pkg/cmd/repo/license/list/list_test.go:18pkg/cmd/repo/license/list/list_test::TestNewCmdList · Go · 46 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		args    []string
		wantErr bool
		tty     bool
	}{
		{
			name:    "happy path no arguments",
			args:    []string{},
			wantErr: false,
			tty:     false,
		},
		{
			name:    "too many arguments",
			args:    []string{"foo"},
			wantErr: true,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			ios.SetStdinTTY(tt.tty)
			ios.SetStdoutTTY(tt.tty)
			ios.SetStderrTTY(tt.tty)

			f := &cmdutil.Factory{
				IOStreams: ios,
			}
			cmd := NewCmdList(f, func(*ListOptions) error {
+ 16 more lines · read full file
pkg/cmd/repo/license/list/list_test.go:65pkg/cmd/repo/license/list/list_test::TestListRun · Go · 132 lines
func TestListRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       *ListOptions
		isTTY      bool
		httpStubs  func(t *testing.T, reg *httpmock.Registry)
		wantStdout string
		wantStderr string
		wantErr    bool
		errMsg     string
	}{
		{
			name:  "license list tty",
			isTTY: true,
			httpStubs: func(t *testing.T, reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "licenses"),
					httpmock.StringResponse(`[
						{
							"key": "mit",
							"name": "MIT License",
							"spdx_id": "MIT",
							"url": "https://api.github.com/licenses/mit",
							"node_id": "MDc6TGljZW5zZW1pdA=="
						},
						{
							"key": "lgpl-3.0",
							"name": "GNU Lesser General Public License v3.0",
							"spdx_id": "LGPL-3.0",
							"url": "https://api.github.com/licenses/lgpl-3.0",
+ 102 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo license view
short: View a specific repository license by license key or SPDX ID.
long: Run `gh repo license list` to see available commonly used licenses. For even more licenses, visit <https://choosealicense.com/appendix>.
pname: gh repo license
plink: gh_repo_license.yaml
options:
    - option: web
      shorthand: w
      value_type: bool
      default_value: "false"
      description: Open https://choosealicense.com/ in the browser
DOCS
gh_repo_license_view.md:1Markdown · 40 words
TESTS
pkg/cmd/repo/license/view/view_test.go:19pkg/cmd/repo/license/view/view_test::TestNewCmdView · Go · 62 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name     string
		args     []string
		wantErr  bool
		wantOpts *ViewOptions
		tty      bool
	}{
		{
			name:    "No license key or SPDX ID provided",
			args:    []string{},
			wantErr: true,
			wantOpts: &ViewOptions{
				License: "",
			},
		},
		{
			name:    "Happy path single license key",
			args:    []string{"mit"},
			wantErr: false,
			wantOpts: &ViewOptions{
				License: "mit",
			},
		},
		{
			name:    "Happy path too many license keys",
			args:    []string{"mit", "apache-2.0"},
			wantErr: true,
			wantOpts: &ViewOptions{
				License: "",
+ 32 more lines · read full file
pkg/cmd/repo/license/view/view_test.go:82pkg/cmd/repo/license/view/view_test::TestViewRun · Go · 231 lines
func TestViewRun(t *testing.T) {
	tests := []struct {
		name           string
		opts           *ViewOptions
		isTTY          bool
		httpStubs      func(reg *httpmock.Registry)
		wantStdout     string
		wantStderr     string
		wantErr        bool
		errMsg         string
		wantBrowsedURL string
	}{
		{
			name:    "happy path with license no tty",
			opts:    &ViewOptions{License: "mit"},
			wantErr: false,
			isTTY:   false,
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "licenses/mit"),
					httpmock.StringResponse(`{
						"key": "mit",
						"name": "MIT License",
						"spdx_id": "MIT",
						"url": "https://api.github.com/licenses/mit",
						"node_id": "MDc6TGljZW5zZTEz",
						"html_url": "http://choosealicense.com/licenses/mit/",
						"description": "A short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code.",
						"implementation": "Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders.",
						"permissions": [
+ 201 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh repo license view
short: View a specific repository license by license key or SPDX ID.
long: Run `gh repo license list` to see available commonly used licenses. For even more licenses, visit <https://choosealicense.com/appendix>.
pname: gh repo license
plink: gh_repo_license.yaml
options:
    - option: web
      shorthand: w
      value_type: bool
      default_value: "false"
      description: Open https://choosealicense.com/ in the browser
DOCS
gh_repo_license_view.md:22Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo list
short: List repositories owned by a user or organization.
long: |-
    Note that the list will only include repositories owned by the provided argument,
    and the `--fork` or `--source` flags will not traverse ownership boundaries. For example,
    when listing the forks in an organization, the output would not include those owned by individual users.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: archived
DOCS
gh_repo_list.md:1Markdown · 133 words
TESTS
pkg/cmd/repo/autolink/list/list_test.go:20pkg/cmd/repo/autolink/list/list_test::TestJSONFields · Go · 8 lines
func TestJSONFields(t *testing.T) {
	jsonfieldstest.ExpectCommandToSupportJSONFields(t, NewCmdList, []string{
		"id",
		"isAlphanumeric",
		"keyPrefix",
		"urlTemplate",
	})
}
pkg/cmd/repo/autolink/list/list_test.go:29pkg/cmd/repo/autolink/list/list_test::TestNewCmdList · Go · 69 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name         string
		input        string
		output       listOptions
		wantErr      bool
		wantExporter bool
		errMsg       string
	}{
		{
			name:   "no argument",
			input:  "",
			output: listOptions{},
		},
		{
			name:   "web flag",
			input:  "--web",
			output: listOptions{WebMode: true},
		},
		{
			name:         "json flag",
			input:        "--json id",
			output:       listOptions{},
			wantExporter: true,
		},
		{
			name:    "invalid json flag",
			input:   "--json invalid",
			output:  listOptions{},
			wantErr: true,
+ 39 more lines · read full file
pkg/cmd/repo/autolink/list/list_test.go:114pkg/cmd/repo/autolink/list/list_test::TestListRun · Go · 155 lines
func TestListRun(t *testing.T) {
	tests := []struct {
		name        string
		opts        *listOptions
		isTTY       bool
		stubLister  stubAutolinkLister
		expectedErr error
		wantStdout  string
		wantStderr  string
	}{
		{
			name:  "list tty",
			opts:  &listOptions{},
			isTTY: true,
			stubLister: stubAutolinkLister{
				autolinks: []shared.Autolink{
					{
						ID:             1,
						KeyPrefix:      "TICKET-",
						URLTemplate:    "https://example.com/TICKET?query=<num>",
						IsAlphanumeric: true,
					},
					{
						ID:             2,
						KeyPrefix:      "STORY-",
						URLTemplate:    "https://example.com/STORY?id=<num>",
						IsAlphanumeric: false,
					},
				},
			},
+ 125 more lines · read full file
+ 15 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo list
short: List repositories owned by a user or organization.
long: |-
    Note that the list will only include repositories owned by the provided argument,
    and the `--fork` or `--source` flags will not traverse ownership boundaries. For example,
    when listing the forks in an organization, the output would not include those owned by individual users.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: archived
DOCS
gh_repo_list.md:24Markdown · 4 words
TESTS
pkg/cmd/repo/list/list_test.go:98pkg/cmd/repo/list/list_test::TestNewCmdList · Go · 249 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ListOptions{
				Limit:       30,
				Owner:       "",
				Visibility:  "",
				Fork:        false,
				Source:      false,
				Language:    "",
				Topic:       []string(nil),
				Archived:    false,
				NonArchived: false,
			},
		},
		{
			name: "with owner",
			cli:  "monalisa",
			wants: ListOptions{
				Limit:       30,
				Owner:       "monalisa",
				Visibility:  "",
				Fork:        false,
+ 219 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo list
short: List repositories owned by a user or organization.
long: |-
    Note that the list will only include repositories owned by the provided argument,
    and the `--fork` or `--source` flags will not traverse ownership boundaries. For example,
    when listing the forks in an organization, the output would not include those owned by individual users.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: archived
DOCS
gh_repo_list.md:25Markdown · 3 words
TESTS
pkg/cmd/repo/list/list_test.go:98pkg/cmd/repo/list/list_test::TestNewCmdList · Go · 249 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ListOptions{
				Limit:       30,
				Owner:       "",
				Visibility:  "",
				Fork:        false,
				Source:      false,
				Language:    "",
				Topic:       []string(nil),
				Archived:    false,
				NonArchived: false,
			},
		},
		{
			name: "with owner",
			cli:  "monalisa",
			wants: ListOptions{
				Limit:       30,
				Owner:       "monalisa",
				Visibility:  "",
				Fork:        false,
+ 219 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo list
short: List repositories owned by a user or organization.
long: |-
    Note that the list will only include repositories owned by the provided argument,
    and the `--fork` or `--source` flags will not traverse ownership boundaries. For example,
    when listing the forks in an organization, the output would not include those owned by individual users.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: archived
DOCS
gh_repo_list.md:26Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo list
short: List repositories owned by a user or organization.
long: |-
    Note that the list will only include repositories owned by the provided argument,
    and the `--fork` or `--source` flags will not traverse ownership boundaries. For example,
    when listing the forks in an organization, the output would not include those owned by individual users.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: archived
DOCS
gh_repo_list.md:27Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo list
short: List repositories owned by a user or organization.
long: |-
    Note that the list will only include repositories owned by the provided argument,
    and the `--fork` or `--source` flags will not traverse ownership boundaries. For example,
    when listing the forks in an organization, the output would not include those owned by individual users.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: archived
DOCS
gh_repo_list.md:28Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo list
short: List repositories owned by a user or organization.
long: |-
    Note that the list will only include repositories owned by the provided argument,
    and the `--fork` or `--source` flags will not traverse ownership boundaries. For example,
    when listing the forks in an organization, the output would not include those owned by individual users.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: archived
DOCS
gh_repo_list.md:29Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo list
short: List repositories owned by a user or organization.
long: |-
    Note that the list will only include repositories owned by the provided argument,
    and the `--fork` or `--source` flags will not traverse ownership boundaries. For example,
    when listing the forks in an organization, the output would not include those owned by individual users.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: archived
DOCS
gh_repo_list.md:30Markdown · 3 words
TESTS
pkg/cmd/repo/list/list_test.go:98pkg/cmd/repo/list/list_test::TestNewCmdList · Go · 249 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ListOptions{
				Limit:       30,
				Owner:       "",
				Visibility:  "",
				Fork:        false,
				Source:      false,
				Language:    "",
				Topic:       []string(nil),
				Archived:    false,
				NonArchived: false,
			},
		},
		{
			name: "with owner",
			cli:  "monalisa",
			wants: ListOptions{
				Limit:       30,
				Owner:       "monalisa",
				Visibility:  "",
				Fork:        false,
+ 219 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo list
short: List repositories owned by a user or organization.
long: |-
    Note that the list will only include repositories owned by the provided argument,
    and the `--fork` or `--source` flags will not traverse ownership boundaries. For example,
    when listing the forks in an organization, the output would not include those owned by individual users.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: archived
DOCS
gh_repo_list.md:31Markdown · 3 words
TESTS
pkg/cmd/repo/list/list_test.go:98pkg/cmd/repo/list/list_test::TestNewCmdList · Go · 249 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ListOptions{
				Limit:       30,
				Owner:       "",
				Visibility:  "",
				Fork:        false,
				Source:      false,
				Language:    "",
				Topic:       []string(nil),
				Archived:    false,
				NonArchived: false,
			},
		},
		{
			name: "with owner",
			cli:  "monalisa",
			wants: ListOptions{
				Limit:       30,
				Owner:       "monalisa",
				Visibility:  "",
				Fork:        false,
+ 219 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo list
short: List repositories owned by a user or organization.
long: |-
    Note that the list will only include repositories owned by the provided argument,
    and the `--fork` or `--source` flags will not traverse ownership boundaries. For example,
    when listing the forks in an organization, the output would not include those owned by individual users.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: archived
DOCS
gh_repo_list.md:32Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo list
short: List repositories owned by a user or organization.
long: |-
    Note that the list will only include repositories owned by the provided argument,
    and the `--fork` or `--source` flags will not traverse ownership boundaries. For example,
    when listing the forks in an organization, the output would not include those owned by individual users.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: archived
DOCS
gh_repo_list.md:33Markdown · 3 words
TESTS
pkg/cmd/repo/list/list_test.go:98pkg/cmd/repo/list/list_test::TestNewCmdList · Go · 249 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ListOptions{
				Limit:       30,
				Owner:       "",
				Visibility:  "",
				Fork:        false,
				Source:      false,
				Language:    "",
				Topic:       []string(nil),
				Archived:    false,
				NonArchived: false,
			},
		},
		{
			name: "with owner",
			cli:  "monalisa",
			wants: ListOptions{
				Limit:       30,
				Owner:       "monalisa",
				Visibility:  "",
				Fork:        false,
+ 219 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo list
short: List repositories owned by a user or organization.
long: |-
    Note that the list will only include repositories owned by the provided argument,
    and the `--fork` or `--source` flags will not traverse ownership boundaries. For example,
    when listing the forks in an organization, the output would not include those owned by individual users.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: archived
DOCS
gh_repo_list.md:34Markdown · 5 words
TESTS
pkg/cmd/repo/list/list_test.go:98pkg/cmd/repo/list/list_test::TestNewCmdList · Go · 249 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr string
	}{
		{
			name: "no arguments",
			cli:  "",
			wants: ListOptions{
				Limit:       30,
				Owner:       "",
				Visibility:  "",
				Fork:        false,
				Source:      false,
				Language:    "",
				Topic:       []string(nil),
				Archived:    false,
				NonArchived: false,
			},
		},
		{
			name: "with owner",
			cli:  "monalisa",
			wants: ListOptions{
				Limit:       30,
				Owner:       "monalisa",
				Visibility:  "",
				Fork:        false,
+ 219 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo rename
short: Rename a GitHub repository.
long: |-
    `<new-name>` is the desired repository name without the owner.

    By default, the current repository is renamed. Otherwise, the repository specified
    with `--repo` is renamed.

    To transfer repository ownership to another user account or organization,
    you must follow additional steps on `github.com`.
pname: gh repo
plink: gh_repo.yaml
DOCS
gh_repo_rename.md:1Markdown · 64 words
TESTS
pkg/cmd/repo/rename/rename_test.go:22pkg/cmd/repo/rename/rename_test::TestNewCmdRename · Go · 84 lines
func TestNewCmdRename(t *testing.T) {
	testCases := []struct {
		name    string
		input   string
		output  RenameOptions
		errMsg  string
		tty     bool
		wantErr bool
	}{
		{
			name:    "no arguments no tty",
			input:   "",
			errMsg:  "new name argument required when not running interactively",
			wantErr: true,
		},
		{
			name:  "one argument no tty confirmed",
			input: "REPO --yes",
			output: RenameOptions{
				newRepoSelector: "REPO",
			},
		},
		{
			name:    "one argument no tty",
			input:   "REPO",
			errMsg:  "--yes required when passing a single argument",
			wantErr: true,
		},
		{
			name:  "one argument tty confirmed",
+ 54 more lines · read full file
pkg/cmd/repo/rename/rename_test.go:107pkg/cmd/repo/rename/rename_test::TestRenameRun · Go · 185 lines
func TestRenameRun(t *testing.T) {
	testCases := []struct {
		name        string
		opts        RenameOptions
		httpStubs   func(*httpmock.Registry)
		execStubs   func(*run.CommandStubber)
		promptStubs func(*prompter.MockPrompter)
		wantOut     string
		tty         bool
		wantErr     bool
		errMsg      string
	}{
		{
			name:    "none argument",
			wantOut: "✓ Renamed repository OWNER/NEW_REPO\n✓ Updated the \"origin\" remote\n",
			promptStubs: func(pm *prompter.MockPrompter) {
				pm.RegisterInput("Rename OWNER/REPO to:", func(_, _ string) (string, error) {
					return "NEW_REPO", nil
				})
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("PATCH", "repos/OWNER/REPO"),
					httpmock.StatusStringResponse(200, `{"name":"NEW_REPO","owner":{"login":"OWNER"}}`))
			},
			execStubs: func(cs *run.CommandStubber) {
				cs.Register(`git remote set-url origin https://github.com/OWNER/NEW_REPO.git`, 0, "")
			},
			tty: true,
		},
+ 155 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo rename
short: Rename a GitHub repository.
long: |-
    `<new-name>` is the desired repository name without the owner.

    By default, the current repository is renamed. Otherwise, the repository specified
    with `--repo` is renamed.

    To transfer repository ownership to another user account or organization,
    you must follow additional steps on `github.com`.
pname: gh repo
plink: gh_repo.yaml
DOCS
gh_repo_rename.md:31Markdown · 7 words
TESTS
pkg/cmd/repo/rename/rename_test.go:22pkg/cmd/repo/rename/rename_test::TestNewCmdRename · Go · 84 lines
func TestNewCmdRename(t *testing.T) {
	testCases := []struct {
		name    string
		input   string
		output  RenameOptions
		errMsg  string
		tty     bool
		wantErr bool
	}{
		{
			name:    "no arguments no tty",
			input:   "",
			errMsg:  "new name argument required when not running interactively",
			wantErr: true,
		},
		{
			name:  "one argument no tty confirmed",
			input: "REPO --yes",
			output: RenameOptions{
				newRepoSelector: "REPO",
			},
		},
		{
			name:    "one argument no tty",
			input:   "REPO",
			errMsg:  "--yes required when passing a single argument",
			wantErr: true,
		},
		{
			name:  "one argument tty confirmed",
+ 54 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo rename
short: Rename a GitHub repository.
long: |-
    `<new-name>` is the desired repository name without the owner.

    By default, the current repository is renamed. Otherwise, the repository specified
    with `--repo` is renamed.

    To transfer repository ownership to another user account or organization,
    you must follow additional steps on `github.com`.
pname: gh repo
plink: gh_repo.yaml
DOCS
gh_repo_rename.md:32Markdown · 4 words
TESTS
pkg/cmd/repo/rename/rename_test.go:22pkg/cmd/repo/rename/rename_test::TestNewCmdRename · Go · 84 lines
func TestNewCmdRename(t *testing.T) {
	testCases := []struct {
		name    string
		input   string
		output  RenameOptions
		errMsg  string
		tty     bool
		wantErr bool
	}{
		{
			name:    "no arguments no tty",
			input:   "",
			errMsg:  "new name argument required when not running interactively",
			wantErr: true,
		},
		{
			name:  "one argument no tty confirmed",
			input: "REPO --yes",
			output: RenameOptions{
				newRepoSelector: "REPO",
			},
		},
		{
			name:    "one argument no tty",
			input:   "REPO",
			errMsg:  "--yes required when passing a single argument",
			wantErr: true,
		},
		{
			name:  "one argument tty confirmed",
+ 54 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo set-default
short: This command sets the default remote repository to use when querying the
long: |-
    GitHub API for the locally cloned repository.

    gh uses the default repository for things like:

    - viewing and creating pull requests
    - viewing and creating issues
    - viewing and creating releases
    - working with GitHub Actions
DOCS
gh_repo_set-default.md:1Markdown · 72 words
TESTS
pkg/cmd/repo/setdefault/setdefault_test.go:20pkg/cmd/repo/setdefault/setdefault_test::TestNewCmdSetDefault · Go · 143 lines
func TestNewCmdSetDefault(t *testing.T) {
	tests := []struct {
		name     string
		gitStubs func(*run.CommandStubber)
		remotes  func() (context.Remotes, error)
		input    string
		output   SetDefaultOptions
		wantErr  bool
		errMsg   string
	}{
		{
			name: "no argument",
			gitStubs: func(cs *run.CommandStubber) {
				cs.Register(`git rev-parse --git-dir`, 0, ".git")
			},
			input:  "",
			output: SetDefaultOptions{},
		},
		{
			name: "repo argument",
			gitStubs: func(cs *run.CommandStubber) {
				cs.Register(`git rev-parse --git-dir`, 0, ".git")
			},
			input:  "cli/cli",
			output: SetDefaultOptions{Repo: ghrepo.New("cli", "cli")},
		},
		{
			name: "invalid repo argument",
			gitStubs: func(cs *run.CommandStubber) {
				cs.Register(`git rev-parse --git-dir`, 0, ".git")
+ 113 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh repo set-default
short: This command sets the default remote repository to use when querying the
long: |-
    GitHub API for the locally cloned repository.

    gh uses the default repository for things like:

    - viewing and creating pull requests
    - viewing and creating issues
    - viewing and creating releases
    - working with GitHub Actions
DOCS
gh_repo_set-default.md:29Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo set-default
short: This command sets the default remote repository to use when querying the
long: |-
    GitHub API for the locally cloned repository.

    gh uses the default repository for things like:

    - viewing and creating pull requests
    - viewing and creating issues
    - viewing and creating releases
    - working with GitHub Actions
DOCS
gh_repo_set-default.md:30Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo sync
short: Sync destination repository from source repository. Syncing uses the default branch
long: |-
    of the source repository to update the matching branch on the destination
    repository so they are equal. A fast forward update will be used except when the
    `--force` flag is specified, then the two branches will
    be synced using a hard reset.

    Without an argument, the local repository is selected as the destination repository.

    The source repository is the parent of the destination repository by default.
    This can be overridden with the `--source` flag.
TESTS
pkg/cmd/repo/sync/sync_test.go:19pkg/cmd/repo/sync/sync_test::TestNewCmdSync · Go · 83 lines
func TestNewCmdSync(t *testing.T) {
	tests := []struct {
		name    string
		tty     bool
		input   string
		output  SyncOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:   "no argument",
			tty:    true,
			input:  "",
			output: SyncOptions{},
		},
		{
			name:  "destination repo",
			tty:   true,
			input: "cli/cli",
			output: SyncOptions{
				DestArg: "cli/cli",
			},
		},
		{
			name:  "source repo",
			tty:   true,
			input: "--source cli/cli",
			output: SyncOptions{
				SrcArg: "cli/cli",
			},
+ 53 more lines · read full file
pkg/cmd/repo/sync/sync_test.go:103pkg/cmd/repo/sync/sync_test::Test_SyncRun · Go · 474 lines
func Test_SyncRun(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		opts       *SyncOptions
		remotes    []*context.Remote
		httpStubs  func(*httpmock.Registry)
		gitStubs   func(*mockGitClient)
		wantStdout string
		wantErr    bool
		errMsg     string
	}{
		{
			name: "sync local repo with parent - tty",
			tty:  true,
			opts: &SyncOptions{},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query RepositoryInfo\b`),
					httpmock.StringResponse(`{"data":{"repository":{"defaultBranchRef":{"name": "trunk"}}}}`))
			},
			gitStubs: func(mgc *mockGitClient) {
				mgc.On("Fetch", "origin", "refs/heads/trunk").Return(nil).Once()
				mgc.On("HasLocalBranch", "trunk").Return(true).Once()
				mgc.On("IsAncestor", "trunk", "FETCH_HEAD").Return(true, nil).Once()
				mgc.On("CurrentBranch").Return("trunk", nil).Once()
				mgc.On("IsDirty").Return(false, nil).Once()
				mgc.On("MergeFastForward", "FETCH_HEAD").Return(nil).Once()
			},
			wantStdout: "✓ Synced the \"trunk\" branch from \"OWNER/REPO\" to local repository\n",
+ 444 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo sync
short: Sync destination repository from source repository. Syncing uses the default branch
long: |-
    of the source repository to update the matching branch on the destination
    repository so they are equal. A fast forward update will be used except when the
    `--force` flag is specified, then the two branches will
    be synced using a hard reset.

    Without an argument, the local repository is selected as the destination repository.

    The source repository is the parent of the destination repository by default.
    This can be overridden with the `--source` flag.
DOCS
gh_repo_sync.md:29Markdown · 6 words
TESTS
pkg/cmd/repo/sync/sync_test.go:19pkg/cmd/repo/sync/sync_test::TestNewCmdSync · Go · 83 lines
func TestNewCmdSync(t *testing.T) {
	tests := []struct {
		name    string
		tty     bool
		input   string
		output  SyncOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:   "no argument",
			tty:    true,
			input:  "",
			output: SyncOptions{},
		},
		{
			name:  "destination repo",
			tty:   true,
			input: "cli/cli",
			output: SyncOptions{
				DestArg: "cli/cli",
			},
		},
		{
			name:  "source repo",
			tty:   true,
			input: "--source cli/cli",
			output: SyncOptions{
				SrcArg: "cli/cli",
			},
+ 53 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo sync
short: Sync destination repository from source repository. Syncing uses the default branch
long: |-
    of the source repository to update the matching branch on the destination
    repository so they are equal. A fast forward update will be used except when the
    `--force` flag is specified, then the two branches will
    be synced using a hard reset.

    Without an argument, the local repository is selected as the destination repository.

    The source repository is the parent of the destination repository by default.
    This can be overridden with the `--source` flag.
DOCS
gh_repo_sync.md:30Markdown · 13 words
TESTS
pkg/cmd/repo/sync/sync_test.go:19pkg/cmd/repo/sync/sync_test::TestNewCmdSync · Go · 83 lines
func TestNewCmdSync(t *testing.T) {
	tests := []struct {
		name    string
		tty     bool
		input   string
		output  SyncOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:   "no argument",
			tty:    true,
			input:  "",
			output: SyncOptions{},
		},
		{
			name:  "destination repo",
			tty:   true,
			input: "cli/cli",
			output: SyncOptions{
				DestArg: "cli/cli",
			},
		},
		{
			name:  "source repo",
			tty:   true,
			input: "--source cli/cli",
			output: SyncOptions{
				SrcArg: "cli/cli",
			},
+ 53 more lines · read full file
pkg/cmd/repo/sync/sync_test.go:103pkg/cmd/repo/sync/sync_test::Test_SyncRun · Go · 474 lines
func Test_SyncRun(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		opts       *SyncOptions
		remotes    []*context.Remote
		httpStubs  func(*httpmock.Registry)
		gitStubs   func(*mockGitClient)
		wantStdout string
		wantErr    bool
		errMsg     string
	}{
		{
			name: "sync local repo with parent - tty",
			tty:  true,
			opts: &SyncOptions{},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query RepositoryInfo\b`),
					httpmock.StringResponse(`{"data":{"repository":{"defaultBranchRef":{"name": "trunk"}}}}`))
			},
			gitStubs: func(mgc *mockGitClient) {
				mgc.On("Fetch", "origin", "refs/heads/trunk").Return(nil).Once()
				mgc.On("HasLocalBranch", "trunk").Return(true).Once()
				mgc.On("IsAncestor", "trunk", "FETCH_HEAD").Return(true, nil).Once()
				mgc.On("CurrentBranch").Return("trunk", nil).Once()
				mgc.On("IsDirty").Return(false, nil).Once()
				mgc.On("MergeFastForward", "FETCH_HEAD").Return(nil).Once()
			},
			wantStdout: "✓ Synced the \"trunk\" branch from \"OWNER/REPO\" to local repository\n",
+ 444 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo sync
short: Sync destination repository from source repository. Syncing uses the default branch
long: |-
    of the source repository to update the matching branch on the destination
    repository so they are equal. A fast forward update will be used except when the
    `--force` flag is specified, then the two branches will
    be synced using a hard reset.

    Without an argument, the local repository is selected as the destination repository.

    The source repository is the parent of the destination repository by default.
    This can be overridden with the `--source` flag.
DOCS
gh_repo_sync.md:31Markdown · 2 words
TESTS
pkg/cmd/repo/sync/sync_test.go:19pkg/cmd/repo/sync/sync_test::TestNewCmdSync · Go · 83 lines
func TestNewCmdSync(t *testing.T) {
	tests := []struct {
		name    string
		tty     bool
		input   string
		output  SyncOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:   "no argument",
			tty:    true,
			input:  "",
			output: SyncOptions{},
		},
		{
			name:  "destination repo",
			tty:   true,
			input: "cli/cli",
			output: SyncOptions{
				DestArg: "cli/cli",
			},
		},
		{
			name:  "source repo",
			tty:   true,
			input: "--source cli/cli",
			output: SyncOptions{
				SrcArg: "cli/cli",
			},
+ 53 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo unarchive
short: Unarchive a GitHub repository.
long: With no argument, unarchives the current repository.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: "yes"
      shorthand: "y"
      value_type: bool
      default_value: "false"
      description: Skip the confirmation prompt
DOCS
gh_repo_unarchive.md:1Markdown · 20 words
TESTS
pkg/cmd/repo/unarchive/unarchive_test.go:18pkg/cmd/repo/unarchive/unarchive_test::TestNewCmdUnarchive · Go · 49 lines
func TestNewCmdUnarchive(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		wantErr bool
		output  UnarchiveOptions
		errMsg  string
	}{
		{
			name:    "no arguments no tty",
			input:   "",
			errMsg:  "--yes required when not running interactively",
			wantErr: true,
		},
		{
			name:   "repo argument tty",
			input:  "OWNER/REPO --confirm",
			output: UnarchiveOptions{RepoArg: "OWNER/REPO", Confirmed: true},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			f := &cmdutil.Factory{
				IOStreams: ios,
			}
			argv, err := shlex.Split(tt.input)
			assert.NoError(t, err)
			var gotOpts *UnarchiveOptions
			cmd := NewCmdUnarchive(f, func(opts *UnarchiveOptions) error {
+ 19 more lines · read full file
pkg/cmd/repo/unarchive/unarchive_test.go:68pkg/cmd/repo/unarchive/unarchive_test::Test_UnarchiveRun · Go · 101 lines
func Test_UnarchiveRun(t *testing.T) {
	queryResponse := `{ "data": { "repository": { "id": "THE-ID","isArchived": %s} } }`
	tests := []struct {
		name          string
		opts          UnarchiveOptions
		httpStubs     func(*httpmock.Registry)
		prompterStubs func(*prompter.PrompterMock)
		isTTY         bool
		wantStdout    string
		wantStderr    string
	}{
		{
			name:       "archived repo tty",
			wantStdout: "✓ Unarchived repository OWNER/REPO\n",
			prompterStubs: func(pm *prompter.PrompterMock) {
				pm.ConfirmFunc = func(p string, d bool) (bool, error) {
					if p == "Unarchive OWNER/REPO?" {
						return true, nil
					}
					return false, prompter.NoSuchPromptErr(p)
				}
			},
			isTTY: true,
			opts:  UnarchiveOptions{RepoArg: "OWNER/REPO"},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query RepositoryInfo\b`),
					httpmock.StringResponse(fmt.Sprintf(queryResponse, "true")))
				reg.Register(
					httpmock.GraphQL(`mutation UnarchiveRepository\b`),
+ 71 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo unarchive
short: Unarchive a GitHub repository.
long: With no argument, unarchives the current repository.
pname: gh repo
plink: gh_repo.yaml
options:
    - option: "yes"
      shorthand: "y"
      value_type: bool
      default_value: "false"
      description: Skip the confirmation prompt
DOCS
gh_repo_unarchive.md:21Markdown · 4 words
TESTS
pkg/cmd/repo/unarchive/unarchive_test.go:18pkg/cmd/repo/unarchive/unarchive_test::TestNewCmdUnarchive · Go · 49 lines
func TestNewCmdUnarchive(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		wantErr bool
		output  UnarchiveOptions
		errMsg  string
	}{
		{
			name:    "no arguments no tty",
			input:   "",
			errMsg:  "--yes required when not running interactively",
			wantErr: true,
		},
		{
			name:   "repo argument tty",
			input:  "OWNER/REPO --confirm",
			output: UnarchiveOptions{RepoArg: "OWNER/REPO", Confirmed: true},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ios, _, _, _ := iostreams.Test()
			f := &cmdutil.Factory{
				IOStreams: ios,
			}
			argv, err := shlex.Split(tt.input)
			assert.NoError(t, err)
			var gotOpts *UnarchiveOptions
			cmd := NewCmdUnarchive(f, func(opts *UnarchiveOptions) error {
+ 19 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo view
short: Display the description and the README of a GitHub repository.
long: |-
    With no argument, the repository for the current directory is displayed.

    With `--web`, open the repository in a web browser instead.

    With `--branch`, view a specific branch of the repository.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
DOCS
gh_repo_view.md:1Markdown · 118 words
TESTS
pkg/cmd/repo/autolink/view/view_test.go:20pkg/cmd/repo/autolink/view/view_test::TestJSONFields · Go · 8 lines
func TestJSONFields(t *testing.T) {
	jsonfieldstest.ExpectCommandToSupportJSONFields(t, NewCmdView, []string{
		"id",
		"isAlphanumeric",
		"keyPrefix",
		"urlTemplate",
	})
}
pkg/cmd/repo/autolink/view/view_test.go:29pkg/cmd/repo/autolink/view/view_test::TestNewCmdView · Go · 69 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name         string
		input        string
		output       viewOptions
		wantErr      bool
		wantExporter bool
		errMsg       string
	}{
		{
			name:    "no argument",
			input:   "",
			wantErr: true,
			errMsg:  "accepts 1 arg(s), received 0",
		},
		{
			name:   "id provided",
			input:  "123",
			output: viewOptions{ID: "123"},
		},
		{
			name:         "json flag",
			input:        "123 --json id",
			output:       viewOptions{ID: "123"},
			wantExporter: true,
		},
		{
			name:    "invalid json flag",
			input:   "123 --json invalid",
			wantErr: true,
+ 39 more lines · read full file
pkg/cmd/repo/autolink/view/view_test.go:114pkg/cmd/repo/autolink/view/view_test::TestViewRun · Go · 84 lines
func TestViewRun(t *testing.T) {
	tests := []struct {
		name        string
		opts        *viewOptions
		stubViewer  stubAutolinkViewer
		expectedErr error
		wantStdout  string
	}{
		{
			name: "view",
			opts: &viewOptions{
				ID: "1",
			},
			stubViewer: stubAutolinkViewer{
				autolink: &shared.Autolink{
					ID:             1,
					KeyPrefix:      "TICKET-",
					URLTemplate:    "https://example.com/TICKET?query=<num>",
					IsAlphanumeric: true,
				},
			},
			wantStdout: heredoc.Doc(`
				Autolink in OWNER/REPO

				ID: 1
				Key Prefix: TICKET-
				URL Template: https://example.com/TICKET?query=<num>
				Alphanumeric: true
			`),
		},
+ 54 more lines · read full file
+ 14 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh repo view
short: Display the description and the README of a GitHub repository.
long: |-
    With no argument, the repository for the current directory is displayed.

    With `--web`, open the repository in a web browser instead.

    With `--branch`, view a specific branch of the repository.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
DOCS
gh_repo_view.md:26Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo view
short: Display the description and the README of a GitHub repository.
long: |-
    With no argument, the repository for the current directory is displayed.

    With `--web`, open the repository in a web browser instead.

    With `--branch`, view a specific branch of the repository.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
DOCS
gh_repo_view.md:27Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo view
short: Display the description and the README of a GitHub repository.
long: |-
    With no argument, the repository for the current directory is displayed.

    With `--web`, open the repository in a web browser instead.

    With `--branch`, view a specific branch of the repository.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
DOCS
gh_repo_view.md:28Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo view
short: Display the description and the README of a GitHub repository.
long: |-
    With no argument, the repository for the current directory is displayed.

    With `--web`, open the repository in a web browser instead.

    With `--branch`, view a specific branch of the repository.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
DOCS
gh_repo_view.md:29Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh repo view
short: Display the description and the README of a GitHub repository.
long: |-
    With no argument, the repository for the current directory is displayed.

    With `--web`, open the repository in a web browser instead.

    With `--branch`, view a specific branch of the repository.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh repo
plink: gh_repo.yaml
DOCS
gh_repo_view.md:30Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh ruleset
short: Repository rulesets are a way to define a set of rules that apply to a repository.
long: These commands allow you to view information about them.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_ruleset.md:1Markdown · 50 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh ruleset
short: Repository rulesets are a way to define a set of rules that apply to a repository.
long: These commands allow you to view information about them.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_ruleset.md:24Markdown · 7 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh ruleset check
short: View information about GitHub rules that apply to a given branch.
long: |-
    The provided branch name does not need to exist; rules will be displayed that would apply
    to a branch with that name. All rules are returned regardless of where they are configured.

    If no branch name is provided, then the current branch will be used.

    The `--default` flag can be used to view rules that apply to the default branch of the
    repository.
pname: gh ruleset
plink: gh_ruleset.yaml
DOCS
gh_ruleset_check.md:1Markdown · 89 words
TESTS
pkg/cmd/ruleset/check/check_test.go:20pkg/cmd/ruleset/check/check_test::Test_NewCmdCheck · Go · 96 lines
func Test_NewCmdCheck(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    CheckOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: CheckOptions{
				Branch:  "",
				Default: false,
				WebMode: false,
			},
		},
		{
			name:  "branch name",
			args:  "my-branch",
			isTTY: true,
			want: CheckOptions{
				Branch:  "my-branch",
				Default: false,
				WebMode: false,
			},
		},
		{
			name:  "default",
+ 66 more lines · read full file
pkg/cmd/ruleset/check/check_test.go:117pkg/cmd/ruleset/check/check_test::Test_checkRun · Go · 117 lines
func Test_checkRun(t *testing.T) {
	tests := []struct {
		name       string
		isTTY      bool
		opts       CheckOptions
		wantErr    string
		wantStdout string
		wantStderr string
		wantBrowse string
	}{
		{
			name:  "view rules for branch",
			isTTY: true,
			opts: CheckOptions{
				Branch: "my-branch",
			},
			wantStdout: heredoc.Doc(`
			6 rules apply to branch my-branch in repo my-org/repo-name

			- commit_author_email_pattern: [name: ] [negate: false] [operator: ends_with] [pattern: @example.com] 
			  (configured in ruleset 1234 from organization my-org)

			- commit_author_email_pattern: [name: ] [negate: false] [operator: ends_with] [pattern: @example.com] 
			  (configured in ruleset 5678 from repository my-org/repo-name)

			- commit_message_pattern: [name: ] [negate: false] [operator: starts_with] [pattern: fff] 
			  (configured in ruleset 1234 from organization my-org)

			- commit_message_pattern: [name: ] [negate: false] [operator: contains] [pattern: asdf] 
			  (configured in ruleset 5678 from repository my-org/repo-name)
+ 87 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh ruleset check
short: View information about GitHub rules that apply to a given branch.
long: |-
    The provided branch name does not need to exist; rules will be displayed that would apply
    to a branch with that name. All rules are returned regardless of where they are configured.

    If no branch name is provided, then the current branch will be used.

    The `--default` flag can be used to view rules that apply to the default branch of the
    repository.
pname: gh ruleset
plink: gh_ruleset.yaml
DOCS
gh_ruleset_check.md:28Markdown · 5 words
TESTS
pkg/cmd/ruleset/check/check_test.go:20pkg/cmd/ruleset/check/check_test::Test_NewCmdCheck · Go · 96 lines
func Test_NewCmdCheck(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    CheckOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: CheckOptions{
				Branch:  "",
				Default: false,
				WebMode: false,
			},
		},
		{
			name:  "branch name",
			args:  "my-branch",
			isTTY: true,
			want: CheckOptions{
				Branch:  "my-branch",
				Default: false,
				WebMode: false,
			},
		},
		{
			name:  "default",
+ 66 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh ruleset check
short: View information about GitHub rules that apply to a given branch.
long: |-
    The provided branch name does not need to exist; rules will be displayed that would apply
    to a branch with that name. All rules are returned regardless of where they are configured.

    If no branch name is provided, then the current branch will be used.

    The `--default` flag can be used to view rules that apply to the default branch of the
    repository.
pname: gh ruleset
plink: gh_ruleset.yaml
DOCS
gh_ruleset_check.md:29Markdown · 9 words
TESTS
pkg/cmd/ruleset/check/check_test.go:20pkg/cmd/ruleset/check/check_test::Test_NewCmdCheck · Go · 96 lines
func Test_NewCmdCheck(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    CheckOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: CheckOptions{
				Branch:  "",
				Default: false,
				WebMode: false,
			},
		},
		{
			name:  "branch name",
			args:  "my-branch",
			isTTY: true,
			want: CheckOptions{
				Branch:  "my-branch",
				Default: false,
				WebMode: false,
			},
		},
		{
			name:  "default",
+ 66 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh ruleset list
short: List GitHub rulesets for a repository or organization.
long: |-
    If no options are provided, the current repository's rulesets are listed. You can query a different
    repository's rulesets by using the `--repo` flag. You can also use the `--org` flag to list rulesets
    configured for the provided organization.

    Use the `--parents` flag to control whether rulesets configured at higher levels that also apply to the provided
    repository or organization should be returned. The default is `true`.

    Your access token must have the `admin:org` scope to use the `--org` flag, which can be granted by running `gh auth refresh -s admin:org`.
pname: gh ruleset
DOCS
gh_ruleset_list.md:1Markdown · 120 words
TESTS
pkg/cmd/ruleset/list/list_test.go:21pkg/cmd/ruleset/list/list_test::Test_NewCmdList · Go · 117 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ListOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ListOptions{
				Limit:          30,
				IncludeParents: true,
				WebMode:        false,
				Organization:   "",
			},
		},
		{
			name:  "limit",
			args:  "--limit 1",
			isTTY: true,
			want: ListOptions{
				Limit:          1,
				IncludeParents: true,
				WebMode:        false,
				Organization:   "",
			},
		},
+ 87 more lines · read full file
pkg/cmd/ruleset/list/list_test.go:139pkg/cmd/ruleset/list/list_test::Test_listRun · Go · 204 lines
func Test_listRun(t *testing.T) {
	tests := []struct {
		name       string
		isTTY      bool
		opts       ListOptions
		httpStubs  func(*httpmock.Registry)
		wantErr    string
		wantStdout string
		wantStderr string
		wantBrowse string
	}{
		{
			name:  "list repo rulesets",
			isTTY: true,
			wantStdout: heredoc.Doc(`

				Showing 3 of 3 rulesets in OWNER/REPO

				ID  NAME    SOURCE             STATUS    RULES
				4   test    OWNER/REPO (repo)  evaluate  1
				42  asdf    OWNER/REPO (repo)  active    2
				77  foobar  Org-Name (org)     disabled  4
			`),
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.GraphQL(`query RepoRulesetList\b`),
					httpmock.FileResponse("./fixtures/rulesetList.json"),
				)
			},
			wantStderr: "",
+ 174 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh ruleset list
short: List GitHub rulesets for a repository or organization.
long: |-
    If no options are provided, the current repository's rulesets are listed. You can query a different
    repository's rulesets by using the `--repo` flag. You can also use the `--org` flag to list rulesets
    configured for the provided organization.

    Use the `--parents` flag to control whether rulesets configured at higher levels that also apply to the provided
    repository or organization should be returned. The default is `true`.

    Your access token must have the `admin:org` scope to use the `--org` flag, which can be granted by running `gh auth refresh -s admin:org`.
pname: gh ruleset
DOCS
gh_ruleset_list.md:29Markdown · 6 words
TESTS
pkg/cmd/ruleset/list/list_test.go:21pkg/cmd/ruleset/list/list_test::Test_NewCmdList · Go · 117 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ListOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ListOptions{
				Limit:          30,
				IncludeParents: true,
				WebMode:        false,
				Organization:   "",
			},
		},
		{
			name:  "limit",
			args:  "--limit 1",
			isTTY: true,
			want: ListOptions{
				Limit:          1,
				IncludeParents: true,
				WebMode:        false,
				Organization:   "",
			},
		},
+ 87 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh ruleset list
short: List GitHub rulesets for a repository or organization.
long: |-
    If no options are provided, the current repository's rulesets are listed. You can query a different
    repository's rulesets by using the `--repo` flag. You can also use the `--org` flag to list rulesets
    configured for the provided organization.

    Use the `--parents` flag to control whether rulesets configured at higher levels that also apply to the provided
    repository or organization should be returned. The default is `true`.

    Your access token must have the `admin:org` scope to use the `--org` flag, which can be granted by running `gh auth refresh -s admin:org`.
pname: gh ruleset
DOCS
gh_ruleset_list.md:30Markdown · 7 words
TESTS
pkg/cmd/ruleset/list/list_test.go:21pkg/cmd/ruleset/list/list_test::Test_NewCmdList · Go · 117 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ListOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ListOptions{
				Limit:          30,
				IncludeParents: true,
				WebMode:        false,
				Organization:   "",
			},
		},
		{
			name:  "limit",
			args:  "--limit 1",
			isTTY: true,
			want: ListOptions{
				Limit:          1,
				IncludeParents: true,
				WebMode:        false,
				Organization:   "",
			},
		},
+ 87 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh ruleset list
short: List GitHub rulesets for a repository or organization.
long: |-
    If no options are provided, the current repository's rulesets are listed. You can query a different
    repository's rulesets by using the `--repo` flag. You can also use the `--org` flag to list rulesets
    configured for the provided organization.

    Use the `--parents` flag to control whether rulesets configured at higher levels that also apply to the provided
    repository or organization should be returned. The default is `true`.

    Your access token must have the `admin:org` scope to use the `--org` flag, which can be granted by running `gh auth refresh -s admin:org`.
pname: gh ruleset
DOCS
gh_ruleset_list.md:31Markdown · 11 words
TESTS
pkg/cmd/ruleset/list/list_test.go:21pkg/cmd/ruleset/list/list_test::Test_NewCmdList · Go · 117 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ListOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ListOptions{
				Limit:          30,
				IncludeParents: true,
				WebMode:        false,
				Organization:   "",
			},
		},
		{
			name:  "limit",
			args:  "--limit 1",
			isTTY: true,
			want: ListOptions{
				Limit:          1,
				IncludeParents: true,
				WebMode:        false,
				Organization:   "",
			},
		},
+ 87 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh ruleset list
short: List GitHub rulesets for a repository or organization.
long: |-
    If no options are provided, the current repository's rulesets are listed. You can query a different
    repository's rulesets by using the `--repo` flag. You can also use the `--org` flag to list rulesets
    configured for the provided organization.

    Use the `--parents` flag to control whether rulesets configured at higher levels that also apply to the provided
    repository or organization should be returned. The default is `true`.

    Your access token must have the `admin:org` scope to use the `--org` flag, which can be granted by running `gh auth refresh -s admin:org`.
pname: gh ruleset
DOCS
gh_ruleset_list.md:32Markdown · 9 words
TESTS
pkg/cmd/ruleset/list/list_test.go:21pkg/cmd/ruleset/list/list_test::Test_NewCmdList · Go · 117 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ListOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ListOptions{
				Limit:          30,
				IncludeParents: true,
				WebMode:        false,
				Organization:   "",
			},
		},
		{
			name:  "limit",
			args:  "--limit 1",
			isTTY: true,
			want: ListOptions{
				Limit:          1,
				IncludeParents: true,
				WebMode:        false,
				Organization:   "",
			},
		},
+ 87 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh ruleset view
short: View information about a GitHub ruleset.
long: |-
    If no ID is provided, an interactive prompt will be used to choose
    the ruleset to view.

    Use the `--parents` flag to control whether rulesets configured at higher
    levels that also apply to the provided repository or organization should
    be returned. The default is `true`.
pname: gh ruleset
plink: gh_ruleset.yaml
options:
DOCS
gh_ruleset_view.md:1Markdown · 66 words
TESTS
pkg/cmd/ruleset/view/view_test.go:22pkg/cmd/ruleset/view/view_test::Test_NewCmdView · Go · 130 lines
func Test_NewCmdView(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ViewOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ViewOptions{
				ID:              "",
				WebMode:         false,
				IncludeParents:  true,
				InteractiveMode: true,
				Organization:    "",
			},
		},
		{
			name:  "only ID",
			args:  "3",
			isTTY: true,
			want: ViewOptions{
				ID:              "3",
				WebMode:         false,
				IncludeParents:  true,
				InteractiveMode: false,
				Organization:    "",
+ 100 more lines · read full file
pkg/cmd/ruleset/view/view_test.go:153pkg/cmd/ruleset/view/view_test::Test_viewRun · Go · 261 lines
func Test_viewRun(t *testing.T) {
	repoRulesetStdout := heredoc.Doc(`

	Test Ruleset
	ID: 42
	Source: my-owner/repo-name (Repository)
	Enforcement: Active
	You can bypass: pull requests only

	Bypass List
	- OrganizationAdmin (ID: 1), mode: always
	- RepositoryRole (ID: 5), mode: always

	Conditions
	- ref_name: [exclude: []] [include: [~ALL]] 

	Rules
	- commit_author_email_pattern: [name: ] [negate: false] [operator: ends_with] [pattern: @example.com] 
	- commit_message_pattern: [name: ] [negate: false] [operator: contains] [pattern: asdf] 
	- creation
	`)

	tests := []struct {
		name          string
		isTTY         bool
		opts          ViewOptions
		httpStubs     func(*httpmock.Registry)
		prompterStubs func(*prompter.MockPrompter)
		wantErr       string
		wantStdout    string
+ 231 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh ruleset view
short: View information about a GitHub ruleset.
long: |-
    If no ID is provided, an interactive prompt will be used to choose
    the ruleset to view.

    Use the `--parents` flag to control whether rulesets configured at higher
    levels that also apply to the provided repository or organization should
    be returned. The default is `true`.
pname: gh ruleset
plink: gh_ruleset.yaml
options:
DOCS
gh_ruleset_view.md:27Markdown · 10 words
TESTS
pkg/cmd/ruleset/view/view_test.go:22pkg/cmd/ruleset/view/view_test::Test_NewCmdView · Go · 130 lines
func Test_NewCmdView(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ViewOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ViewOptions{
				ID:              "",
				WebMode:         false,
				IncludeParents:  true,
				InteractiveMode: true,
				Organization:    "",
			},
		},
		{
			name:  "only ID",
			args:  "3",
			isTTY: true,
			want: ViewOptions{
				ID:              "3",
				WebMode:         false,
				IncludeParents:  true,
				InteractiveMode: false,
				Organization:    "",
+ 100 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh ruleset view
short: View information about a GitHub ruleset.
long: |-
    If no ID is provided, an interactive prompt will be used to choose
    the ruleset to view.

    Use the `--parents` flag to control whether rulesets configured at higher
    levels that also apply to the provided repository or organization should
    be returned. The default is `true`.
pname: gh ruleset
plink: gh_ruleset.yaml
options:
DOCS
gh_ruleset_view.md:28Markdown · 11 words
TESTS
pkg/cmd/ruleset/view/view_test.go:22pkg/cmd/ruleset/view/view_test::Test_NewCmdView · Go · 130 lines
func Test_NewCmdView(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ViewOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ViewOptions{
				ID:              "",
				WebMode:         false,
				IncludeParents:  true,
				InteractiveMode: true,
				Organization:    "",
			},
		},
		{
			name:  "only ID",
			args:  "3",
			isTTY: true,
			want: ViewOptions{
				ID:              "3",
				WebMode:         false,
				IncludeParents:  true,
				InteractiveMode: false,
				Organization:    "",
+ 100 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh ruleset view
short: View information about a GitHub ruleset.
long: |-
    If no ID is provided, an interactive prompt will be used to choose
    the ruleset to view.

    Use the `--parents` flag to control whether rulesets configured at higher
    levels that also apply to the provided repository or organization should
    be returned. The default is `true`.
pname: gh ruleset
plink: gh_ruleset.yaml
options:
DOCS
gh_ruleset_view.md:29Markdown · 6 words
TESTS
pkg/cmd/ruleset/view/view_test.go:22pkg/cmd/ruleset/view/view_test::Test_NewCmdView · Go · 130 lines
func Test_NewCmdView(t *testing.T) {
	tests := []struct {
		name    string
		args    string
		isTTY   bool
		want    ViewOptions
		wantErr string
	}{
		{
			name:  "no arguments",
			args:  "",
			isTTY: true,
			want: ViewOptions{
				ID:              "",
				WebMode:         false,
				IncludeParents:  true,
				InteractiveMode: true,
				Organization:    "",
			},
		},
		{
			name:  "only ID",
			args:  "3",
			isTTY: true,
			want: ViewOptions{
				ID:              "3",
				WebMode:         false,
				IncludeParents:  true,
				InteractiveMode: false,
				Organization:    "",
+ 100 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run
short: List, view, and watch recent workflow runs from GitHub Actions.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
TESTS
pkg/cmd/workflow/run/run_test.go:26pkg/cmd/workflow/run/run_test::TestNewCmdRun · Go · 126 lines
func TestNewCmdRun(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    RunOptions
		wantsErr bool
		errMsg   string
		stdin    string
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
			errMsg:   "workflow ID, name, or filename required when not running interactively",
		},
		{
			name: "blank tty",
			tty:  true,
			wants: RunOptions{
				Prompt: true,
			},
		},
		{
			name: "ref flag",
			tty:  true,
			cli:  "--ref 12345abc",
			wants: RunOptions{
				Prompt: true,
				Ref:    "12345abc",
			},
+ 96 more lines · read full file
pkg/cmd/workflow/run/run_test.go:153pkg/cmd/workflow/run/run_test::Test_magicFieldValue · Go · 60 lines
func Test_magicFieldValue(t *testing.T) {
	f, err := os.CreateTemp(t.TempDir(), "gh-test")
	if err != nil {
		t.Fatal(err)
	}
	defer f.Close()

	fmt.Fprint(f, "file contents")

	ios, _, _, _ := iostreams.Test()

	type args struct {
		v    string
		opts RunOptions
	}
	tests := []struct {
		name    string
		args    args
		want    interface{}
		wantErr bool
	}{
		{
			name:    "string",
			args:    args{v: "hello"},
			want:    "hello",
			wantErr: false,
		},
		{
			name: "file",
			args: args{
+ 30 more lines · read full file
pkg/cmd/workflow/run/run_test.go:214pkg/cmd/workflow/run/run_test::Test_findInputs · Go · 106 lines
func Test_findInputs(t *testing.T) {
	tests := []struct {
		name    string
		YAML    []byte
		wantErr bool
		errMsg  string
		wantOut []WorkflowInput
	}{
		{
			name:    "blank",
			YAML:    []byte{},
			wantErr: true,
			errMsg:  "invalid YAML file",
		},
		{
			name:    "no event specified",
			YAML:    []byte("name: workflow"),
			wantErr: true,
			errMsg:  "invalid workflow: no 'on' key",
		},
		{
			name:    "not workflow_dispatch",
			YAML:    []byte("name: workflow\non: pull_request"),
			wantErr: true,
			errMsg:  "unable to manually run a workflow without a workflow_dispatch event",
		},
		{
			name:    "bad inputs",
			YAML:    []byte("name: workflow\non:\n workflow_dispatch:\n  inputs: lol  "),
			wantErr: true,
+ 76 more lines · read full file
+ 1 more tests · open all in source
EXAMPLES

N/A

CONTRACT
command: gh run
short: List, view, and watch recent workflow runs from GitHub Actions.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_run.md:26Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run cancel
short: Cancel a workflow run
pname: gh run
plink: gh_run.yaml
options:
    - option: force
      value_type: bool
      default_value: "false"
      description: Force cancel a workflow run
DOCS
gh_run_cancel.md:1Markdown · 18 words
TESTS
pkg/cmd/run/cancel/cancel_test.go:20pkg/cmd/run/cancel/cancel_test::TestNewCmdCancel · Go · 74 lines
func TestNewCmdCancel(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    CancelOptions
		wantsErr bool
	}{
		{
			name: "blank tty",
			tty:  true,
			wants: CancelOptions{
				Prompt: true,
			},
		},
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "with arg",
			cli:  "1234",
			wants: CancelOptions{
				RunID: "1234",
				Force: false,
			},
		},
		{
			name: "with arg and force flag",
			cli:  "1234 --force",
+ 44 more lines · read full file
pkg/cmd/run/cancel/cancel_test.go:95pkg/cmd/run/cancel/cancel_test::TestRunCancel · Go · 210 lines
func TestRunCancel(t *testing.T) {
	inProgressRun := shared.TestRun(1234, shared.InProgress, "")
	completedRun := shared.TestRun(4567, shared.Completed, shared.Failure)
	tests := []struct {
		name        string
		httpStubs   func(*httpmock.Registry)
		promptStubs func(*prompter.MockPrompter)
		opts        *CancelOptions
		wantErr     bool
		wantOut     string
		errMsg      string
	}{
		{
			name: "cancel run",
			opts: &CancelOptions{
				RunID: "1234",
			},
			wantErr: false,
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/1234"),
					httpmock.JSONResponse(inProgressRun))
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/123"),
					httpmock.JSONResponse(shared.TestWorkflow))
				reg.Register(
					httpmock.REST("POST", "repos/OWNER/REPO/actions/runs/1234/cancel"),
					httpmock.StatusStringResponse(202, "{}"))
			},
			wantOut: "✓ Request to cancel workflow 1234 submitted.\n",
+ 180 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh run cancel
short: Cancel a workflow run
pname: gh run
plink: gh_run.yaml
options:
    - option: force
      value_type: bool
      default_value: "false"
      description: Force cancel a workflow run
DOCS
gh_run_cancel.md:19Markdown · 5 words
TESTS
pkg/cmd/run/cancel/cancel_test.go:20pkg/cmd/run/cancel/cancel_test::TestNewCmdCancel · Go · 74 lines
func TestNewCmdCancel(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    CancelOptions
		wantsErr bool
	}{
		{
			name: "blank tty",
			tty:  true,
			wants: CancelOptions{
				Prompt: true,
			},
		},
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "with arg",
			cli:  "1234",
			wants: CancelOptions{
				RunID: "1234",
				Force: false,
			},
		},
		{
			name: "with arg and force flag",
			cli:  "1234 --force",
+ 44 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run delete
short: Delete a workflow run
pname: gh run
plink: gh_run.yaml
DOCS
gh_run_delete.md:1Markdown · 18 words
TESTS
pkg/cmd/alias/delete/delete_test.go:87pkg/cmd/alias/delete/delete_test::TestDeleteRun · Go · 102 lines
func TestDeleteRun(t *testing.T) {
	tests := []struct {
		name        string
		config      string
		isTTY       bool
		opts        *DeleteOptions
		wantAliases map[string]string
		wantStdout  string
		wantStderr  string
		wantErrMsg  string
	}{
		{
			name: "delete alias",
			config: heredoc.Doc(`
				aliases:
				  il: issue list
				  co: pr checkout
			`),
			isTTY: true,
			opts: &DeleteOptions{
				Name: "co",
				All:  false,
			},
			wantAliases: map[string]string{
				"il": "issue list",
			},
			wantStderr: "✓ Deleted alias co; was pr checkout\n",
		},
		{
			name: "delete all aliases",
+ 72 more lines · read full file
pkg/cmd/cache/delete/delete_test.go:122pkg/cmd/cache/delete/delete_test::TestDeleteRun · Go · 367 lines
func TestDeleteRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       DeleteOptions
		stubs      func(*httpmock.Registry)
		tty        bool
		wantErr    bool
		wantErrMsg string
		wantStderr string
		wantStdout string
	}{
		{
			name: "deletes cache tty",
			opts: DeleteOptions{Identifier: "123"},
			stubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("DELETE", "repos/OWNER/REPO/actions/caches/123"),
					httpmock.StatusStringResponse(204, ""),
				)
			},
			tty:        true,
			wantStdout: "✓ Deleted 1 cache from OWNER/REPO\n",
		},
		{
			name: "deletes cache notty",
			opts: DeleteOptions{Identifier: "123"},
			stubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("DELETE", "repos/OWNER/REPO/actions/caches/123"),
					httpmock.StatusStringResponse(204, ""),
+ 337 more lines · read full file
pkg/cmd/gist/delete/delete_test.go:121pkg/cmd/gist/delete/delete_test::Test_deleteRun · Go · 207 lines
func Test_deleteRun(t *testing.T) {
	tests := []struct {
		name            string
		opts            *DeleteOptions
		cancel          bool
		httpStubs       func(*httpmock.Registry)
		mockPromptGists bool
		noGists         bool
		wantErr         bool
		wantStdout      string
		wantStderr      string
	}{
		{
			name: "successfully delete",
			opts: &DeleteOptions{
				Selector: "1234",
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.REST("GET", "gists/1234"),
					httpmock.JSONResponse(shared.Gist{ID: "1234", Files: map[string]*shared.GistFile{"cool.txt": {Filename: "cool.txt"}}}))
				reg.Register(httpmock.REST("DELETE", "gists/1234"),
					httpmock.StatusStringResponse(200, "{}"))
			},
			wantStdout: "✓ Gist \"cool.txt\" deleted\n",
		},
		{
			name: "successfully delete with prompt",
			opts: &DeleteOptions{
				Selector: "",
			},
+ 177 more lines · read full file
+ 18 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh run download
short: Download artifacts generated by a GitHub Actions workflow run.
long: |-
    The contents of each artifact will be extracted under separate directories based on
    the artifact name. If only a single artifact is specified, it will be extracted into
    the current directory.

    By default, this command downloads the latest artifact created and uploaded through
    GitHub Actions. Because workflows can delete or overwrite artifacts, `<run-id>`
    must be used to select an artifact from a specific workflow run.
pname: gh run
plink: gh_run.yaml
TESTS
pkg/cmd/attestation/download/download_test.go:191pkg/cmd/attestation/download/download_test::TestRunDownload · Go · 138 lines
func TestRunDownload(t *testing.T) {
	tempDir := t.TempDir()
	store := &LiveStore{
		outputPath: tempDir,
	}

	baseOpts := Options{
		ArtifactPath:    artifactPath,
		APIClient:       api.NewTestClient(),
		OCIClient:       oci.MockClient{},
		DigestAlgorithm: "sha512",
		Owner:           "sigstore",
		Store:           store,
		Limit:           30,
		Logger:          io.NewTestHandler(),
	}

	t.Run("fetch and store attestations successfully with owner", func(t *testing.T) {
		err := runDownload(&baseOpts)
		require.NoError(t, err)

		artifact, err := artifact.NewDigestedArtifact(baseOpts.OCIClient, baseOpts.ArtifactPath, baseOpts.DigestAlgorithm)
		require.NoError(t, err)

		expectedFilePath := expectedFilePath(tempDir, artifact.DigestWithAlg())
		require.FileExists(t, expectedFilePath)

		actualLineCount, err := countLines(expectedFilePath)
		require.NoError(t, err)
+ 109 more lines · read full file
pkg/cmd/release/download/download_test.go:176pkg/cmd/release/download/download_test::Test_downloadRun · Go · 399 lines
func Test_downloadRun(t *testing.T) {
	tests := []struct {
		name       string
		isTTY      bool
		opts       DownloadOptions
		httpStubs  func(*httpmock.Registry)
		wantErr    string
		wantStdout string
		wantStderr string
		wantFiles  []string
	}{
		{
			name:  "download all assets",
			isTTY: true,
			opts: DownloadOptions{
				TagName:     "v1.2.3",
				Destination: ".",
				Concurrency: 2,
			},
			httpStubs: func(reg *httpmock.Registry) {
				shared.StubFetchRelease(t, reg, "OWNER", "REPO", "v1.2.3", `{
					"assets": [
						{ "name": "windows-32bit.zip", "size": 12,
						"url": "https://api.github.com/assets/1234" },
						{ "name": "windows-64bit.zip", "size": 34,
						"url": "https://api.github.com/assets/3456" },
						{ "name": "linux.tgz", "size": 56,
						"url": "https://api.github.com/assets/5678" }
					],
					"tarball_url": "https://api.github.com/repos/OWNER/REPO/tarball/v1.2.3",
+ 369 more lines · read full file
pkg/cmd/release/download/download_test.go:576pkg/cmd/release/download/download_test::Test_downloadRun_cloberAndSkip · Go · 155 lines
func Test_downloadRun_cloberAndSkip(t *testing.T) {
	oldAssetContents := "older copy to be clobbered"
	oldZipballContents := "older zipball to be clobbered"
	// this should be shorter than oldAssetContents and oldZipballContents
	newContents := "somedata"

	tests := []struct {
		name            string
		opts            DownloadOptions
		httpStubs       func(*httpmock.Registry)
		wantErr         string
		wantFileSize    int64
		wantArchiveSize int64
	}{
		{
			name: "no clobber or skip",
			opts: DownloadOptions{
				TagName:      "v1.2.3",
				FilePatterns: []string{"windows-64bit.zip"},
				Destination:  "tmp/packages",
				Concurrency:  2,
			},
			wantErr:         "already exists (use `--clobber` to overwrite file or `--skip-existing` to skip file)",
			wantFileSize:    int64(len(oldAssetContents)),
			wantArchiveSize: int64(len(oldZipballContents)),
		},
		{
			name: "clobber",
			opts: DownloadOptions{
				TagName:           "v1.2.3",
+ 125 more lines · read full file
+ 3 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh run download
short: Download artifacts generated by a GitHub Actions workflow run.
long: |-
    The contents of each artifact will be extracted under separate directories based on
    the artifact name. If only a single artifact is specified, it will be extracted into
    the current directory.

    By default, this command downloads the latest artifact created and uploaded through
    GitHub Actions. Because workflows can delete or overwrite artifacts, `<run-id>`
    must be used to select an artifact from a specific workflow run.
pname: gh run
plink: gh_run.yaml
DOCS
gh_run_download.md:28Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run download
short: Download artifacts generated by a GitHub Actions workflow run.
long: |-
    The contents of each artifact will be extracted under separate directories based on
    the artifact name. If only a single artifact is specified, it will be extracted into
    the current directory.

    By default, this command downloads the latest artifact created and uploaded through
    GitHub Actions. Because workflows can delete or overwrite artifacts, `<run-id>`
    must be used to select an artifact from a specific workflow run.
pname: gh run
plink: gh_run.yaml
DOCS
gh_run_download.md:29Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run download
short: Download artifacts generated by a GitHub Actions workflow run.
long: |-
    The contents of each artifact will be extracted under separate directories based on
    the artifact name. If only a single artifact is specified, it will be extracted into
    the current directory.

    By default, this command downloads the latest artifact created and uploaded through
    GitHub Actions. Because workflows can delete or overwrite artifacts, `<run-id>`
    must be used to select an artifact from a specific workflow run.
pname: gh run
plink: gh_run.yaml
DOCS
gh_run_download.md:30Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:1Markdown · 104 words
TESTS
pkg/cmd/agent-task/list/list_test.go:92pkg/cmd/agent-task/list/list_test::Test_listRun · Go · 312 lines
func Test_listRun(t *testing.T) {
	sampleDate := time.Now().Add(-6 * time.Hour) // 6h ago
	sampleDateString := sampleDate.Format(time.RFC3339)

	tests := []struct {
		name           string
		tty            bool
		capiStubs      func(*testing.T, *capi.CapiClientMock)
		limit          int
		web            bool
		jsonFields     []string
		wantOut        string
		wantErr        error
		wantStderr     string
		wantBrowserURL string
	}{
		{
			name: "viewer-scoped no sessions",
			tty:  true,
			capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
				m.ListLatestSessionsForViewerFunc = func(ctx context.Context, limit int) ([]*capi.Session, error) {
					return nil, nil
				}
			},
			wantErr: cmdutil.NewNoResultsError("no agent tasks found"),
		},
		{
			name:  "viewer-scoped respects --limit",
			tty:   true,
			limit: 999,
+ 282 more lines · read full file
pkg/cmd/cache/list/list_test.go:129pkg/cmd/cache/list/list_test::TestListRun · Go · 222 lines
func TestListRun(t *testing.T) {
	var now = time.Date(2023, 1, 1, 1, 1, 1, 1, time.UTC)
	tests := []struct {
		name       string
		opts       ListOptions
		stubs      func(*httpmock.Registry)
		tty        bool
		wantErr    bool
		wantErrMsg string
		wantStderr string
		wantStdout string
	}{
		{
			name: "displays results tty",
			tty:  true,
			stubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/caches"),
					httpmock.JSONResponse(shared.CachePayload{
						ActionsCaches: []shared.Cache{
							{
								Id:             1,
								Key:            "foo",
								CreatedAt:      time.Date(2021, 1, 1, 1, 1, 1, 1, time.UTC),
								LastAccessedAt: time.Date(2022, 1, 1, 1, 1, 1, 1, time.UTC),
								SizeInBytes:    100,
							},
							{
								Id:             2,
								Key:            "bar",
+ 192 more lines · read full file
pkg/cmd/config/list/list_test.go:73pkg/cmd/config/list/list_test::Test_listRun · Go · 53 lines
func Test_listRun(t *testing.T) {
	tests := []struct {
		name    string
		input   *ListOptions
		config  gh.Config
		stdout  string
		wantErr bool
	}{
		{
			name: "list",
			config: func() gh.Config {
				cfg := config.NewBlankConfig()
				cfg.Set("HOST", "git_protocol", "ssh")
				cfg.Set("HOST", "editor", "/usr/bin/vim")
				cfg.Set("HOST", "prompt", "disabled")
				cfg.Set("HOST", "prefer_editor_prompt", "enabled")
				cfg.Set("HOST", "pager", "less")
				cfg.Set("HOST", "http_unix_socket", "")
				cfg.Set("HOST", "browser", "brave")
				return cfg
			}(),
			input: &ListOptions{Hostname: "HOST"},
			stdout: heredoc.Doc(`
				git_protocol=ssh
				editor=/usr/bin/vim
				prompt=disabled
				prefer_editor_prompt=enabled
				pager=less
				http_unix_socket=
				browser=brave
+ 23 more lines · read full file
+ 32 more tests · open all in source
EXAMPLES
CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:27Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:28Markdown · 4 words
TESTS
pkg/cmd/run/list/list_test.go:23pkg/cmd/run/list/list_test::TestNewCmdList · Go · 115 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "blank",
			wants: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "limit",
			cli:  "--limit 100",
			wants: ListOptions{
				Limit: 100,
			},
		},
		{
			name:     "bad limit",
			cli:      "--limit hi",
			wantsErr: true,
		},
		{
			name: "workflow",
			cli:  "--workflow foo.yml",
			wants: ListOptions{
+ 85 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:29Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:30Markdown · 8 words
TESTS
pkg/cmd/run/list/list_test.go:23pkg/cmd/run/list/list_test::TestNewCmdList · Go · 115 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "blank",
			wants: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "limit",
			cli:  "--limit 100",
			wants: ListOptions{
				Limit: 100,
			},
		},
		{
			name:     "bad limit",
			cli:      "--limit hi",
			wantsErr: true,
		},
		{
			name: "workflow",
			cli:  "--workflow foo.yml",
			wants: ListOptions{
+ 85 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:31Markdown · 8 words
TESTS
pkg/cmd/run/list/list_test.go:23pkg/cmd/run/list/list_test::TestNewCmdList · Go · 115 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "blank",
			wants: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "limit",
			cli:  "--limit 100",
			wants: ListOptions{
				Limit: 100,
			},
		},
		{
			name:     "bad limit",
			cli:      "--limit hi",
			wantsErr: true,
		},
		{
			name: "workflow",
			cli:  "--workflow foo.yml",
			wants: ListOptions{
+ 85 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:32Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:33Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:34Markdown · 6 words
TESTS
pkg/cmd/run/list/list_test.go:23pkg/cmd/run/list/list_test::TestNewCmdList · Go · 115 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "blank",
			wants: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "limit",
			cli:  "--limit 100",
			wants: ListOptions{
				Limit: 100,
			},
		},
		{
			name:     "bad limit",
			cli:      "--limit hi",
			wantsErr: true,
		},
		{
			name: "workflow",
			cli:  "--workflow foo.yml",
			wants: ListOptions{
+ 85 more lines · read full file
EXAMPLES

N/A

CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:35Markdown · 5 words
TESTS
pkg/cmd/run/list/list_test.go:23pkg/cmd/run/list/list_test::TestNewCmdList · Go · 115 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "blank",
			wants: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "limit",
			cli:  "--limit 100",
			wants: ListOptions{
				Limit: 100,
			},
		},
		{
			name:     "bad limit",
			cli:      "--limit hi",
			wantsErr: true,
		},
		{
			name: "workflow",
			cli:  "--workflow foo.yml",
			wants: ListOptions{
+ 85 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:36Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:37Markdown · 8 words
TESTS
pkg/cmd/run/list/list_test.go:23pkg/cmd/run/list/list_test::TestNewCmdList · Go · 115 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "blank",
			wants: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "limit",
			cli:  "--limit 100",
			wants: ListOptions{
				Limit: 100,
			},
		},
		{
			name:     "bad limit",
			cli:      "--limit hi",
			wantsErr: true,
		},
		{
			name: "workflow",
			cli:  "--workflow foo.yml",
			wants: ListOptions{
+ 85 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run list
short: List recent workflow runs.
long: |-
    Note that providing the `workflow_name` to the `-w` flag will not fetch disabled workflows.
    Also pass the `-a` flag to fetch disabled workflow runs using the `workflow_name` and the `-w` flag.

    Runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

    To see runs associated with a pull request, users should run `gh pr checks`.

    For more information about output formatting flags, see `gh help formatting`.
pname: gh run
DOCS
gh_run_list.md:38Markdown · 4 words
TESTS
pkg/cmd/run/list/list_test.go:23pkg/cmd/run/list/list_test::TestNewCmdList · Go · 115 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "blank",
			wants: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "limit",
			cli:  "--limit 100",
			wants: ListOptions{
				Limit: 100,
			},
		},
		{
			name:     "bad limit",
			cli:      "--limit hi",
			wantsErr: true,
		},
		{
			name: "workflow",
			cli:  "--workflow foo.yml",
			wants: ListOptions{
+ 85 more lines · read full file
EXAMPLES

N/A

CONTRACT
command: gh run rerun
short: Rerun an entire run, only failed jobs, or a specific job from a run.
long: Note that due to historical reasons, the `--job` flag may not take what you expect.
pname: gh run
plink: gh_run.yaml
options:
    - option: debug
      shorthand: d
      value_type: bool
      default_value: "false"
      description: Rerun with debug logging
    - option: failed
TESTS
pkg/cmd/run/rerun/rerun_test.go:22pkg/cmd/run/rerun/rerun_test::TestNewCmdRerun · Go · 143 lines
func TestNewCmdRerun(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    RerunOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: RerunOptions{
				Prompt: true,
			},
		},
		{
			name: "with arg nontty",
			cli:  "1234",
			wants: RerunOptions{
				RunID: "1234",
			},
		},
		{
			name: "with arg tty",
			tty:  true,
			cli:  "1234",
+ 113 more lines · read full file
pkg/cmd/run/rerun/rerun_test.go:166pkg/cmd/run/rerun/rerun_test::TestRerun · Go · 321 lines
func TestRerun(t *testing.T) {
	tests := []struct {
		name        string
		httpStubs   func(*httpmock.Registry)
		promptStubs func(*prompter.MockPrompter)
		opts        *RerunOptions
		tty         bool
		wantErr     bool
		errOut      string
		wantOut     string
		wantDebug   bool
	}{
		{
			name: "arg",
			tty:  true,
			opts: &RerunOptions{
				RunID: "1234",
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/1234"),
					httpmock.JSONResponse(shared.FailedRun))
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/123"),
					httpmock.JSONResponse(workflowShared.WorkflowsPayload{
						Workflows: []workflowShared.Workflow{
							shared.TestWorkflow,
						},
					}))
				reg.Register(
+ 291 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh run rerun
short: Rerun an entire run, only failed jobs, or a specific job from a run.
long: Note that due to historical reasons, the `--job` flag may not take what you expect.
pname: gh run
plink: gh_run.yaml
options:
    - option: debug
      shorthand: d
      value_type: bool
      default_value: "false"
      description: Rerun with debug logging
    - option: failed
TESTS
pkg/cmd/run/rerun/rerun_test.go:22pkg/cmd/run/rerun/rerun_test::TestNewCmdRerun · Go · 143 lines
func TestNewCmdRerun(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    RerunOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: RerunOptions{
				Prompt: true,
			},
		},
		{
			name: "with arg nontty",
			cli:  "1234",
			wants: RerunOptions{
				RunID: "1234",
			},
		},
		{
			name: "with arg tty",
			tty:  true,
			cli:  "1234",
+ 113 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run rerun
short: Rerun an entire run, only failed jobs, or a specific job from a run.
long: Note that due to historical reasons, the `--job` flag may not take what you expect.
pname: gh run
plink: gh_run.yaml
options:
    - option: debug
      shorthand: d
      value_type: bool
      default_value: "false"
      description: Rerun with debug logging
    - option: failed
TESTS
pkg/cmd/run/rerun/rerun_test.go:22pkg/cmd/run/rerun/rerun_test::TestNewCmdRerun · Go · 143 lines
func TestNewCmdRerun(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    RerunOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: RerunOptions{
				Prompt: true,
			},
		},
		{
			name: "with arg nontty",
			cli:  "1234",
			wants: RerunOptions{
				RunID: "1234",
			},
		},
		{
			name: "with arg tty",
			tty:  true,
			cli:  "1234",
+ 113 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run rerun
short: Rerun an entire run, only failed jobs, or a specific job from a run.
long: Note that due to historical reasons, the `--job` flag may not take what you expect.
pname: gh run
plink: gh_run.yaml
options:
    - option: debug
      shorthand: d
      value_type: bool
      default_value: "false"
      description: Rerun with debug logging
    - option: failed
TESTS
pkg/cmd/run/rerun/rerun_test.go:22pkg/cmd/run/rerun/rerun_test::TestNewCmdRerun · Go · 143 lines
func TestNewCmdRerun(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    RerunOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: RerunOptions{
				Prompt: true,
			},
		},
		{
			name: "with arg nontty",
			cli:  "1234",
			wants: RerunOptions{
				RunID: "1234",
			},
		},
		{
			name: "with arg tty",
			tty:  true,
			cli:  "1234",
+ 113 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run view
short: View a summary of a workflow run.
long: |-
    Due to platform limitations, `gh` may not always be able to associate jobs with their
    corresponding logs when using the primary method of fetching logs in zip format.

    In such cases, `gh` will attempt to fetch logs for each job individually via the API.
    This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
    the operation will fail with an error.

    Additionally, due to similar platform constraints, some log lines may not be
    associated with a specific step within a job. In these cases, the step name will
DOCS
gh_run_view.md:1Markdown · 142 words
TESTS
pkg/cmd/agent-task/view/view_test.go:160pkg/cmd/agent-task/view/view_test::Test_viewRun · Go · 1165 lines
func Test_viewRun(t *testing.T) {
	sampleDate := time.Now().Add(-6 * time.Hour) // 6h ago
	sampleCompletedAt := sampleDate.Add(5 * time.Minute)

	tests := []struct {
		name             string
		tty              bool
		opts             ViewOptions
		promptStubs      func(*testing.T, *prompter.MockPrompter)
		capiStubs        func(*testing.T, *capi.CapiClientMock)
		logRendererStubs func(*testing.T, *shared.LogRendererMock)
		jsonFields       []string
		wantOut          string
		wantErr          error
		wantStderr       string
		wantBrowserURL   string
	}{
		{
			name: "with session id, not found (tty)",
			tty:  true,
			opts: ViewOptions{
				SelectorArg: "some-session-id",
				SessionID:   "some-session-id",
			},
			capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
				m.GetSessionFunc = func(_ context.Context, _ string) (*capi.Session, error) {
					return nil, capi.ErrSessionNotFound
				}
			},
			wantStderr: "session not found\n",
+ 1135 more lines · read full file
pkg/cmd/gist/view/view_test.go:114pkg/cmd/gist/view/view_test::Test_viewRun · Go · 406 lines
func Test_viewRun(t *testing.T) {
	tests := []struct {
		name         string
		opts         *ViewOptions
		wantOut      string
		mockGist     *shared.Gist
		mockGistList bool
		isTTY        bool
		wantErr      string
	}{
		{
			name:  "no such gist",
			isTTY: false,
			opts: &ViewOptions{
				Selector:  "1234",
				ListFiles: false,
			},
			wantErr: "not found",
		},
		{
			name:  "one file",
			isTTY: true,
			opts: &ViewOptions{
				Selector:  "1234",
				ListFiles: false,
			},
			mockGist: &shared.Gist{
				Files: map[string]*shared.GistFile{
					"cicada.txt": {
						Content: "bwhiizzzbwhuiiizzzz",
+ 376 more lines · read full file
pkg/cmd/project/view/view_test.go:94pkg/cmd/project/view/view_test::TestRunView_User · Go · 71 lines
func TestRunView_User(t *testing.T) {
	defer gock.Off()

	// get user ID
	gock.New("https://api.github.com").
		Post("/graphql").
		MatchType("json").
		JSON(map[string]interface{}{
			"query": "query UserOrgOwner.*",
			"variables": map[string]interface{}{
				"login": "monalisa",
			},
		}).
		Reply(200).
		JSON(map[string]interface{}{
			"data": map[string]interface{}{
				"user": map[string]interface{}{
					"id": "an ID",
				},
			},
			"errors": []interface{}{
				map[string]interface{}{
					"type": "NOT_FOUND",
					"path": []string{"organization"},
				},
			},
		})

	gock.New("https://api.github.com").
		Post("/graphql").
+ 41 more lines · read full file
+ 28 more tests · open all in source
EXAMPLES
CONTRACT
command: gh run view
short: View a summary of a workflow run.
long: |-
    Due to platform limitations, `gh` may not always be able to associate jobs with their
    corresponding logs when using the primary method of fetching logs in zip format.

    In such cases, `gh` will attempt to fetch logs for each job individually via the API.
    This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
    the operation will fail with an error.

    Additionally, due to similar platform constraints, some log lines may not be
    associated with a specific step within a job. In these cases, the step name will
DOCS
gh_run_view.md:31Markdown · 7 words
TESTS
pkg/cmd/run/view/view_test.go:30pkg/cmd/run/view/view_test::TestNewCmdView · Go · 147 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ViewOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: ViewOptions{
				Prompt: true,
			},
		},
		{
			name: "web tty",
			tty:  true,
			cli:  "--web",
			wants: ViewOptions{
				Prompt: true,
				Web:    true,
			},
		},
		{
			name: "web nontty",
+ 117 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh run view
short: View a summary of a workflow run.
long: |-
    Due to platform limitations, `gh` may not always be able to associate jobs with their
    corresponding logs when using the primary method of fetching logs in zip format.

    In such cases, `gh` will attempt to fetch logs for each job individually via the API.
    This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
    the operation will fail with an error.

    Additionally, due to similar platform constraints, some log lines may not be
    associated with a specific step within a job. In these cases, the step name will
DOCS
gh_run_view.md:32Markdown · 7 words
TESTS
pkg/cmd/run/view/view_test.go:30pkg/cmd/run/view/view_test::TestNewCmdView · Go · 147 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ViewOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: ViewOptions{
				Prompt: true,
			},
		},
		{
			name: "web tty",
			tty:  true,
			cli:  "--web",
			wants: ViewOptions{
				Prompt: true,
				Web:    true,
			},
		},
		{
			name: "web nontty",
+ 117 more lines · read full file
EXAMPLES
CONTRACT
command: gh run view
short: View a summary of a workflow run.
long: |-
    Due to platform limitations, `gh` may not always be able to associate jobs with their
    corresponding logs when using the primary method of fetching logs in zip format.

    In such cases, `gh` will attempt to fetch logs for each job individually via the API.
    This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
    the operation will fail with an error.

    Additionally, due to similar platform constraints, some log lines may not be
    associated with a specific step within a job. In these cases, the step name will
DOCS
gh_run_view.md:33Markdown · 8 words
TESTS
pkg/cmd/run/view/view_test.go:30pkg/cmd/run/view/view_test::TestNewCmdView · Go · 147 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ViewOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: ViewOptions{
				Prompt: true,
			},
		},
		{
			name: "web tty",
			tty:  true,
			cli:  "--web",
			wants: ViewOptions{
				Prompt: true,
				Web:    true,
			},
		},
		{
			name: "web nontty",
+ 117 more lines · read full file
pkg/cmd/run/view/view_test.go:178pkg/cmd/run/view/view_test::TestViewRun · Go · 2529 lines
func TestViewRun(t *testing.T) {
	emptyZipArchive := createZipArchive(t, map[string]string{})
	zipArchive := createZipArchive(t, map[string]string{
		"0_cool job.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
			log line 1
			log line 2
			log line 3`),
		"cool job/1_fob the barz.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
		`),
		"cool job/2_barz the fob.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
		`),
		"1_sad job.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
			log line 1
			log line 2
			log line 3
		`),
		"sad job/1_barf the quux.txt": heredoc.Doc(`
			log line 1
+ 2499 more lines · read full file
EXAMPLES
CONTRACT
command: gh run view
short: View a summary of a workflow run.
long: |-
    Due to platform limitations, `gh` may not always be able to associate jobs with their
    corresponding logs when using the primary method of fetching logs in zip format.

    In such cases, `gh` will attempt to fetch logs for each job individually via the API.
    This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
    the operation will fail with an error.

    Additionally, due to similar platform constraints, some log lines may not be
    associated with a specific step within a job. In these cases, the step name will
DOCS
gh_run_view.md:34Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run view
short: View a summary of a workflow run.
long: |-
    Due to platform limitations, `gh` may not always be able to associate jobs with their
    corresponding logs when using the primary method of fetching logs in zip format.

    In such cases, `gh` will attempt to fetch logs for each job individually via the API.
    This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
    the operation will fail with an error.

    Additionally, due to similar platform constraints, some log lines may not be
    associated with a specific step within a job. In these cases, the step name will
DOCS
gh_run_view.md:35Markdown · 6 words
TESTS
pkg/cmd/run/view/view_test.go:178pkg/cmd/run/view/view_test::TestViewRun · Go · 2529 lines
func TestViewRun(t *testing.T) {
	emptyZipArchive := createZipArchive(t, map[string]string{})
	zipArchive := createZipArchive(t, map[string]string{
		"0_cool job.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
			log line 1
			log line 2
			log line 3`),
		"cool job/1_fob the barz.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
		`),
		"cool job/2_barz the fob.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
		`),
		"1_sad job.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
			log line 1
			log line 2
			log line 3
		`),
		"sad job/1_barf the quux.txt": heredoc.Doc(`
			log line 1
+ 2499 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run view
short: View a summary of a workflow run.
long: |-
    Due to platform limitations, `gh` may not always be able to associate jobs with their
    corresponding logs when using the primary method of fetching logs in zip format.

    In such cases, `gh` will attempt to fetch logs for each job individually via the API.
    This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
    the operation will fail with an error.

    Additionally, due to similar platform constraints, some log lines may not be
    associated with a specific step within a job. In these cases, the step name will
DOCS
gh_run_view.md:36Markdown · 10 words
TESTS
pkg/cmd/run/view/view_test.go:30pkg/cmd/run/view/view_test::TestNewCmdView · Go · 147 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ViewOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: ViewOptions{
				Prompt: true,
			},
		},
		{
			name: "web tty",
			tty:  true,
			cli:  "--web",
			wants: ViewOptions{
				Prompt: true,
				Web:    true,
			},
		},
		{
			name: "web nontty",
+ 117 more lines · read full file
pkg/cmd/run/view/view_test.go:178pkg/cmd/run/view/view_test::TestViewRun · Go · 2529 lines
func TestViewRun(t *testing.T) {
	emptyZipArchive := createZipArchive(t, map[string]string{})
	zipArchive := createZipArchive(t, map[string]string{
		"0_cool job.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
			log line 1
			log line 2
			log line 3`),
		"cool job/1_fob the barz.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
		`),
		"cool job/2_barz the fob.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
		`),
		"1_sad job.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
			log line 1
			log line 2
			log line 3
		`),
		"sad job/1_barf the quux.txt": heredoc.Doc(`
			log line 1
+ 2499 more lines · read full file
EXAMPLES
CONTRACT
command: gh run view
short: View a summary of a workflow run.
long: |-
    Due to platform limitations, `gh` may not always be able to associate jobs with their
    corresponding logs when using the primary method of fetching logs in zip format.

    In such cases, `gh` will attempt to fetch logs for each job individually via the API.
    This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
    the operation will fail with an error.

    Additionally, due to similar platform constraints, some log lines may not be
    associated with a specific step within a job. In these cases, the step name will
DOCS
gh_run_view.md:37Markdown · 13 words
TESTS
pkg/cmd/run/view/view_test.go:30pkg/cmd/run/view/view_test::TestNewCmdView · Go · 147 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ViewOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: ViewOptions{
				Prompt: true,
			},
		},
		{
			name: "web tty",
			tty:  true,
			cli:  "--web",
			wants: ViewOptions{
				Prompt: true,
				Web:    true,
			},
		},
		{
			name: "web nontty",
+ 117 more lines · read full file
pkg/cmd/run/view/view_test.go:178pkg/cmd/run/view/view_test::TestViewRun · Go · 2529 lines
func TestViewRun(t *testing.T) {
	emptyZipArchive := createZipArchive(t, map[string]string{})
	zipArchive := createZipArchive(t, map[string]string{
		"0_cool job.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
			log line 1
			log line 2
			log line 3`),
		"cool job/1_fob the barz.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
		`),
		"cool job/2_barz the fob.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
		`),
		"1_sad job.txt": heredoc.Doc(`
			log line 1
			log line 2
			log line 3
			log line 1
			log line 2
			log line 3
		`),
		"sad job/1_barf the quux.txt": heredoc.Doc(`
			log line 1
+ 2499 more lines · read full file
EXAMPLES

N/A

CONTRACT
command: gh run view
short: View a summary of a workflow run.
long: |-
    Due to platform limitations, `gh` may not always be able to associate jobs with their
    corresponding logs when using the primary method of fetching logs in zip format.

    In such cases, `gh` will attempt to fetch logs for each job individually via the API.
    This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
    the operation will fail with an error.

    Additionally, due to similar platform constraints, some log lines may not be
    associated with a specific step within a job. In these cases, the step name will
DOCS
gh_run_view.md:38Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run view
short: View a summary of a workflow run.
long: |-
    Due to platform limitations, `gh` may not always be able to associate jobs with their
    corresponding logs when using the primary method of fetching logs in zip format.

    In such cases, `gh` will attempt to fetch logs for each job individually via the API.
    This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
    the operation will fail with an error.

    Additionally, due to similar platform constraints, some log lines may not be
    associated with a specific step within a job. In these cases, the step name will
DOCS
gh_run_view.md:39Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

CONTRACT
command: gh run view
short: View a summary of a workflow run.
long: |-
    Due to platform limitations, `gh` may not always be able to associate jobs with their
    corresponding logs when using the primary method of fetching logs in zip format.

    In such cases, `gh` will attempt to fetch logs for each job individually via the API.
    This fallback is slower and more resource-intensive. If more than 25 job logs are missing,
    the operation will fail with an error.

    Additionally, due to similar platform constraints, some log lines may not be
    associated with a specific step within a job. In these cases, the step name will
DOCS
gh_run_view.md:40Markdown · 5 words
TESTS
pkg/cmd/run/view/view_test.go:30pkg/cmd/run/view/view_test::TestNewCmdView · Go · 147 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ViewOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: ViewOptions{
				Prompt: true,
			},
		},
		{
			name: "web tty",
			tty:  true,
			cli:  "--web",
			wants: ViewOptions{
				Prompt: true,
				Web:    true,
			},
		},
		{
			name: "web nontty",
+ 117 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run watch
short: Watch a run until it completes, showing its progress.
long: |-
    By default, all steps are displayed. The `--compact` option can be used to only
    show the relevant/failed steps.

    This command does not support authenticating via fine grained PATs
    as it is not currently possible to create a PAT with the `checks:read` permission.
pname: gh run
plink: gh_run.yaml
options:
    - option: compact
TESTS
pkg/cmd/run/watch/watch_test.go:22pkg/cmd/run/watch/watch_test::TestNewCmdWatch · Go · 87 lines
func TestNewCmdWatch(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    WatchOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: WatchOptions{
				Prompt:   true,
				Interval: defaultInterval,
			},
		},
		{
			name: "interval",
			tty:  true,
			cli:  "-i10",
			wants: WatchOptions{
				Interval: 10,
				Prompt:   true,
			},
		},
		{
+ 57 more lines · read full file
pkg/cmd/run/watch/watch_test.go:110pkg/cmd/run/watch/watch_test::TestWatchRun · Go · 309 lines
func TestWatchRun(t *testing.T) {
	failedRunStubs := func(reg *httpmock.Registry) {
		inProgressRun := shared.TestRunWithCommit(2, shared.InProgress, "", "commit2")
		completedRun := shared.TestRun(2, shared.Completed, shared.Failure)
		reg.Register(
			httpmock.REST("GET", "repos/OWNER/REPO/actions/runs"),
			httpmock.JSONResponse(shared.RunsPayload{
				WorkflowRuns: []shared.Run{
					shared.TestRunWithCommit(1, shared.InProgress, "", "commit1"),
					inProgressRun,
				},
			}))
		reg.Register(
			httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/2"),
			httpmock.JSONResponse(inProgressRun))
		reg.Register(
			httpmock.REST("GET", "runs/2/jobs"),
			httpmock.JSONResponse(shared.JobsPayload{
				Jobs: []shared.Job{}}))
		reg.Register(
			httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/2"),
			httpmock.JSONResponse(completedRun))
		reg.Register(
			httpmock.REST("GET", "runs/2/jobs"),
			httpmock.JSONResponse(shared.JobsPayload{
				Jobs: []shared.Job{
					shared.FailedJob,
				},
			}))
		reg.Register(
+ 279 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh run watch
short: Watch a run until it completes, showing its progress.
long: |-
    By default, all steps are displayed. The `--compact` option can be used to only
    show the relevant/failed steps.

    This command does not support authenticating via fine grained PATs
    as it is not currently possible to create a PAT with the `checks:read` permission.
pname: gh run
plink: gh_run.yaml
options:
    - option: compact
DOCS
gh_run_watch.md:26Markdown · 4 words
TESTS
pkg/cmd/run/watch/watch_test.go:22pkg/cmd/run/watch/watch_test::TestNewCmdWatch · Go · 87 lines
func TestNewCmdWatch(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    WatchOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: WatchOptions{
				Prompt:   true,
				Interval: defaultInterval,
			},
		},
		{
			name: "interval",
			tty:  true,
			cli:  "-i10",
			wants: WatchOptions{
				Interval: 10,
				Prompt:   true,
			},
		},
		{
+ 57 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh run watch
short: Watch a run until it completes, showing its progress.
long: |-
    By default, all steps are displayed. The `--compact` option can be used to only
    show the relevant/failed steps.

    This command does not support authenticating via fine grained PATs
    as it is not currently possible to create a PAT with the `checks:read` permission.
pname: gh run
plink: gh_run.yaml
options:
    - option: compact
DOCS
gh_run_watch.md:27Markdown · 7 words
TESTS
pkg/cmd/run/watch/watch_test.go:22pkg/cmd/run/watch/watch_test::TestNewCmdWatch · Go · 87 lines
func TestNewCmdWatch(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    WatchOptions
		wantsErr bool
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "blank tty",
			tty:  true,
			wants: WatchOptions{
				Prompt:   true,
				Interval: defaultInterval,
			},
		},
		{
			name: "interval",
			tty:  true,
			cli:  "-i10",
			wants: WatchOptions{
				Interval: 10,
				Prompt:   true,
			},
		},
		{
+ 57 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh run watch
short: Watch a run until it completes, showing its progress.
long: |-
    By default, all steps are displayed. The `--compact` option can be used to only
    show the relevant/failed steps.

    This command does not support authenticating via fine grained PATs
    as it is not currently possible to create a PAT with the `checks:read` permission.
pname: gh run
plink: gh_run.yaml
options:
    - option: compact
DOCS
gh_run_watch.md:28Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search
short: Search across all of GitHub.
long: |-
    Excluding search results that match a qualifier

    In a browser, the GitHub search syntax supports excluding results that match a search qualifier
    by prefixing the qualifier with a hyphen. For example, to search for issues that
    do not have the label "bug", you would use `-label:bug` as a search qualifier.

    `gh` supports this syntax in `gh search` as well, but it requires extra
    command line arguments to avoid the hyphen being interpreted as a command line flag because it begins with a hyphen.
DOCS
gh_search.md:1Markdown · 205 words
TESTS
pkg/cmd/skills/search/search_test.go:20pkg/cmd/skills/search/search_test::TestSearchRun_UnsupportedHost · Go · 18 lines
func TestSearchRun_UnsupportedHost(t *testing.T) {
	ios, _, _, _ := iostreams.Test()
	cfg := config.NewBlankConfig()
	authCfg := cfg.Authentication()
	authCfg.SetDefaultHost("acme.ghes.com", "user")
	cfg.AuthenticationFunc = func() gh.AuthConfig {
		return authCfg
	}
	err := searchRun(&SearchOptions{
		IO:         ios,
		Query:      "terraform",
		Page:       1,
		Limit:      defaultLimit,
		HttpClient: func() (*http.Client, error) { return &http.Client{}, nil },
		Config:     func() (gh.Config, error) { return cfg, nil },
	})
	require.ErrorContains(t, err, "does not currently support GitHub Enterprise Server")
}
pkg/cmd/skills/search/search_test.go:39pkg/cmd/skills/search/search_test::TestNewCmdSearch · Go · 96 lines
func TestNewCmdSearch(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantOpts SearchOptions
		wantErr  string
	}{
		{
			name:     "query argument",
			args:     "terraform",
			wantOpts: SearchOptions{Query: "terraform", Page: 1, Limit: defaultLimit},
		},
		{
			name:     "with page flag",
			args:     "terraform --page 3",
			wantOpts: SearchOptions{Query: "terraform", Page: 3, Limit: defaultLimit},
		},
		{
			name:     "with limit flag",
			args:     "terraform --limit 5",
			wantOpts: SearchOptions{Query: "terraform", Page: 1, Limit: 5},
		},
		{
			name:     "with limit short flag",
			args:     "terraform -L 10",
			wantOpts: SearchOptions{Query: "terraform", Page: 1, Limit: 10},
		},
		{
			name:     "with owner flag",
			args:     "terraform --owner hashicorp",
+ 66 more lines · read full file
pkg/cmd/skills/search/search_test.go:136pkg/cmd/skills/search/search_test::TestSearchRun · Go · 258 lines
func TestSearchRun(t *testing.T) {
	const emptyCodeResponse = `{"total_count": 0, "incomplete_results": false, "items": []}`

	// stubKeywordSearch registers the HTTP stubs needed for a keyword search.
	// searchByKeyword fires up to 3 concurrent search/code requests (path,
	// owner, primary). Stubs are one-shot in httpmock, so we register one
	// per request.
	stubKeywordSearch := func(reg *httpmock.Registry, codeResponse string) {
		for range 3 {
			reg.Register(
				httpmock.REST("GET", "search/code"),
				httpmock.StringResponse(codeResponse),
			)
		}
	}

	tests := []struct {
		name       string
		opts       *SearchOptions
		tty        bool
		httpStubs  func(*httpmock.Registry)
		wantStdout string
		wantStderr string
		wantErr    string
	}{
		{
			name: "displays results in non-TTY",
			tty:  false,
			opts: &SearchOptions{Query: "terraform", Page: 1, Limit: defaultLimit},
			httpStubs: func(reg *httpmock.Registry) {
+ 228 more lines · read full file
+ 10 more tests · open all in source
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:1Markdown · 85 words
TESTS
pkg/cmd/search/code/code_test.go:20pkg/cmd/search/code/code_test::TestNewCmdCode · Go · 114 lines
func TestNewCmdCode(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  CodeOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "react lifecycle",
			output: CodeOptions{
				Query: search.Query{
					Keywords: []string{"react", "lifecycle"},
					Kind:     "code",
					Limit:    30,
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
			output: CodeOptions{
				Query: search.Query{
+ 84 more lines · read full file
pkg/cmd/search/code/code_test.go:135pkg/cmd/search/code/code_test::TestCodeRun · Go · 280 lines
func TestCodeRun(t *testing.T) {
	var query = search.Query{
		Keywords: []string{"map"},
		Kind:     "code",
		Limit:    30,
		Qualifiers: search.Qualifiers{
			Language: "go",
			Repo:     []string{"cli/cli"},
		},
	}
	tests := []struct {
		errMsg     string
		name       string
		opts       *CodeOptions
		tty        bool
		wantErr    bool
		wantStderr string
		wantStdout string
		wantBrowse string
	}{
		{
			name: "displays results tty",
			opts: &CodeOptions{
				Query: query,
				Searcher: &search.SearcherMock{
					CodeFunc: func(query search.Query) (search.CodeResult, error) {
						return search.CodeResult{
							IncompleteResults: false,
							Items: []search.Code{
								{
+ 250 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:29Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:30Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:31Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:32Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:33Markdown · 4 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:34Markdown · 7 words
TESTS
pkg/cmd/search/code/code_test.go:20pkg/cmd/search/code/code_test::TestNewCmdCode · Go · 114 lines
func TestNewCmdCode(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  CodeOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "react lifecycle",
			output: CodeOptions{
				Query: search.Query{
					Keywords: []string{"react", "lifecycle"},
					Kind:     "code",
					Limit:    30,
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
			output: CodeOptions{
				Query: search.Query{
+ 84 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:35Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:36Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:37Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:38Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:39Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search code
short: Search within code in GitHub repositories.
pname: gh search
plink: gh_search.yaml
options:
    - option: extension
      value_type: string
      description: Filter on file extension
    - option: filename
      value_type: string
      description: Filter on filename
    - option: jq
DOCS
gh_search_code.md:40Markdown · 8 words
TESTS
pkg/cmd/search/code/code_test.go:20pkg/cmd/search/code/code_test::TestNewCmdCode · Go · 114 lines
func TestNewCmdCode(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		output  CodeOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "react lifecycle",
			output: CodeOptions{
				Query: search.Query{
					Keywords: []string{"react", "lifecycle"},
					Kind:     "code",
					Limit:    30,
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
			output: CodeOptions{
				Query: search.Query{
+ 84 more lines · read full file
pkg/cmd/search/code/code_test.go:135pkg/cmd/search/code/code_test::TestCodeRun · Go · 280 lines
func TestCodeRun(t *testing.T) {
	var query = search.Query{
		Keywords: []string{"map"},
		Kind:     "code",
		Limit:    30,
		Qualifiers: search.Qualifiers{
			Language: "go",
			Repo:     []string{"cli/cli"},
		},
	}
	tests := []struct {
		errMsg     string
		name       string
		opts       *CodeOptions
		tty        bool
		wantErr    bool
		wantStderr string
		wantStdout string
		wantBrowse string
	}{
		{
			name: "displays results tty",
			opts: &CodeOptions{
				Query: query,
				Searcher: &search.SearcherMock{
					CodeFunc: func(query search.Query) (search.CodeResult, error) {
						return search.CodeResult{
							IncompleteResults: false,
							Items: []search.Code{
								{
+ 250 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:1Markdown · 68 words
TESTS
pkg/cmd/search/commits/commits_test.go:17pkg/cmd/search/commits/commits_test::TestNewCmdCommits · Go · 129 lines
func TestNewCmdCommits(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  CommitsOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: CommitsOptions{
				Query: search.Query{Keywords: []string{"some", "search", "terms"}, Kind: "commits", Limit: 30},
			},
		},
		{
			name:  "web flag",
			input: "--web",
			output: CommitsOptions{
				Query:   search.Query{Keywords: []string{}, Kind: "commits", Limit: 30},
				WebMode: true,
			},
		},
+ 99 more lines · read full file
pkg/cmd/search/commits/commits_test.go:147pkg/cmd/search/commits/commits_test::TestCommitsRun · Go · 165 lines
func TestCommitsRun(t *testing.T) {
	var now = time.Date(2023, 1, 17, 12, 30, 0, 0, time.UTC)
	var author = search.CommitUser{Date: time.Date(2022, 12, 27, 11, 30, 0, 0, time.UTC)}
	var committer = search.CommitUser{Date: time.Date(2022, 12, 28, 12, 30, 0, 0, time.UTC)}
	var query = search.Query{
		Keywords:   []string{"cli"},
		Kind:       "commits",
		Limit:      30,
		Qualifiers: search.Qualifiers{},
	}
	tests := []struct {
		errMsg     string
		name       string
		opts       *CommitsOptions
		tty        bool
		wantErr    bool
		wantStderr string
		wantStdout string
	}{
		{
			name: "displays results tty",
			opts: &CommitsOptions{
				Query: query,
				Searcher: &search.SearcherMock{
					CommitsFunc: func(query search.Query) (search.CommitsResult, error) {
						return search.CommitsResult{
							IncompleteResults: false,
							Items: []search.Commit{
								{
									Author: search.User{Login: "monalisa"},
+ 135 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:28Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:29Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:30Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:31Markdown · 4 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:32Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:33Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:34Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:35Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:36Markdown · 4 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:37Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:38Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:39Markdown · 6 words
TESTS
pkg/cmd/search/commits/commits_test.go:17pkg/cmd/search/commits/commits_test::TestNewCmdCommits · Go · 129 lines
func TestNewCmdCommits(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  CommitsOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: CommitsOptions{
				Query: search.Query{Keywords: []string{"some", "search", "terms"}, Kind: "commits", Limit: 30},
			},
		},
		{
			name:  "web flag",
			input: "--web",
			output: CommitsOptions{
				Query:   search.Query{Keywords: []string{}, Kind: "commits", Limit: 30},
				WebMode: true,
			},
		},
+ 99 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:40Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:41Markdown · 11 words
TESTS
pkg/cmd/search/commits/commits_test.go:17pkg/cmd/search/commits/commits_test::TestNewCmdCommits · Go · 129 lines
func TestNewCmdCommits(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  CommitsOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: CommitsOptions{
				Query: search.Query{Keywords: []string{"some", "search", "terms"}, Kind: "commits", Limit: 30},
			},
		},
		{
			name:  "web flag",
			input: "--web",
			output: CommitsOptions{
				Query:   search.Query{Keywords: []string{}, Kind: "commits", Limit: 30},
				WebMode: true,
			},
		},
+ 99 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:42Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:43Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:44Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:45Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:46Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:47Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:48Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search commits
short: Search for commits on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: author
      value_type: string
      description: Filter by author
    - option: author-date
DOCS
gh_search_commits.md:49Markdown · 8 words
TESTS
pkg/cmd/search/commits/commits_test.go:17pkg/cmd/search/commits/commits_test::TestNewCmdCommits · Go · 129 lines
func TestNewCmdCommits(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  CommitsOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: CommitsOptions{
				Query: search.Query{Keywords: []string{"some", "search", "terms"}, Kind: "commits", Limit: 30},
			},
		},
		{
			name:  "web flag",
			input: "--web",
			output: CommitsOptions{
				Query:   search.Query{Keywords: []string{}, Kind: "commits", Limit: 30},
				WebMode: true,
			},
		},
+ 99 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:1Markdown · 101 words
TESTS
pkg/cmd/search/issues/issues_test.go:15pkg/cmd/search/issues/issues_test::TestNewCmdIssues · Go · 180 lines
func TestNewCmdIssues(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "issue"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 150 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:32Markdown · 5 words
TESTS
pkg/cmd/search/issues/issues_test.go:15pkg/cmd/search/issues/issues_test::TestNewCmdIssues · Go · 180 lines
func TestNewCmdIssues(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "issue"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 150 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:33Markdown · 8 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:34Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:35Markdown · 3 words
TESTS
pkg/cmd/search/issues/issues_test.go:15pkg/cmd/search/issues/issues_test::TestNewCmdIssues · Go · 180 lines
func TestNewCmdIssues(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "issue"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 150 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:36Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:37Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:38Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:39Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:40Markdown · 5 words
TESTS
pkg/cmd/search/issues/issues_test.go:15pkg/cmd/search/issues/issues_test::TestNewCmdIssues · Go · 180 lines
func TestNewCmdIssues(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "issue"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 150 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:41Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:42Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:43Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:44Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:45Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:46Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:47Markdown · 6 words
TESTS
pkg/cmd/search/issues/issues_test.go:15pkg/cmd/search/issues/issues_test::TestNewCmdIssues · Go · 180 lines
func TestNewCmdIssues(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "issue"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 150 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:48Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:49Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:50Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:51Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:52Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:53Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:54Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:55Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:56Markdown · 11 words
TESTS
pkg/cmd/search/issues/issues_test.go:15pkg/cmd/search/issues/issues_test::TestNewCmdIssues · Go · 180 lines
func TestNewCmdIssues(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "issue"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 150 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:57Markdown · 4 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:58Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:59Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:60Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:61Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:62Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:63Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:64Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:65Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:66Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search issues
short: Search for issues on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_issues.md:67Markdown · 8 words
TESTS
pkg/cmd/search/issues/issues_test.go:15pkg/cmd/search/issues/issues_test::TestNewCmdIssues · Go · 180 lines
func TestNewCmdIssues(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "issue"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 150 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:1Markdown · 103 words
TESTS
pkg/cmd/search/prs/prs_test.go:15pkg/cmd/search/prs/prs_test::TestNewCmdPrs · Go · 189 lines
func TestNewCmdPrs(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "pr"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 159 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:32Markdown · 5 words
TESTS
pkg/cmd/search/prs/prs_test.go:15pkg/cmd/search/prs/prs_test::TestNewCmdPrs · Go · 189 lines
func TestNewCmdPrs(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "pr"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 159 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:33Markdown · 8 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:34Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:35Markdown · 3 words
TESTS
pkg/cmd/search/prs/prs_test.go:15pkg/cmd/search/prs/prs_test::TestNewCmdPrs · Go · 189 lines
func TestNewCmdPrs(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "pr"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 159 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:36Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:37Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:38Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:39Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:40Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:41Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:42Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:43Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:44Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:45Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:46Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:47Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:48Markdown · 3 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:49Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:50Markdown · 6 words
TESTS
pkg/cmd/search/prs/prs_test.go:15pkg/cmd/search/prs/prs_test::TestNewCmdPrs · Go · 189 lines
func TestNewCmdPrs(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "pr"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 159 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:51Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:52Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:53Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:54Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:55Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:56Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:57Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:58Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:59Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:60Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:61Markdown · 11 words
TESTS
pkg/cmd/search/prs/prs_test.go:15pkg/cmd/search/prs/prs_test::TestNewCmdPrs · Go · 189 lines
func TestNewCmdPrs(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "pr"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 159 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:62Markdown · 4 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:63Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:64Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:65Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:66Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:67Markdown · 8 words
TESTS
pkg/cmd/search/prs/prs_test.go:15pkg/cmd/search/prs/prs_test::TestNewCmdPrs · Go · 189 lines
func TestNewCmdPrs(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "pr"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 159 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:68Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:69Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:70Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:71Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:72Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:73Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:74Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search prs
short: Search for pull requests on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: app
      value_type: string
      description: Filter by GitHub App author
    - option: archived
DOCS
gh_search_prs.md:75Markdown · 8 words
TESTS
pkg/cmd/search/prs/prs_test.go:15pkg/cmd/search/prs/prs_test::TestNewCmdPrs · Go · 189 lines
func TestNewCmdPrs(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  shared.IssuesOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: shared.IssuesOptions{
				Query: search.Query{
					Keywords:   []string{"some", "search", "terms"},
					Kind:       "issues",
					Limit:      30,
					Qualifiers: search.Qualifiers{Type: "pr"},
				},
			},
		},
		{
			name:  "web flag",
			input: "--web",
+ 159 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:1Markdown · 88 words
TESTS
pkg/cmd/search/repos/repos_test.go:17pkg/cmd/search/repos/repos_test::TestNewCmdRepos · Go · 133 lines
func TestNewCmdRepos(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  ReposOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: ReposOptions{
				Query: search.Query{Keywords: []string{"some", "search", "terms"}, Kind: "repositories", Limit: 30},
			},
		},
		{
			name:  "web flag",
			input: "--web",
			output: ReposOptions{
				Query:   search.Query{Keywords: []string{}, Kind: "repositories", Limit: 30},
				WebMode: true,
			},
		},
+ 103 more lines · read full file
pkg/cmd/search/repos/repos_test.go:151pkg/cmd/search/repos/repos_test::TestReposRun · Go · 137 lines
func TestReposRun(t *testing.T) {
	var now = time.Date(2022, 2, 28, 12, 30, 0, 0, time.UTC)
	var updatedAt = time.Date(2021, 2, 28, 12, 30, 0, 0, time.UTC)
	var query = search.Query{
		Keywords: []string{"cli"},
		Kind:     "repositories",
		Limit:    30,
		Qualifiers: search.Qualifiers{
			Stars: ">50",
			Topic: []string{"golang"},
		},
	}
	tests := []struct {
		errMsg     string
		name       string
		opts       *ReposOptions
		tty        bool
		wantErr    bool
		wantStderr string
		wantStdout string
	}{
		{
			name: "displays results tty",
			opts: &ReposOptions{
				Query: query,
				Searcher: &search.SearcherMock{
					RepositoriesFunc: func(query search.Query) (search.RepositoriesResult, error) {
						return search.RepositoriesResult{
							IncompleteResults: false,
							Items: []search.Repository{
+ 107 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:28Markdown · 8 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:29Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:30Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:31Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:32Markdown · 11 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:33Markdown · 10 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:34Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:35Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:36Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:37Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:38Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:39Markdown · 6 words
TESTS
pkg/cmd/search/repos/repos_test.go:17pkg/cmd/search/repos/repos_test::TestNewCmdRepos · Go · 133 lines
func TestNewCmdRepos(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  ReposOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: ReposOptions{
				Query: search.Query{Keywords: []string{"some", "search", "terms"}, Kind: "repositories", Limit: 30},
			},
		},
		{
			name:  "web flag",
			input: "--web",
			output: ReposOptions{
				Query:   search.Query{Keywords: []string{}, Kind: "repositories", Limit: 30},
				WebMode: true,
			},
		},
+ 103 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:40Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:41Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:42Markdown · 11 words
TESTS
pkg/cmd/search/repos/repos_test.go:17pkg/cmd/search/repos/repos_test::TestNewCmdRepos · Go · 133 lines
func TestNewCmdRepos(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  ReposOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: ReposOptions{
				Query: search.Query{Keywords: []string{"some", "search", "terms"}, Kind: "repositories", Limit: 30},
			},
		},
		{
			name:  "web flag",
			input: "--web",
			output: ReposOptions{
				Query:   search.Query{Keywords: []string{}, Kind: "repositories", Limit: 30},
				WebMode: true,
			},
		},
+ 103 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:43Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:44Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:45Markdown · 4 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:46Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:47Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:48Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:49Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:50Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh search repos
short: Search for repositories on GitHub.
long: |-
    The command supports constructing queries using the GitHub search syntax,
    using the parameter and qualifier flags, or a combination of the two.
pname: gh search
plink: gh_search.yaml
options:
    - option: archived
      value_type: bool
      default_value: "false"
      description: Filter based on the repository archived state {true|false}
DOCS
gh_search_repos.md:51Markdown · 8 words
TESTS
pkg/cmd/search/repos/repos_test.go:17pkg/cmd/search/repos/repos_test::TestNewCmdRepos · Go · 133 lines
func TestNewCmdRepos(t *testing.T) {
	var trueBool = true
	tests := []struct {
		name    string
		input   string
		output  ReposOptions
		wantErr bool
		errMsg  string
	}{
		{
			name:    "no arguments",
			input:   "",
			wantErr: true,
			errMsg:  "specify search keywords or flags",
		},
		{
			name:  "keyword arguments",
			input: "some search terms",
			output: ReposOptions{
				Query: search.Query{Keywords: []string{"some", "search", "terms"}, Kind: "repositories", Limit: 30},
			},
		},
		{
			name:  "web flag",
			input: "--web",
			output: ReposOptions{
				Query:   search.Query{Keywords: []string{}, Kind: "repositories", Limit: 30},
				WebMode: true,
			},
		},
+ 103 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret
short: Secrets can be set at the repository, or organization level for use in
long: |-
    GitHub Actions, Agents, or Dependabot. User, organization, and repository secrets can be set for
    use in GitHub Codespaces. Environment secrets can be set for use in
    GitHub Actions. Run `gh help secret set` to learn how to get started.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
DOCS
gh_secret.md:1Markdown · 73 words
TESTS

N/A

EXAMPLES

N/A

CONTRACT
command: gh secret
short: Secrets can be set at the repository, or organization level for use in
long: |-
    GitHub Actions, Agents, or Dependabot. User, organization, and repository secrets can be set for
    use in GitHub Codespaces. Environment secrets can be set for use in
    GitHub Actions. Run `gh help secret set` to learn how to get started.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
DOCS
gh_secret.md:26Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret delete
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Delete a secret for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_delete.md:1Markdown · 79 words
TESTS
pkg/cmd/secret/delete/delete_test.go:24pkg/cmd/secret/delete/delete_test::TestNewCmdDelete · Go · 120 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    DeleteOptions
		wantsErr bool
	}{
		{
			name:     "no args",
			wantsErr: true,
		},
		{
			name: "repo",
			cli:  "cool",
			wants: DeleteOptions{
				SecretName: "cool",
			},
		},
		{
			name: "org",
			cli:  "cool --org anOrg",
			wants: DeleteOptions{
				SecretName: "cool",
				OrgName:    "anOrg",
			},
		},
		{
			name: "env",
			cli:  "cool --env anEnv",
			wants: DeleteOptions{
+ 90 more lines · read full file
pkg/cmd/secret/delete/delete_test.go:145pkg/cmd/secret/delete/delete_test::TestNewCmdDeleteBaseRepoFuncs · Go · 134 lines
func TestNewCmdDeleteBaseRepoFuncs(t *testing.T) {
	multipleRemotes := ghContext.Remotes{
		&ghContext.Remote{
			Remote: &git.Remote{
				Name: "origin",
			},
			Repo: ghrepo.New("owner", "fork"),
		},
		&ghContext.Remote{
			Remote: &git.Remote{
				Name: "upstream",
			},
			Repo: ghrepo.New("owner", "repo"),
		},
	}

	singleRemote := ghContext.Remotes{
		&ghContext.Remote{
			Remote: &git.Remote{
				Name: "origin",
			},
			Repo: ghrepo.New("owner", "repo"),
		},
	}

	tests := []struct {
		name          string
		args          string
		env           map[string]string
		remotes       ghContext.Remotes
+ 104 more lines · read full file
pkg/cmd/secret/delete/delete_test.go:280pkg/cmd/secret/delete/delete_test::Test_removeRun_repo · Go · 96 lines
func Test_removeRun_repo(t *testing.T) {
	tests := []struct {
		name      string
		opts      *DeleteOptions
		host      string
		httpStubs func(*httpmock.Registry)
	}{
		{
			name: "Actions",
			opts: &DeleteOptions{
				Application: "actions",
				SecretName:  "cool_secret",
			},
			host: "github.com",
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.WithHost(httpmock.REST("DELETE", "repos/owner/repo/actions/secrets/cool_secret"), "api.github.com"), httpmock.StatusStringResponse(204, "No Content"))
			},
		},
		{
			name: "Actions GHES",
			opts: &DeleteOptions{
				Application: "actions",
				SecretName:  "cool_secret",
			},
			host: "example.com",
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.WithHost(httpmock.REST("DELETE", "api/v3/repos/owner/repo/actions/secrets/cool_secret"), "example.com"), httpmock.StatusStringResponse(204, "No Content"))
			},
		},
		{
+ 66 more lines · read full file
+ 3 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh secret delete
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Delete a secret for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_delete.md:24Markdown · 8 words
TESTS
pkg/cmd/secret/delete/delete_test.go:24pkg/cmd/secret/delete/delete_test::TestNewCmdDelete · Go · 120 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    DeleteOptions
		wantsErr bool
	}{
		{
			name:     "no args",
			wantsErr: true,
		},
		{
			name: "repo",
			cli:  "cool",
			wants: DeleteOptions{
				SecretName: "cool",
			},
		},
		{
			name: "org",
			cli:  "cool --org anOrg",
			wants: DeleteOptions{
				SecretName: "cool",
				OrgName:    "anOrg",
			},
		},
		{
			name: "env",
			cli:  "cool --env anEnv",
			wants: DeleteOptions{
+ 90 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret delete
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Delete a secret for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_delete.md:25Markdown · 6 words
TESTS
pkg/cmd/secret/delete/delete_test.go:24pkg/cmd/secret/delete/delete_test::TestNewCmdDelete · Go · 120 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    DeleteOptions
		wantsErr bool
	}{
		{
			name:     "no args",
			wantsErr: true,
		},
		{
			name: "repo",
			cli:  "cool",
			wants: DeleteOptions{
				SecretName: "cool",
			},
		},
		{
			name: "org",
			cli:  "cool --org anOrg",
			wants: DeleteOptions{
				SecretName: "cool",
				OrgName:    "anOrg",
			},
		},
		{
			name: "env",
			cli:  "cool --env anEnv",
			wants: DeleteOptions{
+ 90 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret delete
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Delete a secret for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_delete.md:26Markdown · 6 words
TESTS
pkg/cmd/secret/delete/delete_test.go:24pkg/cmd/secret/delete/delete_test::TestNewCmdDelete · Go · 120 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    DeleteOptions
		wantsErr bool
	}{
		{
			name:     "no args",
			wantsErr: true,
		},
		{
			name: "repo",
			cli:  "cool",
			wants: DeleteOptions{
				SecretName: "cool",
			},
		},
		{
			name: "org",
			cli:  "cool --org anOrg",
			wants: DeleteOptions{
				SecretName: "cool",
				OrgName:    "anOrg",
			},
		},
		{
			name: "env",
			cli:  "cool --env anEnv",
			wants: DeleteOptions{
+ 90 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret delete
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Delete a secret for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_delete.md:27Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret list
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'List secrets for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_list.md:1Markdown · 85 words
TESTS
pkg/cmd/secret/list/list_test.go:28pkg/cmd/secret/list/list_test::Test_NewCmdList · Go · 94 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants ListOptions
	}{
		{
			name: "repo",
			cli:  "",
			wants: ListOptions{
				OrgName: "",
			},
		},
		{
			name: "org",
			cli:  "-oUmbrellaCorporation",
			wants: ListOptions{
				OrgName: "UmbrellaCorporation",
			},
		},
		{
			name: "env",
			cli:  "-eDevelopment",
			wants: ListOptions{
				EnvName: "Development",
			},
		},
		{
			name: "user",
			cli:  "-u",
+ 64 more lines · read full file
pkg/cmd/secret/list/list_test.go:123pkg/cmd/secret/list/list_test::TestNewCmdListBaseRepoFuncs · Go · 133 lines
func TestNewCmdListBaseRepoFuncs(t *testing.T) {
	multipleRemotes := ghContext.Remotes{
		&ghContext.Remote{
			Remote: &git.Remote{
				Name: "origin",
			},
			Repo: ghrepo.New("owner", "fork"),
		},
		&ghContext.Remote{
			Remote: &git.Remote{
				Name: "upstream",
			},
			Repo: ghrepo.New("owner", "repo"),
		},
	}

	singleRemote := ghContext.Remotes{
		&ghContext.Remote{
			Remote: &git.Remote{
				Name: "origin",
			},
			Repo: ghrepo.New("owner", "repo"),
		},
	}

	tests := []struct {
		name          string
		args          string
		env           map[string]string
		remotes       ghContext.Remotes
+ 103 more lines · read full file
pkg/cmd/secret/list/list_test.go:257pkg/cmd/secret/list/list_test::Test_listRun · Go · 394 lines
func Test_listRun(t *testing.T) {
	tests := []struct {
		name    string
		tty     bool
		json    bool
		opts    *ListOptions
		wantOut []string
	}{
		{
			name: "repo tty",
			tty:  true,
			opts: &ListOptions{},
			wantOut: []string{
				"NAME          UPDATED",
				"SECRET_ONE    about 34 years ago",
				"SECRET_TWO    about 2 years ago",
				"SECRET_THREE  about 47 years ago",
			},
		},
		{
			name: "repo not tty",
			tty:  false,
			opts: &ListOptions{},
			wantOut: []string{
				"SECRET_ONE\t1988-10-11T00:00:00Z",
				"SECRET_TWO\t2020-12-04T00:00:00Z",
				"SECRET_THREE\t1975-11-30T00:00:00Z",
			},
		},
		{
+ 364 more lines · read full file
+ 3 more tests · open all in source
EXAMPLES
CONTRACT
command: gh secret list
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'List secrets for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_list.md:24Markdown · 7 words
TESTS
pkg/cmd/secret/list/list_test.go:28pkg/cmd/secret/list/list_test::Test_NewCmdList · Go · 94 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants ListOptions
	}{
		{
			name: "repo",
			cli:  "",
			wants: ListOptions{
				OrgName: "",
			},
		},
		{
			name: "org",
			cli:  "-oUmbrellaCorporation",
			wants: ListOptions{
				OrgName: "UmbrellaCorporation",
			},
		},
		{
			name: "env",
			cli:  "-eDevelopment",
			wants: ListOptions{
				EnvName: "Development",
			},
		},
		{
			name: "user",
			cli:  "-u",
+ 64 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret list
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'List secrets for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_list.md:25Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

CONTRACT
command: gh secret list
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'List secrets for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_list.md:26Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret list
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'List secrets for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_list.md:27Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret list
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'List secrets for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_list.md:28Markdown · 5 words
TESTS
pkg/cmd/secret/list/list_test.go:28pkg/cmd/secret/list/list_test::Test_NewCmdList · Go · 94 lines
func Test_NewCmdList(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants ListOptions
	}{
		{
			name: "repo",
			cli:  "",
			wants: ListOptions{
				OrgName: "",
			},
		},
		{
			name: "org",
			cli:  "-oUmbrellaCorporation",
			wants: ListOptions{
				OrgName: "UmbrellaCorporation",
			},
		},
		{
			name: "env",
			cli:  "-eDevelopment",
			wants: ListOptions{
				EnvName: "Development",
			},
		},
		{
			name: "user",
			cli:  "-u",
+ 64 more lines · read full file
EXAMPLES

N/A

CONTRACT
command: gh secret list
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'List secrets for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_list.md:29Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret list
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'List secrets for a specific application: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_list.md:30Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret set
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Set the application for a secret: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_set.md:1Markdown · 104 words
TESTS
pkg/cmd/secret/set/set_test.go:28pkg/cmd/secret/set/set_test::TestNewCmdSet · Go · 256 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name            string
		args            string
		wants           SetOptions
		stdinTTY        bool
		wantsErr        bool
		wantsErrMessage string
	}{
		{
			name:     "invalid visibility",
			args:     "cool_secret --org coolOrg -v mistyVeil",
			wantsErr: true,
		},
		{
			name:            "when visibility is selected, requires indication of repos",
			args:            "cool_secret --org coolOrg -v selected",
			wantsErr:        true,
			wantsErrMessage: "`--repos` or `--no-repos-selected` required with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --repos",
			args:            "cool_secret --org coolOrg -v private -r coolRepo",
			wantsErr:        true,
			wantsErrMessage: "`--repos` is only supported with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --no-repos-selected",
			args:            "cool_secret --org coolOrg -v private --no-repos-selected",
			wantsErr:        true,
+ 226 more lines · read full file
pkg/cmd/secret/set/set_test.go:285pkg/cmd/secret/set/set_test::TestNewCmdSetBaseRepoFuncs · Go · 134 lines
func TestNewCmdSetBaseRepoFuncs(t *testing.T) {
	multipleRemotes := ghContext.Remotes{
		&ghContext.Remote{
			Remote: &git.Remote{
				Name: "origin",
			},
			Repo: ghrepo.New("owner", "fork"),
		},
		&ghContext.Remote{
			Remote: &git.Remote{
				Name: "upstream",
			},
			Repo: ghrepo.New("owner", "repo"),
		},
	}

	singleRemote := ghContext.Remotes{
		&ghContext.Remote{
			Remote: &git.Remote{
				Name: "origin",
			},
			Repo: ghrepo.New("owner", "repo"),
		},
	}

	tests := []struct {
		name          string
		args          string
		env           map[string]string
		remotes       ghContext.Remotes
+ 104 more lines · read full file
pkg/cmd/secret/set/set_test.go:420pkg/cmd/secret/set/set_test::Test_setRun_repo · Go · 78 lines
func Test_setRun_repo(t *testing.T) {
	tests := []struct {
		name    string
		opts    *SetOptions
		wantApp string
	}{
		{
			name: "Actions",
			opts: &SetOptions{
				Application: "actions",
			},
			wantApp: "actions",
		},
		{
			name: "Agents",
			opts: &SetOptions{
				Application: "agents",
			},
			wantApp: "agents",
		},
		{
			name: "Dependabot",
			opts: &SetOptions{
				Application: "dependabot",
			},
			wantApp: "dependabot",
		},
		{
			name: "defaults to Actions",
			opts: &SetOptions{
+ 48 more lines · read full file
+ 7 more tests · open all in source
EXAMPLES
CONTRACT
command: gh secret set
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Set the application for a secret: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_set.md:29Markdown · 7 words
TESTS
pkg/cmd/secret/set/set_test.go:28pkg/cmd/secret/set/set_test::TestNewCmdSet · Go · 256 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name            string
		args            string
		wants           SetOptions
		stdinTTY        bool
		wantsErr        bool
		wantsErrMessage string
	}{
		{
			name:     "invalid visibility",
			args:     "cool_secret --org coolOrg -v mistyVeil",
			wantsErr: true,
		},
		{
			name:            "when visibility is selected, requires indication of repos",
			args:            "cool_secret --org coolOrg -v selected",
			wantsErr:        true,
			wantsErrMessage: "`--repos` or `--no-repos-selected` required with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --repos",
			args:            "cool_secret --org coolOrg -v private -r coolRepo",
			wantsErr:        true,
			wantsErrMessage: "`--repos` is only supported with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --no-repos-selected",
			args:            "cool_secret --org coolOrg -v private --no-repos-selected",
			wantsErr:        true,
+ 226 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh secret set
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Set the application for a secret: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_set.md:30Markdown · 12 words
TESTS
pkg/cmd/secret/set/set_test.go:28pkg/cmd/secret/set/set_test::TestNewCmdSet · Go · 256 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name            string
		args            string
		wants           SetOptions
		stdinTTY        bool
		wantsErr        bool
		wantsErrMessage string
	}{
		{
			name:     "invalid visibility",
			args:     "cool_secret --org coolOrg -v mistyVeil",
			wantsErr: true,
		},
		{
			name:            "when visibility is selected, requires indication of repos",
			args:            "cool_secret --org coolOrg -v selected",
			wantsErr:        true,
			wantsErrMessage: "`--repos` or `--no-repos-selected` required with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --repos",
			args:            "cool_secret --org coolOrg -v private -r coolRepo",
			wantsErr:        true,
			wantsErrMessage: "`--repos` is only supported with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --no-repos-selected",
			args:            "cool_secret --org coolOrg -v private --no-repos-selected",
			wantsErr:        true,
+ 226 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh secret set
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Set the application for a secret: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_set.md:31Markdown · 4 words
TESTS

N/A

EXAMPLES
CONTRACT
command: gh secret set
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Set the application for a secret: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_set.md:32Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret set
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Set the application for a secret: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_set.md:33Markdown · 7 words
TESTS
pkg/cmd/secret/set/set_test.go:28pkg/cmd/secret/set/set_test::TestNewCmdSet · Go · 256 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name            string
		args            string
		wants           SetOptions
		stdinTTY        bool
		wantsErr        bool
		wantsErrMessage string
	}{
		{
			name:     "invalid visibility",
			args:     "cool_secret --org coolOrg -v mistyVeil",
			wantsErr: true,
		},
		{
			name:            "when visibility is selected, requires indication of repos",
			args:            "cool_secret --org coolOrg -v selected",
			wantsErr:        true,
			wantsErrMessage: "`--repos` or `--no-repos-selected` required with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --repos",
			args:            "cool_secret --org coolOrg -v private -r coolRepo",
			wantsErr:        true,
			wantsErrMessage: "`--repos` is only supported with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --no-repos-selected",
			args:            "cool_secret --org coolOrg -v private --no-repos-selected",
			wantsErr:        true,
+ 226 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh secret set
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Set the application for a secret: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_set.md:34Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh secret set
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Set the application for a secret: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_set.md:35Markdown · 3 words
TESTS
pkg/cmd/secret/set/set_test.go:28pkg/cmd/secret/set/set_test::TestNewCmdSet · Go · 256 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name            string
		args            string
		wants           SetOptions
		stdinTTY        bool
		wantsErr        bool
		wantsErrMessage string
	}{
		{
			name:     "invalid visibility",
			args:     "cool_secret --org coolOrg -v mistyVeil",
			wantsErr: true,
		},
		{
			name:            "when visibility is selected, requires indication of repos",
			args:            "cool_secret --org coolOrg -v selected",
			wantsErr:        true,
			wantsErrMessage: "`--repos` or `--no-repos-selected` required with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --repos",
			args:            "cool_secret --org coolOrg -v private -r coolRepo",
			wantsErr:        true,
			wantsErrMessage: "`--repos` is only supported with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --no-repos-selected",
			args:            "cool_secret --org coolOrg -v private --no-repos-selected",
			wantsErr:        true,
+ 226 more lines · read full file
EXAMPLES
CONTRACT
command: gh secret set
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Set the application for a secret: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_set.md:36Markdown · 11 words
TESTS
pkg/cmd/secret/set/set_test.go:28pkg/cmd/secret/set/set_test::TestNewCmdSet · Go · 256 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name            string
		args            string
		wants           SetOptions
		stdinTTY        bool
		wantsErr        bool
		wantsErrMessage string
	}{
		{
			name:     "invalid visibility",
			args:     "cool_secret --org coolOrg -v mistyVeil",
			wantsErr: true,
		},
		{
			name:            "when visibility is selected, requires indication of repos",
			args:            "cool_secret --org coolOrg -v selected",
			wantsErr:        true,
			wantsErrMessage: "`--repos` or `--no-repos-selected` required with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --repos",
			args:            "cool_secret --org coolOrg -v private -r coolRepo",
			wantsErr:        true,
			wantsErrMessage: "`--repos` is only supported with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --no-repos-selected",
			args:            "cool_secret --org coolOrg -v private --no-repos-selected",
			wantsErr:        true,
+ 226 more lines · read full file
EXAMPLES
CONTRACT
command: gh secret set
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Set the application for a secret: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_set.md:37Markdown · 6 words
TESTS
pkg/cmd/secret/set/set_test.go:28pkg/cmd/secret/set/set_test::TestNewCmdSet · Go · 256 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name            string
		args            string
		wants           SetOptions
		stdinTTY        bool
		wantsErr        bool
		wantsErrMessage string
	}{
		{
			name:     "invalid visibility",
			args:     "cool_secret --org coolOrg -v mistyVeil",
			wantsErr: true,
		},
		{
			name:            "when visibility is selected, requires indication of repos",
			args:            "cool_secret --org coolOrg -v selected",
			wantsErr:        true,
			wantsErrMessage: "`--repos` or `--no-repos-selected` required with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --repos",
			args:            "cool_secret --org coolOrg -v private -r coolRepo",
			wantsErr:        true,
			wantsErrMessage: "`--repos` is only supported with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --no-repos-selected",
			args:            "cool_secret --org coolOrg -v private --no-repos-selected",
			wantsErr:        true,
+ 226 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh secret set
pname: gh secret
plink: gh_secret.yaml
options:
    - option: app
      shorthand: a
      value_type: string
      description: 'Set the application for a secret: {actions|agents|codespaces|dependabot}'
DOCS
gh_secret_set.md:38Markdown · 7 words
TESTS
pkg/cmd/secret/set/set_test.go:28pkg/cmd/secret/set/set_test::TestNewCmdSet · Go · 256 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name            string
		args            string
		wants           SetOptions
		stdinTTY        bool
		wantsErr        bool
		wantsErrMessage string
	}{
		{
			name:     "invalid visibility",
			args:     "cool_secret --org coolOrg -v mistyVeil",
			wantsErr: true,
		},
		{
			name:            "when visibility is selected, requires indication of repos",
			args:            "cool_secret --org coolOrg -v selected",
			wantsErr:        true,
			wantsErrMessage: "`--repos` or `--no-repos-selected` required with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --repos",
			args:            "cool_secret --org coolOrg -v private -r coolRepo",
			wantsErr:        true,
			wantsErrMessage: "`--repos` is only supported with `--visibility=selected`",
		},
		{
			name:            "visibilities other than selected do not accept --no-repos-selected",
			args:            "cool_secret --org coolOrg -v private --no-repos-selected",
			wantsErr:        true,
+ 226 more lines · read full file
EXAMPLES
CONTRACT
command: gh skill
short: Install and manage agent skills from GitHub repositories.
long: |-
    Working with agent skills in the GitHub CLI is in preview and
    subject to change without notice.
pname: gh
plink: gh.yaml
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill install
short: Install agent skills from a GitHub repository or local directory into
long: |-
    your local environment. Skills are placed in a host-specific directory
    at either project scope (inside the current git repository) or user
TESTS
pkg/cmd/skills/install/install_test.go:30pkg/cmd/skills/install/install_test::TestNewCmdInstall · Go · 172 lines
func TestNewCmdInstall(t *testing.T) {
	tests := []struct {
		name          string
		cli           string
		wantOpts      InstallOptions
		wantLocalPath bool
		wantErr       bool
	}{
		{
			name:     "repo argument only",
			cli:      "monalisa/skills-repo",
			wantOpts: InstallOptions{SkillSource: "monalisa/skills-repo", Scope: "project"},
		},
		{
			name:     "repo and skill",
			cli:      "monalisa/skills-repo git-commit",
			wantOpts: InstallOptions{SkillSource: "monalisa/skills-repo", SkillName: "git-commit", Scope: "project"},
		},
		{
			name: "all flags",
			cli:  "monalisa/skills-repo git-commit --agent github-copilot --scope user --pin v1.0.0 --force",
			wantOpts: InstallOptions{
				SkillSource: "monalisa/skills-repo",
				SkillName:   "git-commit",
				Agent:       "github-copilot",
				Scope:       "user",
				Pin:         "v1.0.0",
				Force:       true,
			},
		},
+ 142 more lines · read full file
pkg/cmd/skills/install/install_test.go:186pkg/cmd/skills/install/install_test::command metadata · Go · 15 lines
t.Run("command metadata", func(t *testing.T) {
	ios, _, _, _ := iostreams.Test()
	f := &cmdutil.Factory{IOStreams: ios, Prompter: &prompter.PrompterMock{}, GitClient: &git.Client{}}
	cmd := NewCmdInstall(f, &telemetry.NoOpService{}, nil)

	assert.Equal(t, "install <repository> [<skill[@version]>] [flags]", cmd.Use)
	assert.NotEmpty(t, cmd.Short)
	assert.NotEmpty(t, cmd.Long)
	assert.NotEmpty(t, cmd.Example)
	assert.Contains(t, cmd.Aliases, "add")

	for _, flag := range []string{"agent", "scope", "pin", "dir", "force"} {
		assert.NotNil(t, cmd.Flags().Lookup(flag), "missing flag: --%s", flag)
	}
})
pkg/cmd/skills/install/install_test.go:284pkg/cmd/skills/install/install_test::TestInstallRun · Go · 1247 lines
func TestInstallRun(t *testing.T) {
	tests := []struct {
		name       string
		isTTY      bool
		setup      func(t *testing.T)
		stubs      func(*httpmock.Registry)
		opts       func(ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions
		verify     func(t *testing.T)
		wantErr    string
		wantStdout string
		wantStderr string
	}{
		{
			name:  "non-interactive without repo errors",
			isTTY: false,
			opts: func(ios *iostreams.IOStreams, _ *httpmock.Registry) *InstallOptions {
				t.Helper()
				return &InstallOptions{
					IO:        ios,
					GitClient: &git.Client{RepoDir: t.TempDir()},
				}
			},
			wantErr: "must specify a repository to install from",
		},
		{
			name:  "non-interactive without skill name errors",
			isTTY: false,
			stubs: func(reg *httpmock.Registry) {
				stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123")
				stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123",
+ 1217 more lines · read full file
+ 11 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh skill install
short: Install agent skills from a GitHub repository or local directory into
long: |-
    your local environment. Skills are placed in a host-specific directory
    at either project scope (inside the current git repository) or user
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill install
short: Install agent skills from a GitHub repository or local directory into
long: |-
    your local environment. Skills are placed in a host-specific directory
    at either project scope (inside the current git repository) or user
DOCS
gh_skill_install.md:122Markdown · 8 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill install
short: Install agent skills from a GitHub repository or local directory into
long: |-
    your local environment. Skills are placed in a host-specific directory
    at either project scope (inside the current git repository) or user
DOCS
gh_skill_install.md:123Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh skill install
short: Install agent skills from a GitHub repository or local directory into
long: |-
    your local environment. Skills are placed in a host-specific directory
    at either project scope (inside the current git repository) or user
DOCS
gh_skill_install.md:124Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh skill install
short: Install agent skills from a GitHub repository or local directory into
long: |-
    your local environment. Skills are placed in a host-specific directory
    at either project scope (inside the current git repository) or user
DOCS
gh_skill_install.md:125Markdown · 12 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill install
short: Install agent skills from a GitHub repository or local directory into
long: |-
    your local environment. Skills are placed in a host-specific directory
    at either project scope (inside the current git repository) or user
DOCS
gh_skill_install.md:126Markdown · 9 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill install
short: Install agent skills from a GitHub repository or local directory into
long: |-
    your local environment. Skills are placed in a host-specific directory
    at either project scope (inside the current git repository) or user
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill install
short: Install agent skills from a GitHub repository or local directory into
long: |-
    your local environment. Skills are placed in a host-specific directory
    at either project scope (inside the current git repository) or user
DOCS
gh_skill_install.md:128Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh skill preview
short: Render a skill's `SKILL.md` content in the terminal. This fetches the
long: |-
    skill file from the repository and displays it using the configured
    pager, without installing anything.

    A file tree is shown first, followed by the rendered `SKILL.md` content.
    When running interactively and the skill contains additional files
    (scripts, references, etc.), a file picker lets you browse them
DOCS
gh_skill_preview.md:1Markdown · 115 words
TESTS
pkg/cmd/skills/preview/preview_test.go:24pkg/cmd/skills/preview/preview_test::TestNewCmdPreview · Go · 87 lines
func TestNewCmdPreview(t *testing.T) {
	tests := []struct {
		name                string
		input               string
		wantRepo            string
		wantSkillName       string
		wantVersion         string
		wantAllowHiddenDirs bool
		wantErr             bool
	}{
		{
			name:          "repo and skill",
			input:         "github/awesome-copilot my-skill",
			wantRepo:      "github/awesome-copilot",
			wantSkillName: "my-skill",
		},
		{
			name:          "repo and skill with version",
			input:         "github/awesome-copilot my-skill@v1.2.0",
			wantRepo:      "github/awesome-copilot",
			wantSkillName: "my-skill",
			wantVersion:   "v1.2.0",
		},
		{
			name:          "repo and skill with SHA",
			input:         "github/awesome-copilot my-skill@abc123def456",
			wantRepo:      "github/awesome-copilot",
			wantSkillName: "my-skill",
			wantVersion:   "abc123def456",
		},
+ 57 more lines · read full file
pkg/cmd/skills/preview/preview_test.go:112pkg/cmd/skills/preview/preview_test::TestPreviewRun · Go · 295 lines
func TestPreviewRun(t *testing.T) {
	skillContent := heredoc.Doc(`
		---
		name: my-skill
		description: A test skill
		---
		# My Skill

		This is the skill content.
	`)
	encodedContent := base64.StdEncoding.EncodeToString([]byte(skillContent))

	tests := []struct {
		name       string
		opts       *PreviewOptions
		tty        bool
		httpStubs  func(*httpmock.Registry)
		wantStdout string
		wantErr    string
	}{
		{
			name: "preview specific skill",
			tty:  true,
			opts: &PreviewOptions{
				repo:      ghrepo.New("github", "awesome-copilot"),
				SkillName: "my-skill",
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "repos/github/awesome-copilot/releases/latest"),
+ 265 more lines · read full file
pkg/cmd/skills/preview/preview_test.go:408pkg/cmd/skills/preview/preview_test::TestPreviewRun_UnsupportedHost · Go · 10 lines
func TestPreviewRun_UnsupportedHost(t *testing.T) {
	ios, _, _, _ := iostreams.Test()
	err := previewRun(&PreviewOptions{
		IO:         ios,
		HttpClient: func() (*http.Client, error) { return &http.Client{}, nil },
		repo:       ghrepo.NewWithHost("github", "awesome-copilot", "acme.ghes.com"),
		Telemetry:  &telemetry.NoOpService{},
	})
	require.ErrorContains(t, err, "does not currently support GitHub Enterprise Server")
}
+ 16 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh skill preview
short: Render a skill's `SKILL.md` content in the terminal. This fetches the
long: |-
    skill file from the repository and displays it using the configured
    pager, without installing anything.

    A file tree is shown first, followed by the rendered `SKILL.md` content.
    When running interactively and the skill contains additional files
    (scripts, references, etc.), a file picker lets you browse them
DOCS
gh_skill_preview.md:33Markdown · 8 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh skill publish
short: Validate a local repository's skills against the Agent Skills specification
long: and publish them by creating a GitHub release.
pname: gh skill
plink: gh_skill.yaml
options:
    - option: dry-run
      value_type: bool
      default_value: "false"
      description: Validate without publishing
    - option: fix
      value_type: bool
DOCS
gh_skill_publish.md:1Markdown · 158 words
TESTS
pkg/cmd/skills/publish/publish_test.go:81pkg/cmd/skills/publish/publish_test::TestNewCmdPublish · Go · 70 lines
func TestNewCmdPublish(t *testing.T) {
	tests := []struct {
		name      string
		cli       string
		wantsErr  bool
		wantsOpts PublishOptions
	}{
		{
			name:     "fix and dry-run are mutually exclusive",
			cli:      "./monalisa-skills --dry-run --fix --tag v1.0.0",
			wantsErr: true,
		},
		{
			name: "fix flag only",
			cli:  "--fix",
			wantsOpts: PublishOptions{
				Fix: true,
			},
		},
		{
			name: "directory only",
			cli:  "./octocat-repo",
			wantsOpts: PublishOptions{
				Dir: "./octocat-repo",
			},
		},
		{
			name:      "no args leaves dir empty",
			cli:       "",
			wantsOpts: PublishOptions{},
+ 40 more lines · read full file
pkg/cmd/skills/publish/publish_test.go:152pkg/cmd/skills/publish/publish_test::TestPublishRun_UnsupportedHost · Go · 24 lines
func TestPublishRun_UnsupportedHost(t *testing.T) {
	dir := t.TempDir()
	writeSkill(t, dir, "test-skill", heredoc.Doc(`
		---
		name: test-skill
		description: A test skill
		---
		Body.
	`))

	cs, cmdTeardown := run.Stub()
	defer cmdTeardown(t)
	stubGitRemote(cs, map[string]string{"origin": "https://github.com/monalisa/skills-repo.git"})

	ios, _, _, _ := iostreams.Test()
	err := publishRun(&PublishOptions{
		IO:         ios,
		Dir:        dir,
		GitClient:  newTestGitClient(),
		HttpClient: func() (*http.Client, error) { return nil, nil },
		host:       "acme.ghes.com",
	})
	require.ErrorContains(t, err, "does not currently support GitHub Enterprise Server")
}
pkg/cmd/skills/publish/publish_test.go:177pkg/cmd/skills/publish/publish_test::TestPublishRun · Go · 1356 lines
func TestPublishRun(t *testing.T) {
	tests := []struct {
		name       string
		isTTY      bool
		setup      func(t *testing.T, dir string)
		stubs      func(*httpmock.Registry)
		cmdStubs   func(*run.CommandStubber)
		opts       func(ios *iostreams.IOStreams, dir string, reg *httpmock.Registry) *PublishOptions
		verify     func(t *testing.T, dir string)
		wantErr    string
		wantStdout string
		wantStderr string
	}{
		{
			name:  "no skills found",
			setup: func(_ *testing.T, _ string) {},
			opts: func(ios *iostreams.IOStreams, dir string, _ *httpmock.Registry) *PublishOptions {
				t.Helper()
				return &PublishOptions{IO: ios, Dir: dir}
			},
			wantErr: "no skills found",
		},
		{
			name: "empty skills directory has no discoverable skills",
			setup: func(t *testing.T, dir string) {
				t.Helper()
				require.NoError(t, os.MkdirAll(filepath.Join(dir, "skills", "empty-skill"), 0o755))
			},
			opts: func(ios *iostreams.IOStreams, dir string, _ *httpmock.Registry) *PublishOptions {
				t.Helper()
+ 1326 more lines · read full file
+ 3 more tests · open all in source
WORKFLOWS

N/A

CONTRACT
command: gh skill publish
short: Validate a local repository's skills against the Agent Skills specification
long: and publish them by creating a GitHub release.
pname: gh skill
plink: gh_skill.yaml
options:
    - option: dry-run
      value_type: bool
      default_value: "false"
      description: Validate without publishing
    - option: fix
      value_type: bool
DOCS
gh_skill_publish.md:47Markdown · 3 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill publish
short: Validate a local repository's skills against the Agent Skills specification
long: and publish them by creating a GitHub release.
pname: gh skill
plink: gh_skill.yaml
options:
    - option: dry-run
      value_type: bool
      default_value: "false"
      description: Validate without publishing
    - option: fix
      value_type: bool
DOCS
gh_skill_publish.md:48Markdown · 10 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill publish
short: Validate a local repository's skills against the Agent Skills specification
long: and publish them by creating a GitHub release.
pname: gh skill
plink: gh_skill.yaml
options:
    - option: dry-run
      value_type: bool
      default_value: "false"
      description: Validate without publishing
    - option: fix
      value_type: bool
DOCS
gh_skill_publish.md:49Markdown · 7 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill search
short: Search across all public GitHub repositories for skills matching a keyword.
long: |-
    Uses the GitHub Code Search API to find `SKILL.md` files whose name or
    description matches the query term.

    Results are ranked by relevance: skills whose name contains the query
    term appear first.

    Use `--owner` to scope results to a specific GitHub user or organization.

    In interactive mode, you can select skills from the results to install directly.
DOCS
gh_skill_search.md:1Markdown · 86 words
TESTS
pkg/cmd/skills/search/search_test.go:20pkg/cmd/skills/search/search_test::TestSearchRun_UnsupportedHost · Go · 18 lines
func TestSearchRun_UnsupportedHost(t *testing.T) {
	ios, _, _, _ := iostreams.Test()
	cfg := config.NewBlankConfig()
	authCfg := cfg.Authentication()
	authCfg.SetDefaultHost("acme.ghes.com", "user")
	cfg.AuthenticationFunc = func() gh.AuthConfig {
		return authCfg
	}
	err := searchRun(&SearchOptions{
		IO:         ios,
		Query:      "terraform",
		Page:       1,
		Limit:      defaultLimit,
		HttpClient: func() (*http.Client, error) { return &http.Client{}, nil },
		Config:     func() (gh.Config, error) { return cfg, nil },
	})
	require.ErrorContains(t, err, "does not currently support GitHub Enterprise Server")
}
pkg/cmd/skills/search/search_test.go:39pkg/cmd/skills/search/search_test::TestNewCmdSearch · Go · 96 lines
func TestNewCmdSearch(t *testing.T) {
	tests := []struct {
		name     string
		args     string
		wantOpts SearchOptions
		wantErr  string
	}{
		{
			name:     "query argument",
			args:     "terraform",
			wantOpts: SearchOptions{Query: "terraform", Page: 1, Limit: defaultLimit},
		},
		{
			name:     "with page flag",
			args:     "terraform --page 3",
			wantOpts: SearchOptions{Query: "terraform", Page: 3, Limit: defaultLimit},
		},
		{
			name:     "with limit flag",
			args:     "terraform --limit 5",
			wantOpts: SearchOptions{Query: "terraform", Page: 1, Limit: 5},
		},
		{
			name:     "with limit short flag",
			args:     "terraform -L 10",
			wantOpts: SearchOptions{Query: "terraform", Page: 1, Limit: 10},
		},
		{
			name:     "with owner flag",
			args:     "terraform --owner hashicorp",
+ 66 more lines · read full file
pkg/cmd/skills/search/search_test.go:136pkg/cmd/skills/search/search_test::TestSearchRun · Go · 258 lines
func TestSearchRun(t *testing.T) {
	const emptyCodeResponse = `{"total_count": 0, "incomplete_results": false, "items": []}`

	// stubKeywordSearch registers the HTTP stubs needed for a keyword search.
	// searchByKeyword fires up to 3 concurrent search/code requests (path,
	// owner, primary). Stubs are one-shot in httpmock, so we register one
	// per request.
	stubKeywordSearch := func(reg *httpmock.Registry, codeResponse string) {
		for range 3 {
			reg.Register(
				httpmock.REST("GET", "search/code"),
				httpmock.StringResponse(codeResponse),
			)
		}
	}

	tests := []struct {
		name       string
		opts       *SearchOptions
		tty        bool
		httpStubs  func(*httpmock.Registry)
		wantStdout string
		wantStderr string
		wantErr    string
	}{
		{
			name: "displays results in non-TTY",
			tty:  false,
			opts: &SearchOptions{Query: "terraform", Page: 1, Limit: defaultLimit},
			httpStubs: func(reg *httpmock.Registry) {
+ 228 more lines · read full file
+ 10 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill search
short: Search across all public GitHub repositories for skills matching a keyword.
long: |-
    Uses the GitHub Code Search API to find `SKILL.md` files whose name or
    description matches the query term.

    Results are ranked by relevance: skills whose name contains the query
    term appear first.

    Use `--owner` to scope results to a specific GitHub user or organization.

    In interactive mode, you can select skills from the results to install directly.
DOCS
gh_skill_search.md:30Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh skill search
short: Search across all public GitHub repositories for skills matching a keyword.
long: |-
    Uses the GitHub Code Search API to find `SKILL.md` files whose name or
    description matches the query term.

    Results are ranked by relevance: skills whose name contains the query
    term appear first.

    Use `--owner` to scope results to a specific GitHub user or organization.

    In interactive mode, you can select skills from the results to install directly.
DOCS
gh_skill_search.md:31Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh skill search
short: Search across all public GitHub repositories for skills matching a keyword.
long: |-
    Uses the GitHub Code Search API to find `SKILL.md` files whose name or
    description matches the query term.

    Results are ranked by relevance: skills whose name contains the query
    term appear first.

    Use `--owner` to scope results to a specific GitHub user or organization.

    In interactive mode, you can select skills from the results to install directly.
DOCS
gh_skill_search.md:32Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill search
short: Search across all public GitHub repositories for skills matching a keyword.
long: |-
    Uses the GitHub Code Search API to find `SKILL.md` files whose name or
    description matches the query term.

    Results are ranked by relevance: skills whose name contains the query
    term appear first.

    Use `--owner` to scope results to a specific GitHub user or organization.

    In interactive mode, you can select skills from the results to install directly.
DOCS
gh_skill_search.md:33Markdown · 9 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill search
short: Search across all public GitHub repositories for skills matching a keyword.
long: |-
    Uses the GitHub Code Search API to find `SKILL.md` files whose name or
    description matches the query term.

    Results are ranked by relevance: skills whose name contains the query
    term appear first.

    Use `--owner` to scope results to a specific GitHub user or organization.

    In interactive mode, you can select skills from the results to install directly.
DOCS
gh_skill_search.md:34Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill search
short: Search across all public GitHub repositories for skills matching a keyword.
long: |-
    Uses the GitHub Code Search API to find `SKILL.md` files whose name or
    description matches the query term.

    Results are ranked by relevance: skills whose name contains the query
    term appear first.

    Use `--owner` to scope results to a specific GitHub user or organization.

    In interactive mode, you can select skills from the results to install directly.
DOCS
gh_skill_search.md:35Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh skill update
short: Checks installed skills for available updates by comparing the local
long: |-
    tree SHA (from `SKILL.md` frontmatter) against the remote repository.
DOCS
gh_skill_update.md:1Markdown · 179 words
TESTS
pkg/cmd/skills/update/update_test.go:25pkg/cmd/skills/update/update_test::TestNewCmdUpdate_Help · Go · 17 lines
func TestNewCmdUpdate_Help(t *testing.T) {
	ios, _, _, _ := iostreams.Test()
	f := &cmdutil.Factory{
		IOStreams: ios,
		Prompter:  &prompter.PrompterMock{},
		GitClient: &git.Client{},
	}

	cmd := NewCmdUpdate(f, func(opts *UpdateOptions) error {
		return nil
	})

	assert.Equal(t, "update [<skill>...] [flags]", cmd.Use)
	assert.NotEmpty(t, cmd.Short)
	assert.NotEmpty(t, cmd.Long)
	assert.NotEmpty(t, cmd.Example)
}
pkg/cmd/skills/update/update_test.go:43pkg/cmd/skills/update/update_test::TestNewCmdUpdate_Flags · Go · 10 lines
func TestNewCmdUpdate_Flags(t *testing.T) {
	ios, _, _, _ := iostreams.Test()
	f := &cmdutil.Factory{IOStreams: ios, Prompter: &prompter.PrompterMock{}, GitClient: &git.Client{}}
	cmd := NewCmdUpdate(f, func(_ *UpdateOptions) error { return nil })

	flags := []string{"all", "force", "dry-run", "dir", "unpin"}
	for _, name := range flags {
		assert.NotNil(t, cmd.Flags().Lookup(name), "missing flag: --%s", name)
	}
}
pkg/cmd/skills/update/update_test.go:54pkg/cmd/skills/update/update_test::TestNewCmdUpdate_ArgsPassedToOptions · Go · 20 lines
func TestNewCmdUpdate_ArgsPassedToOptions(t *testing.T) {
	ios, _, stdout, stderr := iostreams.Test()
	f := &cmdutil.Factory{IOStreams: ios, Prompter: &prompter.PrompterMock{}, GitClient: &git.Client{}}

	var gotOpts *UpdateOptions
	cmd := NewCmdUpdate(f, func(opts *UpdateOptions) error {
		gotOpts = opts
		return nil
	})

	args, _ := shlex.Split("mcp-cli git-commit --all --force")
	cmd.SetArgs(args)
	cmd.SetOut(stdout)
	cmd.SetErr(stderr)
	err := cmd.Execute()
	require.NoError(t, err)
	assert.Equal(t, []string{"mcp-cli", "git-commit"}, gotOpts.Skills)
	assert.True(t, gotOpts.All)
	assert.True(t, gotOpts.Force)
}
+ 4 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill update
short: Checks installed skills for available updates by comparing the local
long: |-
    tree SHA (from `SKILL.md` frontmatter) against the remote repository.
DOCS
gh_skill_update.md:44Markdown · 5 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill update
short: Checks installed skills for available updates by comparing the local
long: |-
    tree SHA (from `SKILL.md` frontmatter) against the remote repository.
DOCS
gh_skill_update.md:45Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh skill update
short: Checks installed skills for available updates by comparing the local
long: |-
    tree SHA (from `SKILL.md` frontmatter) against the remote repository.
DOCS
gh_skill_update.md:46Markdown · 6 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill update
short: Checks installed skills for available updates by comparing the local
long: |-
    tree SHA (from `SKILL.md` frontmatter) against the remote repository.
DOCS
gh_skill_update.md:47Markdown · 7 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh skill update
short: Checks installed skills for available updates by comparing the local
long: |-
    tree SHA (from `SKILL.md` frontmatter) against the remote repository.
DOCS
gh_skill_update.md:48Markdown · 9 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh ssh-key
short: Manage SSH keys registered with your GitHub account.
pname: gh
plink: gh.yaml
DOCS
gh_ssh-key.md:1Markdown · 28 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh ssh-key add
short: Add an SSH key to your GitHub account
pname: gh ssh-key
plink: gh_ssh-key.yaml
options:
    - option: title
      shorthand: t
      value_type: string
      description: Title for the new key
    - option: type
      value_type: string
      description: 'Type of the ssh key: {authentication|signing} (default "authentication")'
DOCS
gh_ssh-key_add.md:1Markdown · 17 words
TESTS
pkg/cmd/ssh-key/add/add_test.go:14pkg/cmd/ssh-key/add/add_test::Test_runAdd · Go · 138 lines
func Test_runAdd(t *testing.T) {
	tests := []struct {
		name       string
		stdin      string
		opts       AddOptions
		httpStubs  func(*httpmock.Registry)
		wantStdout string
		wantStderr string
		wantErrMsg string
	}{
		{
			name:  "valid key format, not already in use",
			stdin: "ssh-ed25519 asdf",
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "user/keys"),
					httpmock.StringResponse("[]"))
				reg.Register(
					httpmock.REST("POST", "user/keys"),
					httpmock.RESTPayload(200, ``, func(payload map[string]interface{}) {
						assert.Contains(t, payload, "key")
						assert.Empty(t, payload["title"])
					}))
			},
			wantStdout: "",
			wantStderr: "✓ Public key added to your account\n",
			wantErrMsg: "",
			opts:       AddOptions{KeyFile: "-"},
		},
		{
+ 108 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh ssh-key add
short: Add an SSH key to your GitHub account
pname: gh ssh-key
plink: gh_ssh-key.yaml
options:
    - option: title
      shorthand: t
      value_type: string
      description: Title for the new key
    - option: type
      value_type: string
      description: 'Type of the ssh key: {authentication|signing} (default "authentication")'
DOCS
gh_ssh-key_add.md:19Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh ssh-key add
short: Add an SSH key to your GitHub account
pname: gh ssh-key
plink: gh_ssh-key.yaml
options:
    - option: title
      shorthand: t
      value_type: string
      description: Title for the new key
    - option: type
      value_type: string
      description: 'Type of the ssh key: {authentication|signing} (default "authentication")'
DOCS
gh_ssh-key_add.md:20Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh ssh-key delete
short: Delete an SSH key from your GitHub account
pname: gh ssh-key
plink: gh_ssh-key.yaml
options:
    - option: "yes"
      shorthand: "y"
      value_type: bool
      default_value: "false"
      description: Skip the confirmation prompt
DOCS
gh_ssh-key_delete.md:1Markdown · 17 words
TESTS
pkg/cmd/ssh-key/delete/delete_test.go:18pkg/cmd/ssh-key/delete/delete_test::TestNewCmdDelete · Go · 90 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		input      string
		output     DeleteOptions
		wantErr    bool
		wantErrMsg string
	}{
		{
			name:   "tty",
			tty:    true,
			input:  "123",
			output: DeleteOptions{KeyID: "123", Confirmed: false},
		},
		{
			name:   "confirm flag tty",
			tty:    true,
			input:  "123 --yes",
			output: DeleteOptions{KeyID: "123", Confirmed: true},
		},
		{
			name:   "shorthand confirm flag tty",
			tty:    true,
			input:  "123 -y",
			output: DeleteOptions{KeyID: "123", Confirmed: true},
		},
		{
			name:       "no tty",
			input:      "123",
+ 60 more lines · read full file
pkg/cmd/ssh-key/delete/delete_test.go:109pkg/cmd/ssh-key/delete/delete_test::Test_deleteRun · Go · 103 lines
func Test_deleteRun(t *testing.T) {
	keyResp := "{\"title\":\"My Key\"}"
	tests := []struct {
		name          string
		tty           bool
		opts          DeleteOptions
		httpStubs     func(*httpmock.Registry)
		prompterStubs func(*prompter.PrompterMock)
		wantStdout    string
		wantErr       bool
		wantErrMsg    string
	}{
		{
			name: "delete tty",
			tty:  true,
			opts: DeleteOptions{KeyID: "123"},
			prompterStubs: func(pm *prompter.PrompterMock) {
				pm.ConfirmDeletionFunc = func(_ string) error {
					return nil
				}
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.REST("GET", "user/keys/123"), httpmock.StatusStringResponse(200, keyResp))
				reg.Register(httpmock.REST("DELETE", "user/keys/123"), httpmock.StatusStringResponse(204, ""))
			},
			wantStdout: "✓ SSH key \"My Key\" (123) deleted from your account\n",
		},
		{
			name: "delete with confirm flag tty",
			tty:  true,
+ 73 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh ssh-key delete
short: Delete an SSH key from your GitHub account
pname: gh ssh-key
plink: gh_ssh-key.yaml
options:
    - option: "yes"
      shorthand: "y"
      value_type: bool
      default_value: "false"
      description: Skip the confirmation prompt
DOCS
gh_ssh-key_delete.md:19Markdown · 4 words
TESTS
pkg/cmd/ssh-key/delete/delete_test.go:18pkg/cmd/ssh-key/delete/delete_test::TestNewCmdDelete · Go · 90 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		input      string
		output     DeleteOptions
		wantErr    bool
		wantErrMsg string
	}{
		{
			name:   "tty",
			tty:    true,
			input:  "123",
			output: DeleteOptions{KeyID: "123", Confirmed: false},
		},
		{
			name:   "confirm flag tty",
			tty:    true,
			input:  "123 --yes",
			output: DeleteOptions{KeyID: "123", Confirmed: true},
		},
		{
			name:   "shorthand confirm flag tty",
			tty:    true,
			input:  "123 -y",
			output: DeleteOptions{KeyID: "123", Confirmed: true},
		},
		{
			name:       "no tty",
			input:      "123",
+ 60 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh ssh-key list
short: Lists SSH keys in your GitHub account
pname: gh ssh-key
plink: gh_ssh-key.yaml
DOCS
gh_ssh-key_list.md:1Markdown · 19 words
TESTS
pkg/cmd/ssh-key/list/list_test.go:16pkg/cmd/ssh-key/list/list_test::TestListRun · Go · 238 lines
func TestListRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       ListOptions
		isTTY      bool
		wantStdout string
		wantStderr string
		wantErr    bool
	}{
		{
			name: "list authentication and signing keys; in tty",
			opts: ListOptions{
				HTTPClient: func() (*http.Client, error) {
					createdAt := time.Now().Add(time.Duration(-24) * time.Hour)
					reg := &httpmock.Registry{}
					reg.Register(
						httpmock.REST("GET", "user/keys"),
						httpmock.StringResponse(fmt.Sprintf(`[
							{
								"id": 1234,
								"key": "ssh-rsa AAAABbBB123",
								"title": "Mac",
								"created_at": "%[1]s"
							},
							{
								"id": 5678,
								"key": "ssh-rsa EEEEEEEK247",
								"title": "hubot@Windows",
								"created_at": "%[1]s"
							}
+ 208 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh status
pname: gh
plink: gh.yaml
options:
    - option: exclude
      shorthand: e
      value_type: stringSlice
      description: Comma separated list of repos to exclude in owner/name format
    - option: org
      shorthand: o
      value_type: string
      description: Report status within an organization
DOCS
gh_status.md:1Markdown · 45 words
TESTS
pkg/cmd/auth/status/status_test.go:24pkg/cmd/auth/status/status_test::Test_NewCmdStatus · Go · 64 lines
func Test_NewCmdStatus(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants StatusOptions
	}{
		{
			name:  "no arguments",
			cli:   "",
			wants: StatusOptions{},
		},
		{
			name: "hostname set",
			cli:  "--hostname ellie.williams",
			wants: StatusOptions{
				Hostname: "ellie.williams",
			},
		},
		{
			name: "show token",
			cli:  "--show-token",
			wants: StatusOptions{
				ShowToken: true,
			},
		},
		{
			name: "active",
			cli:  "--active",
			wants: StatusOptions{
				Active: true,
+ 34 more lines · read full file
pkg/cmd/auth/status/status_test.go:89pkg/cmd/auth/status/status_test::TestJSONFields · Go · 5 lines
func TestJSONFields(t *testing.T) {
	jsonfieldstest.ExpectCommandToSupportJSONFields(t, NewCmdStatus, []string{
		"hosts",
	})
}
pkg/cmd/auth/status/status_test.go:95pkg/cmd/auth/status/status_test::Test_statusRun · Go · 668 lines
func Test_statusRun(t *testing.T) {
	tests := []struct {
		name       string
		opts       StatusOptions
		jsonFields []string
		env        map[string]string
		httpStubs  func(*httpmock.Registry)
		cfgStubs   func(*testing.T, gh.Config)
		wantErr    error
		wantOut    string
		wantErrOut string
	}{
		{
			name: "timeout error",
			opts: StatusOptions{
				Hostname: "github.com",
			},
			cfgStubs: func(t *testing.T, c gh.Config) {
				login(t, c, "github.com", "monalisa", "abc123", "https")
			},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.REST("GET", ""), func(req *http.Request) (*http.Response, error) {
					// timeout error
					return nil, context.DeadlineExceeded
				})
			},
			wantErr: cmdutil.SilentError,
			wantErrOut: heredoc.Doc(`
				github.com
				  X Timeout trying to log in to github.com account monalisa (GH_CONFIG_DIR/hosts.yml)
+ 638 more lines · read full file
+ 19 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh status
pname: gh
plink: gh.yaml
options:
    - option: exclude
      shorthand: e
      value_type: stringSlice
      description: Comma separated list of repos to exclude in owner/name format
    - option: org
      shorthand: o
      value_type: string
      description: Report status within an organization
DOCS
gh_status.md:26Markdown · 10 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh status
pname: gh
plink: gh.yaml
options:
    - option: exclude
      shorthand: e
      value_type: stringSlice
      description: Comma separated list of repos to exclude in owner/name format
    - option: org
      shorthand: o
      value_type: string
      description: Report status within an organization
DOCS
gh_status.md:27Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable
short: Variables can be set at the repository, environment or organization level for use in
long: GitHub Actions or Dependabot. Run `gh help variable set` to learn how to get started.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_variable.md:1Markdown · 54 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable
short: Variables can be set at the repository, environment or organization level for use in
long: GitHub Actions or Dependabot. Run `gh help variable set` to learn how to get started.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_variable.md:25Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable delete
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: Delete a variable for an environment
    - option: org
      shorthand: o
      value_type: string
      description: Delete a variable for an organization
DOCS
gh_variable_delete.md:1Markdown · 66 words
TESTS
pkg/cmd/variable/delete/delete_test.go:19pkg/cmd/variable/delete/delete_test::TestNewCmdDelete · Go · 69 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    DeleteOptions
		wantsErr bool
	}{
		{
			name:     "no args",
			wantsErr: true,
		},
		{
			name: "repo",
			cli:  "cool",
			wants: DeleteOptions{
				VariableName: "cool",
			},
		},
		{
			name: "org",
			cli:  "cool --org anOrg",
			wants: DeleteOptions{
				VariableName: "cool",
				OrgName:      "anOrg",
			},
		},
		{
			name: "env",
			cli:  "cool --env anEnv",
			wants: DeleteOptions{
+ 39 more lines · read full file
pkg/cmd/variable/delete/delete_test.go:89pkg/cmd/variable/delete/delete_test::TestRemoveRun · Go · 90 lines
func TestRemoveRun(t *testing.T) {
	tests := []struct {
		name      string
		opts      *DeleteOptions
		host      string
		httpStubs func(*httpmock.Registry)
	}{
		{
			name: "repo",
			opts: &DeleteOptions{
				VariableName: "cool_variable",
			},
			host: "github.com",
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.WithHost(httpmock.REST("DELETE", "repos/owner/repo/actions/variables/cool_variable"), "api.github.com"),
					httpmock.StatusStringResponse(204, "No Content"))
			},
		},
		{
			name: "repo GHES",
			opts: &DeleteOptions{
				VariableName: "cool_variable",
			},
			host: "example.com",
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.WithHost(httpmock.REST("DELETE", "api/v3/repos/owner/repo/actions/variables/cool_variable"), "example.com"),
					httpmock.StatusStringResponse(204, "No Content"))
			},
		},
		{
+ 60 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh variable delete
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: Delete a variable for an environment
    - option: org
      shorthand: o
      value_type: string
      description: Delete a variable for an organization
DOCS
gh_variable_delete.md:23Markdown · 6 words
TESTS
pkg/cmd/variable/delete/delete_test.go:19pkg/cmd/variable/delete/delete_test::TestNewCmdDelete · Go · 69 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    DeleteOptions
		wantsErr bool
	}{
		{
			name:     "no args",
			wantsErr: true,
		},
		{
			name: "repo",
			cli:  "cool",
			wants: DeleteOptions{
				VariableName: "cool",
			},
		},
		{
			name: "org",
			cli:  "cool --org anOrg",
			wants: DeleteOptions{
				VariableName: "cool",
				OrgName:      "anOrg",
			},
		},
		{
			name: "env",
			cli:  "cool --env anEnv",
			wants: DeleteOptions{
+ 39 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable delete
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: Delete a variable for an environment
    - option: org
      shorthand: o
      value_type: string
      description: Delete a variable for an organization
DOCS
gh_variable_delete.md:24Markdown · 6 words
TESTS
pkg/cmd/variable/delete/delete_test.go:19pkg/cmd/variable/delete/delete_test::TestNewCmdDelete · Go · 69 lines
func TestNewCmdDelete(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    DeleteOptions
		wantsErr bool
	}{
		{
			name:     "no args",
			wantsErr: true,
		},
		{
			name: "repo",
			cli:  "cool",
			wants: DeleteOptions{
				VariableName: "cool",
			},
		},
		{
			name: "org",
			cli:  "cool --org anOrg",
			wants: DeleteOptions{
				VariableName: "cool",
				OrgName:      "anOrg",
			},
		},
		{
			name: "env",
			cli:  "cool --env anEnv",
			wants: DeleteOptions{
+ 39 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable get
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: Get a variable for an environment
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
DOCS
gh_variable_get.md:1Markdown · 71 words
TESTS
pkg/cmd/variable/get/get_test.go:22pkg/cmd/variable/get/get_test::TestNewCmdGet · Go · 84 lines
func TestNewCmdGet(t *testing.T) {
	tests := []struct {
		name    string
		cli     string
		wants   GetOptions
		wantErr error
	}{
		{
			name: "repo",
			cli:  "FOO",
			wants: GetOptions{
				OrgName:      "",
				VariableName: "FOO",
			},
		},
		{
			name: "org",
			cli:  "-o TestOrg BAR",
			wants: GetOptions{
				OrgName:      "TestOrg",
				VariableName: "BAR",
			},
		},
		{
			name: "env",
			cli:  "-e Development BAZ",
			wants: GetOptions{
				EnvName:      "Development",
				VariableName: "BAZ",
			},
+ 54 more lines · read full file
pkg/cmd/variable/get/get_test.go:107pkg/cmd/variable/get/get_test::Test_getRun · Go · 192 lines
func Test_getRun(t *testing.T) {
	tf, _ := time.Parse(time.RFC3339, "2024-01-01T00:00:00Z")

	tests := []struct {
		name       string
		opts       *GetOptions
		host       string
		httpStubs  func(*httpmock.Registry)
		jsonFields []string
		wantOut    string
		wantErr    error
	}{
		{
			name: "getting repo variable",
			opts: &GetOptions{
				VariableName: "VARIABLE_ONE",
			},
			host: "github.com",
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.WithHost(httpmock.REST("GET", "repos/owner/repo/actions/variables/VARIABLE_ONE"), "api.github.com"),
					httpmock.JSONResponse(shared.Variable{
						Value: "repo_var",
					}))
			},
			wantOut: "repo_var\n",
		},
		{
			name: "getting GHES repo variable",
			opts: &GetOptions{
				VariableName: "VARIABLE_ONE",
+ 162 more lines · read full file
pkg/cmd/variable/get/get_test.go:300pkg/cmd/variable/get/get_test::TestExportVariables · Go · 19 lines
func TestExportVariables(t *testing.T) {
	ios, _, stdout, _ := iostreams.Test()
	tf, _ := time.Parse(time.RFC3339, "2024-01-01T00:00:00Z")
	vs := &shared.Variable{
		Name:             "v1",
		Value:            "test1",
		UpdatedAt:        tf,
		CreatedAt:        tf,
		Visibility:       shared.All,
		SelectedReposURL: "https://someurl.com",
		NumSelectedRepos: 1,
	}
	exporter := cmdutil.NewJSONExporter()
	exporter.SetFields(shared.VariableJSONFields)
	require.NoError(t, exporter.Write(ios, vs))
	require.JSONEq(t,
		`{"name":"v1","numSelectedRepos":1,"selectedReposURL":"https://someurl.com","updatedAt":"2024-01-01T00:00:00Z","createdAt":"2024-01-01T00:00:00Z","value":"test1","visibility":"all"}`,
		stdout.String())
}
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh variable get
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: Get a variable for an environment
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
DOCS
gh_variable_get.md:23Markdown · 6 words
TESTS
pkg/cmd/variable/get/get_test.go:22pkg/cmd/variable/get/get_test::TestNewCmdGet · Go · 84 lines
func TestNewCmdGet(t *testing.T) {
	tests := []struct {
		name    string
		cli     string
		wants   GetOptions
		wantErr error
	}{
		{
			name: "repo",
			cli:  "FOO",
			wants: GetOptions{
				OrgName:      "",
				VariableName: "FOO",
			},
		},
		{
			name: "org",
			cli:  "-o TestOrg BAR",
			wants: GetOptions{
				OrgName:      "TestOrg",
				VariableName: "BAR",
			},
		},
		{
			name: "env",
			cli:  "-e Development BAZ",
			wants: GetOptions{
				EnvName:      "Development",
				VariableName: "BAZ",
			},
+ 54 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable get
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: Get a variable for an environment
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
DOCS
gh_variable_get.md:24Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable get
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: Get a variable for an environment
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
DOCS
gh_variable_get.md:25Markdown · 6 words
TESTS
pkg/cmd/variable/get/get_test.go:22pkg/cmd/variable/get/get_test::TestNewCmdGet · Go · 84 lines
func TestNewCmdGet(t *testing.T) {
	tests := []struct {
		name    string
		cli     string
		wants   GetOptions
		wantErr error
	}{
		{
			name: "repo",
			cli:  "FOO",
			wants: GetOptions{
				OrgName:      "",
				VariableName: "FOO",
			},
		},
		{
			name: "org",
			cli:  "-o TestOrg BAR",
			wants: GetOptions{
				OrgName:      "TestOrg",
				VariableName: "BAR",
			},
		},
		{
			name: "env",
			cli:  "-e Development BAZ",
			wants: GetOptions{
				EnvName:      "Development",
				VariableName: "BAZ",
			},
+ 54 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable get
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: Get a variable for an environment
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
DOCS
gh_variable_get.md:26Markdown · 6 words
TESTS
pkg/cmd/variable/get/get_test.go:22pkg/cmd/variable/get/get_test::TestNewCmdGet · Go · 84 lines
func TestNewCmdGet(t *testing.T) {
	tests := []struct {
		name    string
		cli     string
		wants   GetOptions
		wantErr error
	}{
		{
			name: "repo",
			cli:  "FOO",
			wants: GetOptions{
				OrgName:      "",
				VariableName: "FOO",
			},
		},
		{
			name: "org",
			cli:  "-o TestOrg BAR",
			wants: GetOptions{
				OrgName:      "TestOrg",
				VariableName: "BAR",
			},
		},
		{
			name: "env",
			cli:  "-e Development BAZ",
			wants: GetOptions{
				EnvName:      "Development",
				VariableName: "BAZ",
			},
+ 54 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable get
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: Get a variable for an environment
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
DOCS
gh_variable_get.md:27Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable list
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: List variables for an environment
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
DOCS
gh_variable_list.md:1Markdown · 74 words
TESTS
pkg/cmd/variable/list/list_test.go:24pkg/cmd/variable/list/list_test::TestNewCmdList · Go · 57 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name  string
		cli   string
		wants ListOptions
	}{
		{
			name: "repo",
			cli:  "",
			wants: ListOptions{
				OrgName: "",
			},
		},
		{
			name: "org",
			cli:  "-oUmbrellaCorporation",
			wants: ListOptions{
				OrgName: "UmbrellaCorporation",
			},
		},
		{
			name: "env",
			cli:  "-eDevelopment",
			wants: ListOptions{
				EnvName: "Development",
			},
		},
	}

	for _, tt := range tests {
+ 27 more lines · read full file
pkg/cmd/variable/list/list_test.go:82pkg/cmd/variable/list/list_test::Test_listRun · Go · 224 lines
func Test_listRun(t *testing.T) {
	tests := []struct {
		name       string
		tty        bool
		opts       *ListOptions
		jsonFields []string
		wantOut    []string
	}{
		{
			name: "repo tty",
			tty:  true,
			opts: &ListOptions{},
			wantOut: []string{
				"NAME            VALUE  UPDATED",
				"VARIABLE_ONE    one    about 34 years ago",
				"VARIABLE_TWO    two    about 2 years ago",
				"VARIABLE_THREE  three  about 47 years ago",
			},
		},
		{
			name: "repo not tty",
			tty:  false,
			opts: &ListOptions{},
			wantOut: []string{
				"VARIABLE_ONE\tone\t1988-10-11T00:00:00Z",
				"VARIABLE_TWO\ttwo\t2020-12-04T00:00:00Z",
				"VARIABLE_THREE\tthree\t1975-11-30T00:00:00Z",
			},
		},
		{
+ 194 more lines · read full file
pkg/cmd/variable/list/list_test.go:317pkg/cmd/variable/list/list_test::Test_listRun_populatesNumSelectedReposIfRequired · Go · 106 lines
func Test_listRun_populatesNumSelectedReposIfRequired(t *testing.T) {
	tests := []struct {
		name          string
		tty           bool
		jsonFields    []string
		wantPopulated bool
	}{
		{
			name:          "org tty",
			tty:           true,
			wantPopulated: true,
		},
		{
			name:          "org tty, json with numSelectedRepos",
			tty:           true,
			jsonFields:    []string{"numSelectedRepos"},
			wantPopulated: true,
		},
		{
			name:          "org tty, json without numSelectedRepos",
			tty:           true,
			jsonFields:    []string{"name"},
			wantPopulated: false,
		},
		{
			name:          "org not tty",
			tty:           false,
			wantPopulated: false,
		},
		{
+ 76 more lines · read full file
+ 2 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh variable list
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: List variables for an environment
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
DOCS
gh_variable_list.md:23Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable list
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: List variables for an environment
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
DOCS
gh_variable_list.md:24Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable list
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: List variables for an environment
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
DOCS
gh_variable_list.md:25Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable list
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: List variables for an environment
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
DOCS
gh_variable_list.md:26Markdown · 5 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable list
pname: gh variable
plink: gh_variable.yaml
options:
    - option: env
      shorthand: e
      value_type: string
      description: List variables for an environment
    - option: jq
      shorthand: q
      value_type: string
      description: Filter JSON output using a jq expression
DOCS
gh_variable_list.md:27Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable set
pname: gh variable
plink: gh_variable.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The value for the variable (reads from standard input if not specified)
DOCS
gh_variable_set.md:1Markdown · 79 words
TESTS
pkg/cmd/variable/set/set_test.go:24pkg/cmd/variable/set/set_test::TestNewCmdSet · Go · 151 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    SetOptions
		stdinTTY bool
		wantsErr bool
	}{
		{
			name:     "invalid visibility type",
			cli:      "cool_variable --org coolOrg -v'mistyVeil'",
			wantsErr: true,
		},
		{
			name:     "selected visibility with no repos selected",
			cli:      "cool_variable --org coolOrg -v'selected'",
			wantsErr: true,
		},
		{
			name:     "private visibility with repos selected",
			cli:      "cool_variable --org coolOrg -v'private' -rcoolRepo",
			wantsErr: true,
		},
		{
			name:     "no name specified",
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "multiple names specified",
+ 121 more lines · read full file
pkg/cmd/variable/set/set_test.go:176pkg/cmd/variable/set/set_test::Test_setRun_repo · Go · 65 lines
func Test_setRun_repo(t *testing.T) {
	tests := []struct {
		name      string
		httpStubs func(*httpmock.Registry)
		wantErr   bool
	}{
		{
			name: "create actions variable",
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.REST("POST", "repos/owner/repo/actions/variables"),
					httpmock.StatusStringResponse(201, `{}`))
			},
		},
		{
			name: "update actions variable",
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.REST("POST", "repos/owner/repo/actions/variables"),
					httpmock.StatusStringResponse(409, `{}`))
				reg.Register(httpmock.REST("PATCH", "repos/owner/repo/actions/variables/cool_variable"),
					httpmock.StatusStringResponse(204, `{}`))
			},
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			reg := &httpmock.Registry{}
			defer reg.Verify(t)
			if tt.httpStubs != nil {
				tt.httpStubs(reg)
+ 35 more lines · read full file
pkg/cmd/variable/set/set_test.go:242pkg/cmd/variable/set/set_test::Test_setRun_env · Go · 73 lines
func Test_setRun_env(t *testing.T) {
	tests := []struct {
		name      string
		opts      *SetOptions
		httpStubs func(*httpmock.Registry)
		wantErr   bool
	}{
		{
			name: "create env variable",
			opts: &SetOptions{},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.GraphQL(`query MapRepositoryNames\b`),
					httpmock.StringResponse(`{"data":{"repo_0001":{"databaseId":1}}}`))
				reg.Register(httpmock.REST("POST", "repositories/1/environments/release/variables"),
					httpmock.StatusStringResponse(201, `{}`))
			},
		},
		{
			name: "update env variable",
			opts: &SetOptions{},
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(httpmock.GraphQL(`query MapRepositoryNames\b`),
					httpmock.StringResponse(`{"data":{"repo_0001":{"databaseId":1}}}`))
				reg.Register(httpmock.REST("POST", "repositories/1/environments/release/variables"),
					httpmock.StatusStringResponse(409, `{}`))
				reg.Register(httpmock.REST("PATCH", "repositories/1/environments/release/variables/cool_variable"),
					httpmock.StatusStringResponse(204, `{}`))
			},
		},
	}
+ 43 more lines · read full file
+ 4 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh variable set
pname: gh variable
plink: gh_variable.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The value for the variable (reads from standard input if not specified)
DOCS
gh_variable_set.md:26Markdown · 12 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh variable set
pname: gh variable
plink: gh_variable.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The value for the variable (reads from standard input if not specified)
DOCS
gh_variable_set.md:27Markdown · 4 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh variable set
pname: gh variable
plink: gh_variable.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The value for the variable (reads from standard input if not specified)
DOCS
gh_variable_set.md:28Markdown · 9 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh variable set
pname: gh variable
plink: gh_variable.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The value for the variable (reads from standard input if not specified)
DOCS
gh_variable_set.md:29Markdown · 3 words
TESTS
pkg/cmd/variable/set/set_test.go:24pkg/cmd/variable/set/set_test::TestNewCmdSet · Go · 151 lines
func TestNewCmdSet(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    SetOptions
		stdinTTY bool
		wantsErr bool
	}{
		{
			name:     "invalid visibility type",
			cli:      "cool_variable --org coolOrg -v'mistyVeil'",
			wantsErr: true,
		},
		{
			name:     "selected visibility with no repos selected",
			cli:      "cool_variable --org coolOrg -v'selected'",
			wantsErr: true,
		},
		{
			name:     "private visibility with repos selected",
			cli:      "cool_variable --org coolOrg -v'private' -rcoolRepo",
			wantsErr: true,
		},
		{
			name:     "no name specified",
			cli:      "",
			wantsErr: true,
		},
		{
			name:     "multiple names specified",
+ 121 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh variable set
pname: gh variable
plink: gh_variable.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The value for the variable (reads from standard input if not specified)
DOCS
gh_variable_set.md:30Markdown · 9 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh variable set
pname: gh variable
plink: gh_variable.yaml
options:
    - option: body
      shorthand: b
      value_type: string
      description: The value for the variable (reads from standard input if not specified)
DOCS
gh_variable_set.md:31Markdown · 7 words
TESTS

N/A

EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh workflow
short: List, view, and run workflows in GitHub Actions.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh workflow
short: List, view, and run workflows in GitHub Actions.
pname: gh
plink: gh.yaml
options:
    - option: repo
      shorthand: R
      value_type: string
      description: Select another repository using the [HOST/]OWNER/REPO format
DOCS
gh_workflow.md:24Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh workflow disable
short: Disable a workflow, preventing it from running or showing up when listing workflows.
pname: gh workflow
plink: gh_workflow.yaml
TESTS
pkg/cmd/workflow/disable/disable_test.go:19pkg/cmd/workflow/disable/disable_test::TestNewCmdDisable · Go · 72 lines
func TestNewCmdDisable(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    DisableOptions
		wantsErr bool
	}{
		{
			name: "blank tty",
			tty:  true,
			wants: DisableOptions{
				Prompt: true,
			},
		},
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "arg tty",
			cli:  "123",
			tty:  true,
			wants: DisableOptions{
				Selector: "123",
			},
		},
		{
			name: "arg nontty",
			cli:  "123",
+ 42 more lines · read full file
pkg/cmd/workflow/disable/disable_test.go:92pkg/cmd/workflow/disable/disable_test::TestDisableRun · Go · 202 lines
func TestDisableRun(t *testing.T) {
	tests := []struct {
		name        string
		opts        *DisableOptions
		httpStubs   func(*httpmock.Registry)
		promptStubs func(*prompter.MockPrompter)
		tty         bool
		wantOut     string
		wantErrOut  string
		wantErr     bool
	}{
		{
			name: "tty no arg",
			opts: &DisableOptions{
				Prompt: true,
			},
			tty: true,
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
					httpmock.JSONResponse(shared.WorkflowsPayload{
						Workflows: []shared.Workflow{
							shared.AWorkflow,
							shared.DisabledWorkflow,
							shared.AnotherWorkflow,
						},
					}))
				reg.Register(
					httpmock.REST("PUT", "repos/OWNER/REPO/actions/workflows/789/disable"),
					httpmock.StatusStringResponse(204, "{}"))
+ 172 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh workflow enable
short: Enable a workflow, allowing it to be run and show up when listing workflows.
pname: gh workflow
plink: gh_workflow.yaml
TESTS
pkg/cmd/workflow/enable/enable_test.go:19pkg/cmd/workflow/enable/enable_test::TestNewCmdEnable · Go · 72 lines
func TestNewCmdEnable(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    EnableOptions
		wantsErr bool
	}{
		{
			name: "blank tty",
			tty:  true,
			wants: EnableOptions{
				Prompt: true,
			},
		},
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "arg tty",
			cli:  "123",
			tty:  true,
			wants: EnableOptions{
				Selector: "123",
			},
		},
		{
			name: "arg nontty",
			cli:  "123",
+ 42 more lines · read full file
pkg/cmd/workflow/enable/enable_test.go:92pkg/cmd/workflow/enable/enable_test::TestEnableRun · Go · 242 lines
func TestEnableRun(t *testing.T) {
	tests := []struct {
		name        string
		opts        *EnableOptions
		httpStubs   func(*httpmock.Registry)
		promptStubs func(*prompter.MockPrompter)
		tty         bool
		wantOut     string
		wantErrOut  string
		wantErr     bool
	}{
		{
			name: "tty no arg",
			opts: &EnableOptions{
				Prompt: true,
			},
			tty: true,
			httpStubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
					httpmock.JSONResponse(shared.WorkflowsPayload{
						Workflows: []shared.Workflow{
							shared.AWorkflow,
							shared.DisabledWorkflow,
							shared.AnotherWorkflow,
						},
					}))
				reg.Register(
					httpmock.REST("PUT", "repos/OWNER/REPO/actions/workflows/456/enable"),
					httpmock.StatusStringResponse(204, "{}"))
+ 212 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh workflow list
short: List workflow files, hiding disabled workflows by default.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: all
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Include disabled workflows
    - option: jq
DOCS
gh_workflow_list.md:1Markdown · 32 words
TESTS
pkg/cmd/workflow/list/list_test.go:19pkg/cmd/workflow/list/list_test::TestNewCmdList · Go · 69 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "no arguments",
			wants: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "all flag",
			cli:  "--all",
			wants: ListOptions{
				Limit: defaultLimit,
				All:   true,
			},
		},
		{
			name: "limit flag",
			cli:  "--limit 100",
			wants: ListOptions{
				Limit: 100,
			},
		},
		{
			name:     "invalid limit flag",
+ 39 more lines · read full file
pkg/cmd/workflow/list/list_test.go:89pkg/cmd/workflow/list/list_test::TestListRun · Go · 141 lines
func TestListRun(t *testing.T) {
	workflows := []shared.Workflow{
		{
			Name:  "Go",
			State: shared.Active,
			ID:    707,
		},
		{
			Name:  "Linter",
			State: shared.Active,
			ID:    666,
		},
		{
			Name:  "Release",
			State: shared.DisabledManually,
			ID:    451,
		},
	}
	payload := shared.WorkflowsPayload{Workflows: workflows}

	tests := []struct {
		name       string
		opts       *ListOptions
		wantErr    bool
		wantOut    string
		wantErrOut string
		stubs      func(*httpmock.Registry)
		tty        bool
	}{
		{
+ 111 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh workflow list
short: List workflow files, hiding disabled workflows by default.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: all
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Include disabled workflows
    - option: jq
DOCS
gh_workflow_list.md:19Markdown · 3 words
TESTS
pkg/cmd/workflow/list/list_test.go:19pkg/cmd/workflow/list/list_test::TestNewCmdList · Go · 69 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "no arguments",
			wants: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "all flag",
			cli:  "--all",
			wants: ListOptions{
				Limit: defaultLimit,
				All:   true,
			},
		},
		{
			name: "limit flag",
			cli:  "--limit 100",
			wants: ListOptions{
				Limit: 100,
			},
		},
		{
			name:     "invalid limit flag",
+ 39 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh workflow list
short: List workflow files, hiding disabled workflows by default.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: all
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Include disabled workflows
    - option: jq
DOCS
gh_workflow_list.md:20Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh workflow list
short: List workflow files, hiding disabled workflows by default.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: all
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Include disabled workflows
    - option: jq
DOCS
gh_workflow_list.md:21Markdown · 6 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh workflow list
short: List workflow files, hiding disabled workflows by default.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: all
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Include disabled workflows
    - option: jq
DOCS
gh_workflow_list.md:22Markdown · 6 words
TESTS
pkg/cmd/workflow/list/list_test.go:19pkg/cmd/workflow/list/list_test::TestNewCmdList · Go · 69 lines
func TestNewCmdList(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		wants    ListOptions
		wantsErr bool
	}{
		{
			name: "no arguments",
			wants: ListOptions{
				Limit: defaultLimit,
			},
		},
		{
			name: "all flag",
			cli:  "--all",
			wants: ListOptions{
				Limit: defaultLimit,
				All:   true,
			},
		},
		{
			name: "limit flag",
			cli:  "--limit 100",
			wants: ListOptions{
				Limit: 100,
			},
		},
		{
			name:     "invalid limit flag",
+ 39 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh workflow list
short: List workflow files, hiding disabled workflows by default.
long: For more information about output formatting flags, see `gh help formatting`.
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: all
      shorthand: a
      value_type: bool
      default_value: "false"
      description: Include disabled workflows
    - option: jq
DOCS
gh_workflow_list.md:23Markdown · 11 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh workflow run
short: Create a `workflow_dispatch` event for a given workflow.
long: |-
    This command will trigger GitHub Actions to run a given workflow file. The given workflow file must
    support an `on.workflow_dispatch` trigger in order to be run in this way.
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: field
      shorthand: F
      value_type: string
      description: Add a string parameter in key=value format, respecting @ syntax (see "gh help api").
TESTS
pkg/cmd/workflow/run/run_test.go:26pkg/cmd/workflow/run/run_test::TestNewCmdRun · Go · 126 lines
func TestNewCmdRun(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    RunOptions
		wantsErr bool
		errMsg   string
		stdin    string
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
			errMsg:   "workflow ID, name, or filename required when not running interactively",
		},
		{
			name: "blank tty",
			tty:  true,
			wants: RunOptions{
				Prompt: true,
			},
		},
		{
			name: "ref flag",
			tty:  true,
			cli:  "--ref 12345abc",
			wants: RunOptions{
				Prompt: true,
				Ref:    "12345abc",
			},
+ 96 more lines · read full file
pkg/cmd/workflow/run/run_test.go:153pkg/cmd/workflow/run/run_test::Test_magicFieldValue · Go · 60 lines
func Test_magicFieldValue(t *testing.T) {
	f, err := os.CreateTemp(t.TempDir(), "gh-test")
	if err != nil {
		t.Fatal(err)
	}
	defer f.Close()

	fmt.Fprint(f, "file contents")

	ios, _, _, _ := iostreams.Test()

	type args struct {
		v    string
		opts RunOptions
	}
	tests := []struct {
		name    string
		args    args
		want    interface{}
		wantErr bool
	}{
		{
			name:    "string",
			args:    args{v: "hello"},
			want:    "hello",
			wantErr: false,
		},
		{
			name: "file",
			args: args{
+ 30 more lines · read full file
pkg/cmd/workflow/run/run_test.go:214pkg/cmd/workflow/run/run_test::Test_findInputs · Go · 106 lines
func Test_findInputs(t *testing.T) {
	tests := []struct {
		name    string
		YAML    []byte
		wantErr bool
		errMsg  string
		wantOut []WorkflowInput
	}{
		{
			name:    "blank",
			YAML:    []byte{},
			wantErr: true,
			errMsg:  "invalid YAML file",
		},
		{
			name:    "no event specified",
			YAML:    []byte("name: workflow"),
			wantErr: true,
			errMsg:  "invalid workflow: no 'on' key",
		},
		{
			name:    "not workflow_dispatch",
			YAML:    []byte("name: workflow\non: pull_request"),
			wantErr: true,
			errMsg:  "unable to manually run a workflow without a workflow_dispatch event",
		},
		{
			name:    "bad inputs",
			YAML:    []byte("name: workflow\non:\n workflow_dispatch:\n  inputs: lol  "),
			wantErr: true,
+ 76 more lines · read full file
+ 1 more tests · open all in source
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh workflow run
short: Create a `workflow_dispatch` event for a given workflow.
long: |-
    This command will trigger GitHub Actions to run a given workflow file. The given workflow file must
    support an `on.workflow_dispatch` trigger in order to be run in this way.
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: field
      shorthand: F
      value_type: string
      description: Add a string parameter in key=value format, respecting @ syntax (see "gh help api").
DOCS
gh_workflow_run.md:31Markdown · 14 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh workflow run
short: Create a `workflow_dispatch` event for a given workflow.
long: |-
    This command will trigger GitHub Actions to run a given workflow file. The given workflow file must
    support an `on.workflow_dispatch` trigger in order to be run in this way.
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: field
      shorthand: F
      value_type: string
      description: Add a string parameter in key=value format, respecting @ syntax (see "gh help api").
TESTS
pkg/cmd/workflow/run/run_test.go:26pkg/cmd/workflow/run/run_test::TestNewCmdRun · Go · 126 lines
func TestNewCmdRun(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    RunOptions
		wantsErr bool
		errMsg   string
		stdin    string
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
			errMsg:   "workflow ID, name, or filename required when not running interactively",
		},
		{
			name: "blank tty",
			tty:  true,
			wants: RunOptions{
				Prompt: true,
			},
		},
		{
			name: "ref flag",
			tty:  true,
			cli:  "--ref 12345abc",
			wants: RunOptions{
				Prompt: true,
				Ref:    "12345abc",
			},
+ 96 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh workflow run
short: Create a `workflow_dispatch` event for a given workflow.
long: |-
    This command will trigger GitHub Actions to run a given workflow file. The given workflow file must
    support an `on.workflow_dispatch` trigger in order to be run in this way.
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: field
      shorthand: F
      value_type: string
      description: Add a string parameter in key=value format, respecting @ syntax (see "gh help api").
DOCS
gh_workflow_run.md:33Markdown · 7 words
TESTS

N/A

EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh workflow run
short: Create a `workflow_dispatch` event for a given workflow.
long: |-
    This command will trigger GitHub Actions to run a given workflow file. The given workflow file must
    support an `on.workflow_dispatch` trigger in order to be run in this way.
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: field
      shorthand: F
      value_type: string
      description: Add a string parameter in key=value format, respecting @ syntax (see "gh help api").
TESTS
pkg/cmd/workflow/run/run_test.go:26pkg/cmd/workflow/run/run_test::TestNewCmdRun · Go · 126 lines
func TestNewCmdRun(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    RunOptions
		wantsErr bool
		errMsg   string
		stdin    string
	}{
		{
			name:     "blank nontty",
			wantsErr: true,
			errMsg:   "workflow ID, name, or filename required when not running interactively",
		},
		{
			name: "blank tty",
			tty:  true,
			wants: RunOptions{
				Prompt: true,
			},
		},
		{
			name: "ref flag",
			tty:  true,
			cli:  "--ref 12345abc",
			wants: RunOptions{
				Prompt: true,
				Ref:    "12345abc",
			},
+ 96 more lines · read full file
EXAMPLES
WORKFLOWS

N/A

CONTRACT
command: gh workflow view
short: View the summary of a workflow
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: ref
      shorthand: r
      value_type: string
      description: The branch or tag name which contains the version of the workflow file you'd like to view
    - option: web
      shorthand: w
      value_type: bool
DOCS
gh_workflow_view.md:1Markdown · 21 words
TESTS
pkg/cmd/workflow/view/view_test.go:21pkg/cmd/workflow/view/view_test::TestNewCmdView · Go · 143 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ViewOptions
		wantsErr bool
	}{
		{
			name: "blank tty",
			tty:  true,
			wants: ViewOptions{
				Prompt: true,
			},
		},
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "arg tty",
			cli:  "123",
			tty:  true,
			wants: ViewOptions{
				Selector: "123",
			},
		},
		{
			name: "arg nontty",
			cli:  "123",
+ 113 more lines · read full file
pkg/cmd/workflow/view/view_test.go:165pkg/cmd/workflow/view/view_test::TestViewRun · Go · 268 lines
func TestViewRun(t *testing.T) {
	aWorkflow := shared.Workflow{
		Name:  "a workflow",
		ID:    123,
		Path:  ".github/workflows/flow.yml",
		State: shared.Active,
	}
	aWorkflowContent := `{"content":"bmFtZTogYSB3b3JrZmxvdwo="}`
	aWorkflowInfo := heredoc.Doc(`
		a workflow - flow.yml
		ID: 123

		Total runs 10
		Recent runs
		   TITLE        WORKFLOW    BRANCH  EVENT  ID
		X  cool commit  a workflow  trunk   push   1
		*  cool commit  a workflow  trunk   push   2
		✓  cool commit  a workflow  trunk   push   3
		X  cool commit  a workflow  trunk   push   4

		To see more runs for this workflow, try: gh run list --workflow flow.yml
		To see the YAML for this workflow, try: gh workflow view flow.yml --yaml
	`)

	tests := []struct {
		name       string
		opts       *ViewOptions
		httpStubs  func(*httpmock.Registry)
		tty        bool
		wantOut    string
+ 238 more lines · read full file
WORKFLOWS

N/A

CONTRACT
command: gh workflow view
short: View the summary of a workflow
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: ref
      shorthand: r
      value_type: string
      description: The branch or tag name which contains the version of the workflow file you'd like to view
    - option: web
      shorthand: w
      value_type: bool
DOCS
gh_workflow_view.md:19Markdown · 17 words
TESTS
pkg/cmd/workflow/view/view_test.go:21pkg/cmd/workflow/view/view_test::TestNewCmdView · Go · 143 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ViewOptions
		wantsErr bool
	}{
		{
			name: "blank tty",
			tty:  true,
			wants: ViewOptions{
				Prompt: true,
			},
		},
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "arg tty",
			cli:  "123",
			tty:  true,
			wants: ViewOptions{
				Selector: "123",
			},
		},
		{
			name: "arg nontty",
			cli:  "123",
+ 113 more lines · read full file
pkg/cmd/workflow/view/view_test.go:165pkg/cmd/workflow/view/view_test::TestViewRun · Go · 268 lines
func TestViewRun(t *testing.T) {
	aWorkflow := shared.Workflow{
		Name:  "a workflow",
		ID:    123,
		Path:  ".github/workflows/flow.yml",
		State: shared.Active,
	}
	aWorkflowContent := `{"content":"bmFtZTogYSB3b3JrZmxvdwo="}`
	aWorkflowInfo := heredoc.Doc(`
		a workflow - flow.yml
		ID: 123

		Total runs 10
		Recent runs
		   TITLE        WORKFLOW    BRANCH  EVENT  ID
		X  cool commit  a workflow  trunk   push   1
		*  cool commit  a workflow  trunk   push   2
		✓  cool commit  a workflow  trunk   push   3
		X  cool commit  a workflow  trunk   push   4

		To see more runs for this workflow, try: gh run list --workflow flow.yml
		To see the YAML for this workflow, try: gh workflow view flow.yml --yaml
	`)

	tests := []struct {
		name       string
		opts       *ViewOptions
		httpStubs  func(*httpmock.Registry)
		tty        bool
		wantOut    string
+ 238 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh workflow view
short: View the summary of a workflow
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: ref
      shorthand: r
      value_type: string
      description: The branch or tag name which contains the version of the workflow file you'd like to view
    - option: web
      shorthand: w
      value_type: bool
DOCS
gh_workflow_view.md:20Markdown · 5 words
TESTS
pkg/cmd/workflow/view/view_test.go:21pkg/cmd/workflow/view/view_test::TestNewCmdView · Go · 143 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ViewOptions
		wantsErr bool
	}{
		{
			name: "blank tty",
			tty:  true,
			wants: ViewOptions{
				Prompt: true,
			},
		},
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "arg tty",
			cli:  "123",
			tty:  true,
			wants: ViewOptions{
				Selector: "123",
			},
		},
		{
			name: "arg nontty",
			cli:  "123",
+ 113 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

CONTRACT
command: gh workflow view
short: View the summary of a workflow
pname: gh workflow
plink: gh_workflow.yaml
options:
    - option: ref
      shorthand: r
      value_type: string
      description: The branch or tag name which contains the version of the workflow file you'd like to view
    - option: web
      shorthand: w
      value_type: bool
DOCS
gh_workflow_view.md:21Markdown · 5 words
TESTS
pkg/cmd/workflow/view/view_test.go:21pkg/cmd/workflow/view/view_test::TestNewCmdView · Go · 143 lines
func TestNewCmdView(t *testing.T) {
	tests := []struct {
		name     string
		cli      string
		tty      bool
		wants    ViewOptions
		wantsErr bool
	}{
		{
			name: "blank tty",
			tty:  true,
			wants: ViewOptions{
				Prompt: true,
			},
		},
		{
			name:     "blank nontty",
			wantsErr: true,
		},
		{
			name: "arg tty",
			cli:  "123",
			tty:  true,
			wants: ViewOptions{
				Selector: "123",
			},
		},
		{
			name: "arg nontty",
			cli:  "123",
+ 113 more lines · read full file
EXAMPLES

N/A

WORKFLOWS

N/A

48 Workflows

Eight percent of flags appear in any documented sequence — recipes name the command, not the flag. An agent that knows a flag exists in isolation hasn't been shown when to use it.

Commands in ≥1 workflow
34%
Flags in ≥1 workflow
8%
Length distribution
2 cmd 15
3 cmd 8
4 cmd 4
5 cmd 4
6+ cmd 17
Guide freshness — cross-repo
download-workflow-artifacts.md · 2 cmds current
manage-caches.md · 2 cmds current
manually-run-a-workflow.md · 4 cmds current
re-run-workflows-and-jobs.md · 3 cmds current
use-workflow-run-logs.md · 3 cmds current
view-workflow-run-history.md · 3 cmds current
increase-security-rating.md · 2 cmds current
use-artifact-attestations.md · 2 cmds current
verify-attestations-offline.md · 4 cmds current
use-github-cli.md · 3 cmds current
use-secrets.md · 5 cmds current
trigger-a-workflow.md · 5 cmds current
add-comments-with-labels.md · 2 cmds current
add-labels-to-issues.md · 2 cmds current
schedule-issue-creation.md · 4 cmds current
renaming-a-codespace.md · 2 cmds current
deleting-a-codespace.md · 2 cmds current
github-codespaces-logs.md · 2 cmds current
troubleshooting-prebuilds.md · 1 cmds current
getting-started-with-git.md · 3 cmds current
github-cli-reference.md · 2 cmds current
github-cli-telemetry.md · 4 cmds current
using-github-cli-extensions.md · 5 cmds current
creating-an-issue.md · 2 cmds current
merging-a-pull-request.md · 2 cmds current
creating-a-pull-request.md · 2 cmds current
fork-a-repo.md · 2 cmds current
syncing-a-fork.md · 2 cmds current
cloning-a-repository.md · 2 cmds current
sheaf scanner · 1163 commands & flags · cli surface · 2026-06-07 22:34 UTC