From 27493ca2f8b13393ffda61822d1450ea74d65433 Mon Sep 17 00:00:00 2001 From: William Martin Date: Mon, 11 Sep 2023 15:18:20 +0200 Subject: [PATCH 1/2] Reinforce not opening PRs without approval on an issue --- .github/CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 10f17a2fcbf..73174db6568 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -16,6 +16,7 @@ Please do: Please avoid: * Opening pull requests for issues marked `needs-design`, `needs-investigation`, or `blocked`. +* Opening pull requests that haven't been approved for work in an issue * Adding installation instructions specifically for your OS/package manager. * Opening pull requests for any issue marked `core`. These issues require additional context from the core CLI team at GitHub and any external pull requests will not be accepted. From c5f88bb551e22b04a3799561f3abea4892012eff Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Tue, 12 Sep 2023 13:12:53 -0400 Subject: [PATCH 2/2] Show full permissions URL in `gh cs create` (#7983) * Show full permissions URL in `gh cs create` * Validate that full permissions URL is displayed --- pkg/cmd/codespace/create.go | 4 +--- pkg/cmd/codespace/create_test.go | 34 +++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/codespace/create.go b/pkg/cmd/codespace/create.go index 889f0b33b50..a2782aef709 100644 --- a/pkg/cmd/codespace/create.go +++ b/pkg/cmd/codespace/create.go @@ -11,7 +11,6 @@ import ( "github.com/cli/cli/v2/internal/codespaces" "github.com/cli/cli/v2/internal/codespaces/api" "github.com/cli/cli/v2/internal/ghrepo" - "github.com/cli/cli/v2/internal/text" "github.com/cli/cli/v2/pkg/cmdutil" "github.com/spf13/cobra" ) @@ -336,13 +335,12 @@ func (a *App) handleAdditionalPermissions(ctx context.Context, createParams *api var ( isInteractive = a.io.CanPrompt() cs = a.io.ColorScheme() - displayURL = text.DisplayURL(allowPermissionsURL) ) fmt.Fprintf(a.io.ErrOut, "You must authorize or deny additional permissions requested by this codespace before continuing.\n") if !isInteractive { - fmt.Fprintf(a.io.ErrOut, "%s in your browser to review and authorize additional permissions: %s\n", cs.Bold("Open this URL"), displayURL) + fmt.Fprintf(a.io.ErrOut, "%s in your browser to review and authorize additional permissions: %s\n", cs.Bold("Open this URL"), allowPermissionsURL) fmt.Fprintf(a.io.ErrOut, "Alternatively, you can run %q with the %q option to continue without authorizing additional permissions.\n", a.io.ColorScheme().Bold("create"), cs.Bold("--default-permissions")) return nil, cmdutil.SilentError } diff --git a/pkg/cmd/codespace/create_test.go b/pkg/cmd/codespace/create_test.go index caf6df271af..ae85fc34a27 100644 --- a/pkg/cmd/codespace/create_test.go +++ b/pkg/cmd/codespace/create_test.go @@ -356,7 +356,39 @@ func TestApp_Create(t *testing.T) { wantErr: cmdutil.SilentError, wantStderr: ` ✓ Codespaces usage for this repository is paid for by monalisa You must authorize or deny additional permissions requested by this codespace before continuing. -Open this URL in your browser to review and authorize additional permissions: example.com/permissions +Open this URL in your browser to review and authorize additional permissions: https://example.com/permissions +Alternatively, you can run "create" with the "--default-permissions" option to continue without authorizing additional permissions. +`, + }, + { + name: "create codespace that requires accepting additional permissions for devcontainer path", + fields: fields{ + apiClient: apiCreateDefaults(&apiClientMock{ + CreateCodespaceFunc: func(ctx context.Context, params *api.CreateCodespaceParams) (*api.Codespace, error) { + if params.Branch != "feature-branch" { + 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) + } + return &api.Codespace{}, api.AcceptPermissionsRequiredError{ + AllowPermissionsURL: "https://example.com/permissions?ref=feature-branch&devcontainer_path=.devcontainer/actions/devcontainer.json", + } + }, + }), + }, + opts: createOptions{ + repo: "monalisa/dotfiles", + branch: "feature-branch", + devContainerPath: ".devcontainer/actions/devcontainer.json", + machine: "GIGA", + showStatus: false, + idleTimeout: 30 * time.Minute, + }, + wantErr: cmdutil.SilentError, + wantStderr: ` ✓ Codespaces usage for this repository is paid for by monalisa +You must authorize or deny additional permissions requested by this codespace before continuing. +Open this URL in your browser to review and authorize additional permissions: https://example.com/permissions?ref=feature-branch&devcontainer_path=.devcontainer/actions/devcontainer.json Alternatively, you can run "create" with the "--default-permissions" option to continue without authorizing additional permissions. `, },