ronantakizawa/codereview-bench huggingface dataset:
Repository: cli/cli
File: pkg/cmd/codespace/ssh.go (Go)

Code before:
		}

		configuredPublicKeys = append(configuredPublicKeys, string(publicKeyContent))
	}

	if len(configuredPublicKeys) == 0 {
		// There are no local private keys which ssh would use
		return false
	}

	user, err := apiClient.GetUser(ctx)
	if err != nil {
		return false
	}

	uploadedPublicKeys, err := apiClient.AuthorizedKeys(ctx, user.Login)
	if err != nil {
		return false
	}

	if len(uploadedPublicKeys) == 0 {
		return false
	}

	for _, configuredPublicKey := range configuredPublicKeys {
		for _, uploadedPublicKey := range uploadedPublicKeys {
			if configuredPublicKey == uploadedPublicKey {
				return true
			}
		}
	}

	return false
}

// getConfiguredPrivateKeys reads the effective configuration for a localhost
// connection and returns all private keys which would be tried for authentication
func getConfiguredPrivateKeys(
	ctx context.Context,
	customConfigFile string,
	customHost string,
) ([]string, error) {
	sshExe, err := safeexec.LookPath("ssh")
	if err != nil {
		return nil, fmt.Errorf("could not find ssh executable: %w", err)
	}

	// The -G option tells ssh to output the effective config for the given host, but not connect
	sshGArgs := []string{"-G"}

	if customConfigFile != "" {

Review comment (suggestion):
This is probably not a problem, but it may be worth hashing `uploadedPublicKeys` into a `map[string]bool` and do O(1) lookups vs re-iterating them for every local key. Personally, I have a very little amount of SSH keys, but I know of users that generate a new key for almost everything.

Code after:

		publicKeyNew := filepath.Join(sshDir, automaticPrivateKeyName+".pub")
		err = os.Rename(publicKey, publicKeyNew)
		if err != nil {
			return nil
		}

		privateKeyNew := filepath.Join(sshDir, automaticPrivateKeyName)
		err = os.Rename(privateKey, privateKeyNew)
		if err != nil {
			return nil
		}

		keyPair := &ssh.KeyPair{
			PublicKeyPath:  publicKeyNew,
			PrivateKeyPath: privateKeyNew,
		}

		return keyPair
	}

	return nil
}

