From 313d20ba83d831815be5d41f326f7c9100949357 Mon Sep 17 00:00:00 2001 From: Andy Feller Date: Mon, 14 Jul 2025 08:33:20 -0400 Subject: [PATCH 1/2] Ensure hostnames are visible in CLI website This commit changes and references to `github.com` and `ghe.com` so they are visible on the GitHub CLI marketing website. GitHub Pages will render URLs with a protocol as clickable links, however hostnames are treated as HTML elements and not rendered. --- pkg/cmd/api/api.go | 8 ++++---- pkg/cmd/extension/command.go | 2 +- pkg/cmd/repo/rename/rename.go | 2 +- pkg/cmd/root/help_topic.go | 2 +- pkg/cmd/search/code/code.go | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/cmd/api/api.go b/pkg/cmd/api/api.go index 586aeae9323..c81844a02a0 100644 --- a/pkg/cmd/api/api.go +++ b/pkg/cmd/api/api.go @@ -199,15 +199,15 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command [.[].data.viewer.repositories.nodes[]] as $r | count(select($r[].isFork))/count($r[])' `), Annotations: map[string]string{ - "help:environment": heredoc.Doc(` + "help:environment": heredoc.Docf(` GH_TOKEN, GITHUB_TOKEN (in order of precedence): an authentication token for - API requests. + %[1]sgithub.com%[1]s API requests. GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKEN (in order of precedence): an authentication token for API requests to GitHub Enterprise. - GH_HOST: make the request to a GitHub host other than . - `), + GH_HOST: make the request to a GitHub host other than %[1]sgithub.com%[1]s. + `, "`"), }, Args: cobra.ExactArgs(1), PreRun: func(c *cobra.Command, args []string) { diff --git a/pkg/cmd/extension/command.go b/pkg/cmd/extension/command.go index 9431c0a92d1..354a91cc3ad 100644 --- a/pkg/cmd/extension/command.go +++ b/pkg/cmd/extension/command.go @@ -300,7 +300,7 @@ func NewCmdExtension(f *cmdutil.Factory) *cobra.Command { For GitHub repositories, the repository argument can be specified in %[1]sOWNER/REPO%[1]s format or as a full repository URL. - The URL format is useful when the repository is not hosted on . + The URL format is useful when the repository is not hosted on %[1]sgithub.com%[1]s. 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. diff --git a/pkg/cmd/repo/rename/rename.go b/pkg/cmd/repo/rename/rename.go index cbb89342dd5..30b573554b7 100644 --- a/pkg/cmd/repo/rename/rename.go +++ b/pkg/cmd/repo/rename/rename.go @@ -59,7 +59,7 @@ func NewCmdRename(f *cmdutil.Factory, runf func(*RenameOptions) error) *cobra.Co with %[1]s--repo%[1]s is renamed. To transfer repository ownership to another user account or organization, - you must follow additional steps on . + you must follow additional steps on %[1]sgithub.com%[1]s. For more information on transferring repository ownership, see: diff --git a/pkg/cmd/root/help_topic.go b/pkg/cmd/root/help_topic.go index 0c9534306aa..a375d9e2050 100644 --- a/pkg/cmd/root/help_topic.go +++ b/pkg/cmd/root/help_topic.go @@ -43,7 +43,7 @@ var HelpTopics = []helpTopic{ short: "Environment variables that can be used with gh", long: heredoc.Docf(` %[1]sGH_TOKEN%[1]s, %[1]sGITHUB_TOKEN%[1]s (in order of precedence): an authentication token that will be used when - a command targets either or a subdomain of . Setting this avoids being prompted to + a command targets either %[1]sgithub.com%[1]s or a subdomain of %[1]sghe.com%[1]s. Setting this avoids being prompted to authenticate and takes precedence over previously stored credentials. %[1]sGH_ENTERPRISE_TOKEN%[1]s, %[1]sGITHUB_ENTERPRISE_TOKEN%[1]s (in order of precedence): an authentication diff --git a/pkg/cmd/search/code/code.go b/pkg/cmd/search/code/code.go index d51ec8fa6be..88f84a125b0 100644 --- a/pkg/cmd/search/code/code.go +++ b/pkg/cmd/search/code/code.go @@ -33,16 +33,16 @@ func NewCmdCode(f *cmdutil.Factory, runF func(*CodeOptions) error) *cobra.Comman cmd := &cobra.Command{ Use: "code ", Short: "Search within code", - Long: heredoc.Doc(` + Long: heredoc.Docf(` Search within code in GitHub repositories. The search syntax is documented at: Note that these search results are powered by what is now a legacy GitHub code search engine. - The results might not match what is seen on , and new features like regex search + The results might not match what is seen on %[1]sgithub.com%[1]s, and new features like regex search are not yet available via the GitHub API. - `), + `, "`"), Example: heredoc.Doc(` # Search code matching "react" and "lifecycle" $ gh search code react lifecycle From 29a94ab9b1e49e5e1c5b20a8d5820b1decae78af Mon Sep 17 00:00:00 2001 From: Andy Feller Date: Mon, 14 Jul 2025 08:43:15 -0400 Subject: [PATCH 2/2] Reformat non-documentation hostnames Outside of the hostnames previously fixed, I talked with @williammartin about what to do with the remaining references and the concern about the mixed format. One suggestion for the error / test use case was to remove the extraneous text all together. --- acceptance/testdata/repo/repo-rename-transfer-ownership.txtar | 4 ++-- pkg/cmd/auth/login/login.go | 2 +- pkg/cmd/repo/rename/rename.go | 2 +- pkg/cmd/repo/rename/rename_test.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/acceptance/testdata/repo/repo-rename-transfer-ownership.txtar b/acceptance/testdata/repo/repo-rename-transfer-ownership.txtar index 754a609d7c2..5075a20a223 100644 --- a/acceptance/testdata/repo/repo-rename-transfer-ownership.txtar +++ b/acceptance/testdata/repo/repo-rename-transfer-ownership.txtar @@ -3,7 +3,7 @@ exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private # Attempt to rename the repo with a slash in the name ! exec gh repo rename $ORG/new-name --repo=$ORG/$SCRIPT_NAME-$RANDOM_STRING --yes -stderr 'New repository name cannot contain \''/\'' character - to transfer a repository to a new owner, you must follow additional steps on . For more information on transferring repository ownership, see .' +stderr 'New repository name cannot contain \''/\'' character - to transfer a repository to a new owner, see .' # Defer repo deletion -defer gh repo delete $ORG/$SCRIPT_NAME-$RANDOM_STRING --yes \ No newline at end of file +defer gh repo delete $ORG/$SCRIPT_NAME-$RANDOM_STRING --yes diff --git a/pkg/cmd/auth/login/login.go b/pkg/cmd/auth/login/login.go index 40b2fb38256..89410e6a11a 100644 --- a/pkg/cmd/auth/login/login.go +++ b/pkg/cmd/auth/login/login.go @@ -95,7 +95,7 @@ func NewCmdLogin(f *cmdutil.Factory, runF func(*LoginOptions) error) *cobra.Comm # Start interactive setup $ gh auth login - # Authenticate against by reading the token from a file + # Authenticate against github.com by reading the token from a file $ gh auth login --with-token < mytoken.txt # Authenticate with specific host diff --git a/pkg/cmd/repo/rename/rename.go b/pkg/cmd/repo/rename/rename.go index 30b573554b7..7a0c93da20f 100644 --- a/pkg/cmd/repo/rename/rename.go +++ b/pkg/cmd/repo/rename/rename.go @@ -126,7 +126,7 @@ func renameRun(opts *RenameOptions) error { } if strings.Contains(newRepoName, "/") { - return fmt.Errorf("New repository name cannot contain '/' character - to transfer a repository to a new owner, you must follow additional steps on . For more information on transferring repository ownership, see .") + return fmt.Errorf("New repository name cannot contain '/' character - to transfer a repository to a new owner, see .") } if opts.DoConfirm { diff --git a/pkg/cmd/repo/rename/rename_test.go b/pkg/cmd/repo/rename/rename_test.go index d6aa2993f18..e68530be001 100644 --- a/pkg/cmd/repo/rename/rename_test.go +++ b/pkg/cmd/repo/rename/rename_test.go @@ -227,7 +227,7 @@ func TestRenameRun(t *testing.T) { newRepoSelector: "org/new-name", }, wantErr: true, - errMsg: "New repository name cannot contain '/' character - to transfer a repository to a new owner, you must follow additional steps on . For more information on transferring repository ownership, see .", + errMsg: "New repository name cannot contain '/' character - to transfer a repository to a new owner, see .", }, }