// hasUploadedValidCustomKey checks which private keys are used in ssh configration and
// compares them to uploaded public keys to see if there is a match
func hasUploadedPublicKeyForConfig(
	ctx context.Context,
	apiClient apiClient,
	customConfigFile string,
	customHost string,
) (bool, error) {
	configuredPrivateKeyPaths, err := getConfiguredPrivateKeys(ctx, customConfigFile, customHost)
	if err != nil {
		return false, fmt.Errorf("getting local ssh keys: %w", err)
	}

	configuredPublicKeys := make(map[string]bool)
	for _, privateKeyPath := range configuredPrivateKeyPaths {
		publicKeyPath := privateKeyPath + ".pub"

		publicKeyContent, err := os.ReadFile(publicKeyPath)
		if err != nil {
			// The default configuration includes standard keys like id_rsa or id_ed25519,
			// but these may not actually exist so just skip them
			continue
		}

		parts := strings.SplitN(string(publicKeyContent), " ", 3)
		if len(parts) < 2 {
			// Unexpected format, skip it
Repository: cli/cli
File: api/queries_repo.go (Go)

Code before:
// RepositoryV3 is the repository result from GitHub API v3
type repositoryV3 struct {
	NodeID    string `json:"node_id"`
	Name      string
	CreatedAt time.Time `json:"created_at"`
	Owner     struct {
		Login string
	}
	Private bool
	HTMLUrl string `json:"html_url"`
	Parent  *repositoryV3
}

// ForkRepo forks the repository on GitHub and returns the new repository
func ForkRepo(client *Client, repo ghrepo.Interface, org, newName string, defaultBranchOnly bool) (*Repository, error) {
	path := fmt.Sprintf("repos/%s/forks", ghrepo.FullName(repo))

	params := map[string]interface{}{}
	if org != "" {
		params["organization"] = org
	}
	if newName != "" {
		params["name"] = newName
	}
	if defaultBranchOnly {
		params["default_branch_only"] = "true"
	}

	body := &bytes.Buffer{}
	enc := json.NewEncoder(body)
	if err := enc.Encode(params); err != nil {
		return nil, err
	}

	result := repositoryV3{}
	err := client.REST(repo.RepoHost(), "POST", path, body, &result)
	if err != nil {
		return nil, err
	}

	newRepo := &Repository{
		ID:        result.NodeID,
		Name:      result.Name,
		CreatedAt: result.CreatedAt,
		Owner: RepositoryOwner{
			Login: result.Owner.Login,
		},
		ViewerPermission: "WRITE",
		hostname:         repo.RepoHost(),
	}


Review comment (suggestion):
`"true"` is a Go string and will serialize to JSON as a JSON string `"true"`. However, the API endpoint expects a JSON boolean. The easiest way to achieve a boolean being sent is to use a Go boolean `true`.

Code after:
// RepositoryV3 is the repository result from GitHub API v3
type repositoryV3 struct {
	NodeID    string `json:"node_id"`
	Name      string
	CreatedAt time.Time `json:"created_at"`
	Owner     struct {
		Login string
	}
	Private bool
	HTMLUrl string `json:"html_url"`
	Parent  *repositoryV3
}

// ForkRepo forks the repository on GitHub and returns the new repository
func ForkRepo(client *Client, repo ghrepo.Interface, org, newName string, defaultBranchOnly bool) (*Repository, error) {
	path := fmt.Sprintf("repos/%s/forks", ghrepo.FullName(repo))

	params := map[string]interface{}{}
	if org != "" {
		params["organization"] = org
	}
	if newName != "" {
		params["name"] = newName
	}
	if defaultBranchOnly {
		params["default_branch_only"] = true
	}

	body := &bytes.Buffer{}
	enc := json.NewEncoder(body)
	if err := enc.Encode(params); err != nil {
		return nil, err
	}

	result := repositoryV3{}
	err := client.REST(repo.RepoHost(), "POST", path, body, &result)
	if err != nil {
		return nil, err
	}

	newRepo := &Repository{
		ID:        result.NodeID,
		Name:      result.Name,
		CreatedAt: result.CreatedAt,
		Owner: RepositoryOwner{
			Login: result.Owner.Login,
		},
		ViewerPermission: "WRITE",
		hostname:         repo.RepoHost(),
	}
Repository: cli/cli
File: pkg/cmd/pr/create/create.go (Go)

Code before:
	"github.com/cli/cli/v2/pkg/cmd/pr/shared"
	"github.com/cli/cli/v2/pkg/cmdutil"
	"github.com/cli/cli/v2/pkg/iostreams"
	"github.com/spf13/cobra"
)

type CreateOptions struct {
	// This struct stores user input and factory functions
	HttpClient func() (*http.Client, error)
	GitClient  *git.Client
	Config     func() (config.Config, error)
	IO         *iostreams.IOStreams
	Remotes    func() (ghContext.Remotes, error)
	Branch     func() (string, error)
	Browser    browser.Browser
	Prompter   shared.Prompt
	Finder     shared.PRFinder

	TitleProvided bool
	BodyProvided  bool

	RootDirOverride string
	RepoOverride    string

	Autofill        bool
	AutofillVerbose bool
	FillFirst       bool
	WebMode         bool
	RecoverFile     string

	IsDraft    bool
	Title      string
	Body       string
	BaseBranch string
	HeadBranch string

	Reviewers []string
	Assignees []string
	Labels    []string
	Projects  []string
	Milestone string

	MaintainerCanModify bool
	Template            string
}

type CreateContext struct {
	// This struct stores contextual data about the creation process and is for building up enough
	// data to create a pull request
	RepoContext        *ghContext.ResolvedRemotes
	BaseRepo           *api.Repository

Review comment (suggestion):
I believe all flags that relate to auto fill drop the `Auto` portion of the flag internally like `FillFirst`.

Code after:
	"github.com/cli/cli/v2/pkg/cmd/pr/shared"
	"github.com/cli/cli/v2/pkg/cmdutil"
	"github.com/cli/cli/v2/pkg/iostreams"
	"github.com/spf13/cobra"
)

type CreateOptions struct {
	// This struct stores user input and factory functions
	HttpClient func() (*http.Client, error)
	GitClient  *git.Client
	Config     func() (config.Config, error)
	IO         *iostreams.IOStreams
	Remotes    func() (ghContext.Remotes, error)
	Branch     func() (string, error)
	Browser    browser.Browser
	Prompter   shared.Prompt
	Finder     shared.PRFinder

	TitleProvided bool
	BodyProvided  bool

	RootDirOverride string
	RepoOverride    string

	Autofill    bool
	FillVerbose bool
	FillFirst   bool
	WebMode     bool
	RecoverFile string

	IsDraft    bool
	Title      string
	Body       string
	BaseBranch string
	HeadBranch string

	Reviewers []string
	Assignees []string
	Labels    []string
	Projects  []string
	Milestone string

	MaintainerCanModify bool
	Template            string
}

type CreateContext struct {
	// This struct stores contextual data about the creation process and is for building up enough
	// data to create a pull request
	RepoContext        *ghContext.ResolvedRemotes
	BaseRepo           *api.Repository
Repository: cli/cli
File: pkg/cmd/pr/shared/survey.go (Go)

Code before:
	if err != nil {
		return err
	}

	if state.Body != result {
		state.MarkDirty()
	}

	state.Body = result

	return nil
}

func TitleSurvey(p Prompt, io *iostreams.IOStreams, state *IssueMetadataState) error {
	var err error
	result := ""
	for result == "" {
		result, err = p.Input("Title (required)", state.Title)
		if err != nil {
			return err
		}
		if result == "" {
			colorizeRed := io.ColorScheme().ColorFromString("red")
			msg := fmt.Sprintf("%s Title cannot be blank.", colorizeRed("X"))
			fmt.Fprintln(io.ErrOut, msg)
		}
	}

	if result != state.Title {
		state.MarkDirty()
	}

	state.Title = result

	return nil
}

type MetadataFetcher struct {
	IO        *iostreams.IOStreams
	APIClient *api.Client
	Repo      ghrepo.Interface
	State     *IssueMetadataState
}

func (mf *MetadataFetcher) RepoMetadataFetch(input api.RepoMetadataInput) (*api.RepoMetadataResult, error) {
	mf.IO.StartProgressIndicator()
	metadataResult, err := api.RepoMetadata(mf.APIClient, mf.Repo, input)
	mf.IO.StopProgressIndicator()
	mf.State.MetadataResult = metadataResult
	return metadataResult, err
}

Review comment (bug):
I think you mentioned this during discussion, but would love to see if we can get the following working being more `gh` idiomatic:

```suggestion
		if result == "" {
			fmt.Fprintf(io.ErrOut, "%s Title cannot be blank\n", io.ColorScheme().FailureIcon())
		}
```

Code after:
	if err != nil {
		return err
	}

	if state.Body != result {
		state.MarkDirty()
	}

	state.Body = result

	return nil
}

func TitleSurvey(p Prompt, io *iostreams.IOStreams, state *IssueMetadataState) error {
	var err error
	result := ""
	for result == "" {
		result, err = p.Input("Title (required)", state.Title)
		if err != nil {
			return err
		}
		if result == "" {
			fmt.Fprintf(io.ErrOut, "%s Title cannot be blank\n", io.ColorScheme().FailureIcon())
		}
	}

	if result != state.Title {
		state.MarkDirty()
	}

	state.Title = result

	return nil
}

type MetadataFetcher struct {
	IO        *iostreams.IOStreams
	APIClient *api.Client
	Repo      ghrepo.Interface
	State     *IssueMetadataState
}

func (mf *MetadataFetcher) RepoMetadataFetch(input api.RepoMetadataInput) (*api.RepoMetadataResult, error) {
	mf.IO.StartProgressIndicator()
	metadataResult, err := api.RepoMetadata(mf.APIClient, mf.Repo, input)
	mf.IO.StopProgressIndicator()
	mf.State.MetadataResult = metadataResult
	return metadataResult, err
}

type RepoMetadataFetcher interface {
Repository: cli/cli
File: pkg/cmd/pr/create/create.go (Go)

Code before:
	if err != nil && !errors.As(err, &notFound) {
		return fmt.Errorf("error checking for existing pull request: %w", err)
	}
	if err == nil {
		return fmt.Errorf("a pull request for branch %q into branch %q already exists:\n%s",
			ctx.HeadBranchLabel, ctx.BaseBranch, existingPR.URL)
	}

	message := "\nCreating pull request for %s into %s in %s\n\n"
	if state.Draft {
		message = "\nCreating draft pull request for %s into %s in %s\n\n"
	}
	if opts.DryRun {
		message = "\nDry Running pull request for %s into %s in %s\n\n"
	}

	cs := opts.IO.ColorScheme()

	if opts.IO.CanPrompt() {
		fmt.Fprintf(opts.IO.ErrOut, message,
			cs.Cyan(ctx.HeadBranchLabel),
			cs.Cyan(ctx.BaseBranch),
			ghrepo.FullName(ctx.BaseRepo))
	}

	if !opts.EditorMode && (opts.FillVerbose || opts.Autofill || opts.FillFirst || (opts.TitleProvided && opts.BodyProvided && ctx.BaseBranch != "")) {
		err = handlePush(*opts, *ctx)
		if err != nil {
			return
		}
		return submitPR(*opts, *ctx, *state)
	}

	if opts.RecoverFile != "" {
		err = shared.FillFromJSON(opts.IO, opts.RecoverFile, state)
		if err != nil {
			return fmt.Errorf("failed to recover input: %w", err)
		}
	}

	action := shared.SubmitAction
	if opts.IsDraft {
		action = shared.SubmitDraftAction
	}

	tpl := shared.NewTemplateManager(client.HTTP(), ctx.BaseRepo, opts.Prompter, opts.RootDirOverride, opts.RepoOverride == "", true)

	if opts.EditorMode {
		if opts.Template != "" {
			var template shared.Template
			template, err = tpl.Select(opts.Template)

Review comment (suggestion):
**Question**

Can `ctx.BaseBranch` ever be `""` under usual circumstances at this point? It seems like various things prior and after assume that it has a value.

Code after:
	}
	if err == nil {
		return fmt.Errorf("a pull request for branch %q into branch %q already exists:\n%s",
			ctx.HeadBranchLabel, ctx.BaseBranch, existingPR.URL)
	}

	message := "\nCreating pull request for %s into %s in %s\n\n"
	if state.Draft {
		message = "\nCreating draft pull request for %s into %s in %s\n\n"
	}
	if opts.DryRun {
		message = "\nDry Running pull request for %s into %s in %s\n\n"
	}

	cs := opts.IO.ColorScheme()

	if opts.IO.CanPrompt() {
		fmt.Fprintf(opts.IO.ErrOut, message,
			cs.Cyan(ctx.HeadBranchLabel),
			cs.Cyan(ctx.BaseBranch),
			ghrepo.FullName(ctx.BaseRepo))
	}

	if !opts.EditorMode && (opts.FillVerbose || opts.Autofill || opts.FillFirst || (opts.TitleProvided && opts.BodyProvided)) {
		err = handlePush(*opts, *ctx)
		if err != nil {
			return
		}
		return submitPR(*opts, *ctx, *state)
	}

	if opts.RecoverFile != "" {
		err = shared.FillFromJSON(opts.IO, opts.RecoverFile, state)
		if err != nil {
			return fmt.Errorf("failed to recover input: %w", err)
		}
	}

	action := shared.SubmitAction
	if opts.IsDraft {
		action = shared.SubmitDraftAction
	}

	tpl := shared.NewTemplateManager(client.HTTP(), ctx.BaseRepo, opts.Prompter, opts.RootDirOverride, opts.RepoOverride == "", true)

	if opts.EditorMode {
		if opts.Template != "" {
			var template shared.Template
			template, err = tpl.Select(opts.Template)
			if err != nil {
				return
Repository: cli/cli
File: internal/featuredetection/feature_detection_test.go (Go)

Code before:
	"net/http"
	"testing"

	"github.com/MakeNowJust/heredoc"
	"github.com/cli/cli/v2/pkg/httpmock"
	"github.com/stretchr/testify/assert"
)

func TestIssueFeatures(t *testing.T) {
	tests := []struct {
		name          string
		hostname      string
		queryResponse map[string]string
		wantFeatures  IssueFeatures
		wantErr       bool
	}{
		{
			name:     "github.com",
			hostname: "github.com",
			wantFeatures: IssueFeatures{
				StateReason: true,
			},
			wantErr: false,
		},
		{
			name:     "ghec data residency (proxima)",
			hostname: "stampname.ghe.com",
			wantFeatures: IssueFeatures{
				StateReason: true,
			},
			wantErr: false,
		},
		{
			name:     "GHE empty response",
			hostname: "git.my.org",
			queryResponse: map[string]string{
				`query Issue_fields\b`: `{"data": {}}`,
			},
			wantFeatures: IssueFeatures{
				StateReason: false,
			},
			wantErr: false,
		},
		{
			name:     "GHE has state reason field",
			hostname: "git.my.org",
			queryResponse: map[string]string{
				`query Issue_fields\b`: heredoc.Doc(`
					{ "data": { "Issue": { "fields": [
						{"name": "stateReason"}
					] } } }

Review comment (suggestion):
```suggestion
			name:     "ghec data residency (ghe.com)",
```

Code after:
	"net/http"
	"testing"

	"github.com/MakeNowJust/heredoc"
	"github.com/cli/cli/v2/pkg/httpmock"
	"github.com/stretchr/testify/assert"
)

func TestIssueFeatures(t *testing.T) {
	tests := []struct {
		name          string
		hostname      string
		queryResponse map[string]string
		wantFeatures  IssueFeatures
		wantErr       bool
	}{
		{
			name:     "github.com",
			hostname: "github.com",
			wantFeatures: IssueFeatures{
				StateReason: true,
			},
			wantErr: false,
		},
		{
			name:     "ghec data residency (ghe.com)",
			hostname: "stampname.ghe.com",
			wantFeatures: IssueFeatures{
				StateReason: true,
			},
			wantErr: false,
		},
		{
			name:     "GHE empty response",
			hostname: "git.my.org",
			queryResponse: map[string]string{
				`query Issue_fields\b`: `{"data": {}}`,
			},
			wantFeatures: IssueFeatures{
				StateReason: false,
			},
			wantErr: false,
		},
		{
			name:     "GHE has state reason field",
			hostname: "git.my.org",
			queryResponse: map[string]string{
				`query Issue_fields\b`: heredoc.Doc(`
					{ "data": { "Issue": { "fields": [
						{"name": "stateReason"}
					] } } }
Repository: cli/cli
File: internal/featuredetection/feature_detection_test.go (Go)

Code before:
			assert.NoError(t, err)
			assert.Equal(t, tt.wantFeatures, gotFeatures)
		})
	}
}

func TestRepositoryFeatures(t *testing.T) {
	tests := []struct {
		name          string
		hostname      string
		queryResponse map[string]string
		wantFeatures  RepositoryFeatures
		wantErr       bool
	}{
		{
			name:     "github.com",
			hostname: "github.com",
			wantFeatures: RepositoryFeatures{
				PullRequestTemplateQuery: true,
				VisibilityField:          true,
				AutoMerge:                true,
			},
			wantErr: false,
		},
		{
			name:     "ghec data residency (proxima)",
			hostname: "stampname.ghe.com",
			wantFeatures: RepositoryFeatures{
				PullRequestTemplateQuery: true,
				VisibilityField:          true,
				AutoMerge:                true,
			},
			wantErr: false,
		},
		{
			name:     "GHE empty response",
			hostname: "git.my.org",
			queryResponse: map[string]string{
				`query Repository_fields\b`: `{"data": {}}`,
			},
			wantFeatures: RepositoryFeatures{
				PullRequestTemplateQuery: false,
			},
			wantErr: false,
		},
		{
			name:     "GHE has pull request template query",
			hostname: "git.my.org",
			queryResponse: map[string]string{
				`query Repository_fields\b`: heredoc.Doc(`
					{ "data": { "Repository": { "fields": [

Review comment (suggestion):
```suggestion
			name:     "ghec data residency (ghe.com)",
```

Code after:
			assert.NoError(t, err)
			assert.Equal(t, tt.wantFeatures, gotFeatures)
		})
	}
}

func TestRepositoryFeatures(t *testing.T) {
	tests := []struct {
		name          string
		hostname      string
		queryResponse map[string]string
		wantFeatures  RepositoryFeatures
		wantErr       bool
	}{
		{
			name:     "github.com",
			hostname: "github.com",
			wantFeatures: RepositoryFeatures{
				PullRequestTemplateQuery: true,
				VisibilityField:          true,
				AutoMerge:                true,
			},
			wantErr: false,
		},
		{
			name:     "ghec data residency (ghe.com)",
			hostname: "stampname.ghe.com",
			wantFeatures: RepositoryFeatures{
				PullRequestTemplateQuery: true,
				VisibilityField:          true,
				AutoMerge:                true,
			},
			wantErr: false,
		},
		{
			name:     "GHE empty response",
			hostname: "git.my.org",
			queryResponse: map[string]string{
				`query Repository_fields\b`: `{"data": {}}`,
			},
			wantFeatures: RepositoryFeatures{
				PullRequestTemplateQuery: false,
			},
			wantErr: false,
		},
		{
			name:     "GHE has pull request template query",
			hostname: "git.my.org",
			queryResponse: map[string]string{
				`query Repository_fields\b`: heredoc.Doc(`
					{ "data": { "Repository": { "fields": [
Repository: cli/cli
File: pkg/cmd/gist/clone/clone_test.go (Go)

Code before:
	}
	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",
		},
		{
			name: "ghec data residency (proxima) HTTPS",
			args: args{
				hostname: "stampname.ghe.com",
				protocol: "https",
				gistID:   "ID",
			},
			want: "https://stampname.ghe.com/gist/ID.git",
		},
		{
			name: "ghec data residency (proxima) SSH",
			args: args{
				hostname: "stampname.ghe.com",
				protocol: "ssh",
				gistID:   "ID",
			},
			want: "git@stampname.ghe.com:gist/ID.git",
		},
		{
			name: "Enterprise HTTPS",
			args: args{
				hostname: "acme.org",
				protocol: "https",
				gistID:   "ID",
			},
			want: "https://acme.org/gist/ID.git",
		},

Review comment (suggestion):
```suggestion
			name: "ghec data residency (ghe.com) HTTPS",
```

Code after:
	}
	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",
		},
		{
			name: "Enterprise HTTPS",
			args: args{
				hostname: "acme.org",
				protocol: "https",
				gistID:   "ID",
			},
			want: "https://acme.org/gist/ID.git",
		},
		{
			name: "Enterprise SSH",
			args: args{
				hostname: "acme.org",
				protocol: "ssh",
				gistID:   "ID",
			},
			want: "git@acme.org:gist/ID.git",
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := formatRemoteURL(tt.args.hostname, tt.args.gistID, tt.args.protocol); got != tt.want {
				t.Errorf("formatRemoteURL() = %v, want %v", got, tt.want)
			}
		})
	}
}
Repository: cli/cli
File: pkg/cmd/gist/clone/clone_test.go (Go)

Code before:
				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",
		},
		{
			name: "ghec data residency (proxima) HTTPS",
			args: args{
				hostname: "stampname.ghe.com",
				protocol: "https",
				gistID:   "ID",
			},
			want: "https://stampname.ghe.com/gist/ID.git",
		},
		{
			name: "ghec data residency (proxima) SSH",
			args: args{
				hostname: "stampname.ghe.com",
				protocol: "ssh",
				gistID:   "ID",
			},
			want: "git@stampname.ghe.com:gist/ID.git",
		},
		{
			name: "Enterprise HTTPS",
			args: args{
				hostname: "acme.org",
				protocol: "https",
				gistID:   "ID",
			},
			want: "https://acme.org/gist/ID.git",
		},
		{
			name: "Enterprise SSH",
			args: args{
				hostname: "acme.org",
				protocol: "ssh",
				gistID:   "ID",
			},
			want: "git@acme.org:gist/ID.git",
		},

Review comment (suggestion):
```suggestion
			name: "ghec data residency (ghe.com) SSH",
```

Code after:
				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",
		},
		{
			name: "Enterprise HTTPS",
			args: args{
				hostname: "acme.org",
				protocol: "https",
				gistID:   "ID",
			},
			want: "https://acme.org/gist/ID.git",
		},
		{
			name: "Enterprise SSH",
			args: args{
				hostname: "acme.org",
				protocol: "ssh",
				gistID:   "ID",
			},
			want: "git@acme.org:gist/ID.git",
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := formatRemoteURL(tt.args.hostname, tt.args.gistID, tt.args.protocol); got != tt.want {
				t.Errorf("formatRemoteURL() = %v, want %v", got, tt.want)
			}
		})
	}
}