Move config interfaces into gh package (#9060)
This commit is contained in:
parent
2543c22463
commit
1d38230675
146 changed files with 665 additions and 463 deletions
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/docs"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/root"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -48,7 +49,7 @@ func run(args []string) error {
|
|||
rootCmd, _ := root.NewCmdRoot(&cmdutil.Factory{
|
||||
IOStreams: ios,
|
||||
Browser: &browser{},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewFromString(""), nil
|
||||
},
|
||||
ExtensionManager: &em{},
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
ghmock "github.com/cli/cli/v2/internal/gh/mock"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
)
|
||||
|
||||
|
|
@ -137,13 +139,13 @@ func createHttpClient() (*http.Client, error) {
|
|||
func TestNew_APIURL_dotcomConfig(t *testing.T) {
|
||||
t.Setenv("GITHUB_API_URL", "")
|
||||
t.Setenv("GITHUB_SERVER_URL", "https://github.com")
|
||||
cfg := &config.ConfigMock{
|
||||
AuthenticationFunc: func() *config.AuthConfig {
|
||||
cfg := &ghmock.ConfigMock{
|
||||
AuthenticationFunc: func() gh.AuthConfig {
|
||||
return &config.AuthConfig{}
|
||||
},
|
||||
}
|
||||
f := &cmdutil.Factory{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
},
|
||||
}
|
||||
|
|
@ -160,15 +162,15 @@ func TestNew_APIURL_dotcomConfig(t *testing.T) {
|
|||
func TestNew_APIURL_customConfig(t *testing.T) {
|
||||
t.Setenv("GITHUB_API_URL", "")
|
||||
t.Setenv("GITHUB_SERVER_URL", "https://github.mycompany.com")
|
||||
cfg := &config.ConfigMock{
|
||||
AuthenticationFunc: func() *config.AuthConfig {
|
||||
cfg := &ghmock.ConfigMock{
|
||||
AuthenticationFunc: func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetDefaultHost("github.mycompany.com", "GH_HOST")
|
||||
return authCfg
|
||||
},
|
||||
}
|
||||
f := &cmdutil.Factory{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
},
|
||||
}
|
||||
|
|
@ -185,13 +187,13 @@ func TestNew_APIURL_customConfig(t *testing.T) {
|
|||
func TestNew_APIURL_env(t *testing.T) {
|
||||
t.Setenv("GITHUB_API_URL", "https://api.mycompany.com")
|
||||
t.Setenv("GITHUB_SERVER_URL", "https://mycompany.com")
|
||||
cfg := &config.ConfigMock{
|
||||
AuthenticationFunc: func() *config.AuthConfig {
|
||||
cfg := &ghmock.ConfigMock{
|
||||
AuthenticationFunc: func() gh.AuthConfig {
|
||||
return &config.AuthConfig{}
|
||||
},
|
||||
}
|
||||
f := &cmdutil.Factory{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
},
|
||||
}
|
||||
|
|
@ -208,7 +210,7 @@ func TestNew_APIURL_env(t *testing.T) {
|
|||
func TestNew_APIURL_dotcomFallback(t *testing.T) {
|
||||
t.Setenv("GITHUB_API_URL", "")
|
||||
f := &cmdutil.Factory{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return nil, errors.New("Failed to load")
|
||||
},
|
||||
}
|
||||
|
|
@ -222,13 +224,13 @@ func TestNew_APIURL_dotcomFallback(t *testing.T) {
|
|||
func TestNew_ServerURL_dotcomConfig(t *testing.T) {
|
||||
t.Setenv("GITHUB_SERVER_URL", "")
|
||||
t.Setenv("GITHUB_API_URL", "https://api.github.com")
|
||||
cfg := &config.ConfigMock{
|
||||
AuthenticationFunc: func() *config.AuthConfig {
|
||||
cfg := &ghmock.ConfigMock{
|
||||
AuthenticationFunc: func() gh.AuthConfig {
|
||||
return &config.AuthConfig{}
|
||||
},
|
||||
}
|
||||
f := &cmdutil.Factory{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
},
|
||||
}
|
||||
|
|
@ -245,15 +247,15 @@ func TestNew_ServerURL_dotcomConfig(t *testing.T) {
|
|||
func TestNew_ServerURL_customConfig(t *testing.T) {
|
||||
t.Setenv("GITHUB_SERVER_URL", "")
|
||||
t.Setenv("GITHUB_API_URL", "https://github.mycompany.com/api/v3")
|
||||
cfg := &config.ConfigMock{
|
||||
AuthenticationFunc: func() *config.AuthConfig {
|
||||
cfg := &ghmock.ConfigMock{
|
||||
AuthenticationFunc: func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetDefaultHost("github.mycompany.com", "GH_HOST")
|
||||
return authCfg
|
||||
},
|
||||
}
|
||||
f := &cmdutil.Factory{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
},
|
||||
}
|
||||
|
|
@ -270,13 +272,13 @@ func TestNew_ServerURL_customConfig(t *testing.T) {
|
|||
func TestNew_ServerURL_env(t *testing.T) {
|
||||
t.Setenv("GITHUB_SERVER_URL", "https://mycompany.com")
|
||||
t.Setenv("GITHUB_API_URL", "https://api.mycompany.com")
|
||||
cfg := &config.ConfigMock{
|
||||
AuthenticationFunc: func() *config.AuthConfig {
|
||||
cfg := &ghmock.ConfigMock{
|
||||
AuthenticationFunc: func() gh.AuthConfig {
|
||||
return &config.AuthConfig{}
|
||||
},
|
||||
}
|
||||
f := &cmdutil.Factory{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
},
|
||||
}
|
||||
|
|
@ -293,7 +295,7 @@ func TestNew_ServerURL_env(t *testing.T) {
|
|||
func TestNew_ServerURL_dotcomFallback(t *testing.T) {
|
||||
t.Setenv("GITHUB_SERVER_URL", "")
|
||||
f := &cmdutil.Factory{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return nil, errors.New("Failed to load")
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
// Note that NewIsolatedTestConfig sets up a Mock keyring as well
|
||||
func newTestAuthConfig(t *testing.T) *AuthConfig {
|
||||
cfg, _ := NewIsolatedTestConfig(t)
|
||||
return cfg.Authentication()
|
||||
return &AuthConfig{cfg: cfg.cfg}
|
||||
}
|
||||
|
||||
func TestTokenFromKeyring(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"path/filepath"
|
||||
"slices"
|
||||
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/keyring"
|
||||
ghAuth "github.com/cli/go-gh/v2/pkg/auth"
|
||||
ghConfig "github.com/cli/go-gh/v2/pkg/config"
|
||||
|
|
@ -27,49 +28,7 @@ const (
|
|||
versionKey = "version"
|
||||
)
|
||||
|
||||
// This interface describes interacting with some persistent configuration for gh.
|
||||
//
|
||||
//go:generate moq -rm -out config_mock.go . Config
|
||||
type Config interface {
|
||||
GetOrDefault(string, string) (string, error)
|
||||
Set(string, string, string)
|
||||
Write() error
|
||||
Migrate(Migration) error
|
||||
|
||||
CacheDir() string
|
||||
|
||||
Aliases() *AliasConfig
|
||||
Authentication() *AuthConfig
|
||||
Browser(string) string
|
||||
Editor(string) string
|
||||
GitProtocol(string) string
|
||||
HTTPUnixSocket(string) string
|
||||
Pager(string) string
|
||||
Prompt(string) string
|
||||
Version() string
|
||||
}
|
||||
|
||||
// Migration is the interface that config migrations must implement.
|
||||
//
|
||||
// Migrations will receive a copy of the config, and should modify that copy
|
||||
// as necessary. After migration has completed, the modified config contents
|
||||
// will be used.
|
||||
//
|
||||
// The calling code is expected to verify that the current version of the config
|
||||
// matches the PreVersion of the migration before calling Do, and will set the
|
||||
// config version to the PostVersion after the migration has completed successfully.
|
||||
//
|
||||
//go:generate moq -rm -out migration_mock.go . Migration
|
||||
type Migration interface {
|
||||
// PreVersion is the required config version for this to be applied
|
||||
PreVersion() string
|
||||
// PostVersion is the config version that must be applied after migration
|
||||
PostVersion() string
|
||||
// Do is expected to apply any necessary changes to the config in place
|
||||
Do(*ghConfig.Config) error
|
||||
}
|
||||
|
||||
func NewConfig() (Config, error) {
|
||||
func NewConfig() (gh.Config, error) {
|
||||
c, err := ghConfig.Read(fallbackConfig())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -123,11 +82,11 @@ func (c *cfg) Write() error {
|
|||
return ghConfig.Write(c.cfg)
|
||||
}
|
||||
|
||||
func (c *cfg) Aliases() *AliasConfig {
|
||||
func (c *cfg) Aliases() gh.AliasConfig {
|
||||
return &AliasConfig{cfg: c.cfg}
|
||||
}
|
||||
|
||||
func (c *cfg) Authentication() *AuthConfig {
|
||||
func (c *cfg) Authentication() gh.AuthConfig {
|
||||
return &AuthConfig{cfg: c.cfg}
|
||||
}
|
||||
|
||||
|
|
@ -166,7 +125,7 @@ func (c *cfg) Version() string {
|
|||
return val
|
||||
}
|
||||
|
||||
func (c *cfg) Migrate(m Migration) error {
|
||||
func (c *cfg) Migrate(m gh.Migration) error {
|
||||
version := c.Version()
|
||||
|
||||
// If migration has already occurred then do not attempt to migrate again.
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
ghmock "github.com/cli/cli/v2/internal/gh/mock"
|
||||
ghConfig "github.com/cli/go-gh/v2/pkg/config"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
|
@ -60,7 +61,7 @@ func TestMigrationAppliedBumpsVersion(t *testing.T) {
|
|||
c.Set([]string{versionKey}, "expected-pre-version")
|
||||
topLevelKey := []string{"toplevelkey"}
|
||||
|
||||
migration := &MigrationMock{
|
||||
migration := &ghmock.MigrationMock{
|
||||
DoFunc: func(config *ghConfig.Config) error {
|
||||
config.Set(topLevelKey, "toplevelvalue")
|
||||
return nil
|
||||
|
|
@ -96,7 +97,7 @@ func TestMigrationIsNoopWhenAlreadyApplied(t *testing.T) {
|
|||
c := ghConfig.ReadFromString(testFullConfig())
|
||||
c.Set([]string{versionKey}, "expected-post-version")
|
||||
|
||||
migration := &MigrationMock{
|
||||
migration := &ghmock.MigrationMock{
|
||||
DoFunc: func(config *ghConfig.Config) error {
|
||||
return errors.New("is not called")
|
||||
},
|
||||
|
|
@ -126,7 +127,7 @@ func TestMigrationErrorsWhenPreVersionMismatch(t *testing.T) {
|
|||
c.Set([]string{versionKey}, "not-expected-pre-version")
|
||||
topLevelKey := []string{"toplevelkey"}
|
||||
|
||||
migration := &MigrationMock{
|
||||
migration := &ghmock.MigrationMock{
|
||||
DoFunc: func(config *ghConfig.Config) error {
|
||||
config.Set(topLevelKey, "toplevelvalue")
|
||||
return nil
|
||||
|
|
@ -228,8 +229,8 @@ func makeFileUnwriteable(t *testing.T, file string) {
|
|||
require.NoError(t, os.Chmod(file, 0000))
|
||||
}
|
||||
|
||||
func mockMigration(doFunc func(config *ghConfig.Config) error) *MigrationMock {
|
||||
return &MigrationMock{
|
||||
func mockMigration(doFunc func(config *ghConfig.Config) error) *ghmock.MigrationMock {
|
||||
return &ghmock.MigrationMock{
|
||||
DoFunc: doFunc,
|
||||
PreVersionFunc: func() string {
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -6,18 +6,20 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
ghmock "github.com/cli/cli/v2/internal/gh/mock"
|
||||
"github.com/cli/cli/v2/internal/keyring"
|
||||
ghConfig "github.com/cli/go-gh/v2/pkg/config"
|
||||
)
|
||||
|
||||
func NewBlankConfig() *ConfigMock {
|
||||
func NewBlankConfig() *ghmock.ConfigMock {
|
||||
return NewFromString(defaultConfigStr)
|
||||
}
|
||||
|
||||
func NewFromString(cfgStr string) *ConfigMock {
|
||||
func NewFromString(cfgStr string) *ghmock.ConfigMock {
|
||||
c := ghConfig.ReadFromString(cfgStr)
|
||||
cfg := cfg{c}
|
||||
mock := &ConfigMock{}
|
||||
mock := &ghmock.ConfigMock{}
|
||||
mock.GetOrDefaultFunc = func(host, key string) (string, error) {
|
||||
return cfg.GetOrDefault(host, key)
|
||||
}
|
||||
|
|
@ -27,13 +29,13 @@ func NewFromString(cfgStr string) *ConfigMock {
|
|||
mock.WriteFunc = func() error {
|
||||
return cfg.Write()
|
||||
}
|
||||
mock.MigrateFunc = func(m Migration) error {
|
||||
mock.MigrateFunc = func(m gh.Migration) error {
|
||||
return cfg.Migrate(m)
|
||||
}
|
||||
mock.AliasesFunc = func() *AliasConfig {
|
||||
mock.AliasesFunc = func() gh.AliasConfig {
|
||||
return &AliasConfig{cfg: c}
|
||||
}
|
||||
mock.AuthenticationFunc = func() *AuthConfig {
|
||||
mock.AuthenticationFunc = func() gh.AuthConfig {
|
||||
return &AuthConfig{
|
||||
cfg: c,
|
||||
defaultHostOverride: func() (string, string) {
|
||||
|
|
@ -88,7 +90,7 @@ func NewFromString(cfgStr string) *ConfigMock {
|
|||
// in the real implementation, sets the GH_CONFIG_DIR env var so that
|
||||
// any call to Write goes to a different location on disk, and then returns
|
||||
// the blank config and a function that reads any data written to disk.
|
||||
func NewIsolatedTestConfig(t *testing.T) (Config, func(io.Writer, io.Writer)) {
|
||||
func NewIsolatedTestConfig(t *testing.T) (*cfg, func(io.Writer, io.Writer)) {
|
||||
keyring.MockInit()
|
||||
|
||||
c := ghConfig.ReadFromString("")
|
||||
|
|
|
|||
158
internal/gh/gh.go
Normal file
158
internal/gh/gh.go
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
// Package gh provides types that represent the domain of the CLI application.
|
||||
//
|
||||
// For example, the CLI expects to be able to get and set user configuration in order to perform its functionality,
|
||||
// so the Config interface is defined here, though the concrete implementation lives elsewhere. Though the current
|
||||
// implementation of config writes to certain files on disk, that is an implementation detail compared to the contract
|
||||
// laid out in the interface here.
|
||||
//
|
||||
// Currently this package is in an early state but we could imagine other domain concepts living here for interacting
|
||||
// with git or GitHub.
|
||||
package gh
|
||||
|
||||
import (
|
||||
ghConfig "github.com/cli/go-gh/v2/pkg/config"
|
||||
)
|
||||
|
||||
// A Config implements persistent storage and modification of application configuration.
|
||||
//
|
||||
//go:generate moq -rm -pkg ghmock -out mock/config.go . Config
|
||||
type Config interface {
|
||||
// GetOrDefault provides primitive access for fetching configuration values, optionally scoped by host.
|
||||
GetOrDefault(hostname string, key string) (string, error)
|
||||
// Set provides primitive access for setting configuration values, optionally scoped by host.
|
||||
Set(hostname string, key string, value string)
|
||||
|
||||
// Browser returns the configured browser, optionally scoped by host.
|
||||
Browser(hostname string) string
|
||||
// Editor returns the configured editor, optionally scoped by host.
|
||||
Editor(hostname string) string
|
||||
// GitProtocol returns the configured git protocol, optionally scoped by host.
|
||||
GitProtocol(hostname string) string
|
||||
// HTTPUnixSocket returns the configured HTTP unix socket, optionally scoped by host.
|
||||
HTTPUnixSocket(hostname string) string
|
||||
// Pager returns the configured Pager, optionally scoped by host.
|
||||
Pager(hostname string) string
|
||||
// Prompt returns the configured prompt, optionally scoped by host.
|
||||
Prompt(hostname string) string
|
||||
|
||||
// Aliases provides persistent storage and modification of command aliases.
|
||||
Aliases() AliasConfig
|
||||
|
||||
// Authentication provides persistent storage and modification of authentication configuration.
|
||||
Authentication() AuthConfig
|
||||
|
||||
// CacheDir returns the directory where the cacheable artifacts can be persisted.
|
||||
CacheDir() string
|
||||
|
||||
// Migrate applies a migration to the configuration.
|
||||
Migrate(Migration) error
|
||||
|
||||
// Version returns the current schema version of the configuration.
|
||||
Version() string
|
||||
|
||||
// Write persists modifications to the configuration.
|
||||
Write() error
|
||||
}
|
||||
|
||||
// Migration is the interface that config migrations must implement.
|
||||
//
|
||||
// Migrations will receive a copy of the config, and should modify that copy
|
||||
// as necessary. After migration has completed, the modified config contents
|
||||
// will be used.
|
||||
//
|
||||
// The calling code is expected to verify that the current version of the config
|
||||
// matches the PreVersion of the migration before calling Do, and will set the
|
||||
// config version to the PostVersion after the migration has completed successfully.
|
||||
//
|
||||
//go:generate moq -rm -pkg ghmock -out mock/migration.go . Migration
|
||||
type Migration interface {
|
||||
// PreVersion is the required config version for this to be applied
|
||||
PreVersion() string
|
||||
// PostVersion is the config version that must be applied after migration
|
||||
PostVersion() string
|
||||
// Do is expected to apply any necessary changes to the config in place
|
||||
Do(*ghConfig.Config) error
|
||||
}
|
||||
|
||||
// AuthConfig is used for interacting with some persistent configuration for gh,
|
||||
// with knowledge on how to access encrypted storage when neccesarry.
|
||||
// Behavior is scoped to authentication specific tasks.
|
||||
type AuthConfig interface {
|
||||
// ActiveToken will retrieve the active auth token for the given hostname, searching environment variables,
|
||||
// general configuration, and finally encrypted storage.
|
||||
ActiveToken(hostname string) (token string, source string)
|
||||
|
||||
// HasEnvToken returns true when a token has been specified in an environment variable, else returns false.
|
||||
HasEnvToken() bool
|
||||
|
||||
// TokenFromKeyring will retrieve the auth token for the given hostname, only searching in encrypted storage.
|
||||
TokenFromKeyring(hostname string) (token string, err error)
|
||||
|
||||
// TokenFromKeyringForUser will retrieve the auth token for the given hostname and username, only searching
|
||||
// in encrypted storage.
|
||||
//
|
||||
// An empty username will return an error because the potential to return the currently active token under
|
||||
// surprising cases is just too high to risk compared to the utility of having the function being smart.
|
||||
TokenFromKeyringForUser(hostname, username string) (token string, err error)
|
||||
|
||||
// ActiveUser will retrieve the username for the active user at the given hostname.
|
||||
//
|
||||
// This will not be accurate if the oauth token is set from an environment variable.
|
||||
ActiveUser(hostname string) (username string, err error)
|
||||
|
||||
// Hosts retrieves a list of known hosts.
|
||||
Hosts() []string
|
||||
|
||||
// DefaultHost retrieves the default host.
|
||||
DefaultHost() (host string, source string)
|
||||
|
||||
// Login will set user, git protocol, and auth token for the given hostname.
|
||||
//
|
||||
// If the encrypt option is specified it will first try to store the auth token
|
||||
// in encrypted storage and will fall back to the general insecure configuration.
|
||||
Login(hostname, username, token, gitProtocol string, secureStorage bool) (insecureStorageUsed bool, err error)
|
||||
|
||||
// SwitchUser switches the active user for a given hostname.
|
||||
SwitchUser(hostname, user string) error
|
||||
|
||||
// Logout will remove user, git protocol, and auth token for the given hostname.
|
||||
// It will remove the auth token from the encrypted storage if it exists there.
|
||||
Logout(hostname, username string) error
|
||||
|
||||
// UsersForHost retrieves a list of users configured for a specific host.
|
||||
UsersForHost(hostname string) []string
|
||||
|
||||
// TokenForUser retrieves the authentication token and its source for a specified user and hostname.
|
||||
TokenForUser(hostname, user string) (token string, source string, err error)
|
||||
|
||||
// The following methods are only for testing and that is a design smell we should consider fixing.
|
||||
|
||||
// SetActiveToken will override any token resolution and return the given token and source for all calls to
|
||||
// ActiveToken.
|
||||
// Use for testing purposes only.
|
||||
SetActiveToken(token, source string)
|
||||
|
||||
// SetHosts will override any hosts resolution and return the given hosts for all calls to Hosts.
|
||||
// Use for testing purposes only.
|
||||
SetHosts(hosts []string)
|
||||
|
||||
// SetDefaultHost will override any host resolution and return the given host and source for all calls to
|
||||
// DefaultHost.
|
||||
// Use for testing purposes only.
|
||||
SetDefaultHost(host, source string)
|
||||
}
|
||||
|
||||
// AliasConfig defines an interface for managing command aliases.
|
||||
type AliasConfig interface {
|
||||
// Get retrieves the expansion for a specified alias.
|
||||
Get(alias string) (expansion string, err error)
|
||||
|
||||
// Add adds a new alias with the specified expansion.
|
||||
Add(alias, expansion string)
|
||||
|
||||
// Delete removes an alias.
|
||||
Delete(alias string) error
|
||||
|
||||
// All returns a map of all aliases to their corresponding expansions.
|
||||
All() map[string]string
|
||||
}
|
||||
|
|
@ -1,26 +1,27 @@
|
|||
// Code generated by moq; DO NOT EDIT.
|
||||
// github.com/matryer/moq
|
||||
|
||||
package config
|
||||
package ghmock
|
||||
|
||||
import (
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Ensure, that ConfigMock does implement Config.
|
||||
// Ensure, that ConfigMock does implement gh.Config.
|
||||
// If this is not the case, regenerate this file with moq.
|
||||
var _ Config = &ConfigMock{}
|
||||
var _ gh.Config = &ConfigMock{}
|
||||
|
||||
// ConfigMock is a mock implementation of Config.
|
||||
// ConfigMock is a mock implementation of gh.Config.
|
||||
//
|
||||
// func TestSomethingThatUsesConfig(t *testing.T) {
|
||||
//
|
||||
// // make and configure a mocked Config
|
||||
// // make and configure a mocked gh.Config
|
||||
// mockedConfig := &ConfigMock{
|
||||
// AliasesFunc: func() *AliasConfig {
|
||||
// AliasesFunc: func() gh.AliasConfig {
|
||||
// panic("mock out the Aliases method")
|
||||
// },
|
||||
// AuthenticationFunc: func() *AuthConfig {
|
||||
// AuthenticationFunc: func() gh.AuthConfig {
|
||||
// panic("mock out the Authentication method")
|
||||
// },
|
||||
// BrowserFunc: func(s string) string {
|
||||
|
|
@ -41,7 +42,7 @@ var _ Config = &ConfigMock{}
|
|||
// HTTPUnixSocketFunc: func(s string) string {
|
||||
// panic("mock out the HTTPUnixSocket method")
|
||||
// },
|
||||
// MigrateFunc: func(migration Migration) error {
|
||||
// MigrateFunc: func(migration gh.Migration) error {
|
||||
// panic("mock out the Migrate method")
|
||||
// },
|
||||
// PagerFunc: func(s string) string {
|
||||
|
|
@ -61,16 +62,16 @@ var _ Config = &ConfigMock{}
|
|||
// },
|
||||
// }
|
||||
//
|
||||
// // use mockedConfig in code that requires Config
|
||||
// // use mockedConfig in code that requires gh.Config
|
||||
// // and then make assertions.
|
||||
//
|
||||
// }
|
||||
type ConfigMock struct {
|
||||
// AliasesFunc mocks the Aliases method.
|
||||
AliasesFunc func() *AliasConfig
|
||||
AliasesFunc func() gh.AliasConfig
|
||||
|
||||
// AuthenticationFunc mocks the Authentication method.
|
||||
AuthenticationFunc func() *AuthConfig
|
||||
AuthenticationFunc func() gh.AuthConfig
|
||||
|
||||
// BrowserFunc mocks the Browser method.
|
||||
BrowserFunc func(s string) string
|
||||
|
|
@ -91,7 +92,7 @@ type ConfigMock struct {
|
|||
HTTPUnixSocketFunc func(s string) string
|
||||
|
||||
// MigrateFunc mocks the Migrate method.
|
||||
MigrateFunc func(migration Migration) error
|
||||
MigrateFunc func(migration gh.Migration) error
|
||||
|
||||
// PagerFunc mocks the Pager method.
|
||||
PagerFunc func(s string) string
|
||||
|
|
@ -149,7 +150,7 @@ type ConfigMock struct {
|
|||
// Migrate holds details about calls to the Migrate method.
|
||||
Migrate []struct {
|
||||
// Migration is the migration argument value.
|
||||
Migration Migration
|
||||
Migration gh.Migration
|
||||
}
|
||||
// Pager holds details about calls to the Pager method.
|
||||
Pager []struct {
|
||||
|
|
@ -194,7 +195,7 @@ type ConfigMock struct {
|
|||
}
|
||||
|
||||
// Aliases calls AliasesFunc.
|
||||
func (mock *ConfigMock) Aliases() *AliasConfig {
|
||||
func (mock *ConfigMock) Aliases() gh.AliasConfig {
|
||||
if mock.AliasesFunc == nil {
|
||||
panic("ConfigMock.AliasesFunc: method is nil but Config.Aliases was just called")
|
||||
}
|
||||
|
|
@ -221,7 +222,7 @@ func (mock *ConfigMock) AliasesCalls() []struct {
|
|||
}
|
||||
|
||||
// Authentication calls AuthenticationFunc.
|
||||
func (mock *ConfigMock) Authentication() *AuthConfig {
|
||||
func (mock *ConfigMock) Authentication() gh.AuthConfig {
|
||||
if mock.AuthenticationFunc == nil {
|
||||
panic("ConfigMock.AuthenticationFunc: method is nil but Config.Authentication was just called")
|
||||
}
|
||||
|
|
@ -439,12 +440,12 @@ func (mock *ConfigMock) HTTPUnixSocketCalls() []struct {
|
|||
}
|
||||
|
||||
// Migrate calls MigrateFunc.
|
||||
func (mock *ConfigMock) Migrate(migration Migration) error {
|
||||
func (mock *ConfigMock) Migrate(migration gh.Migration) error {
|
||||
if mock.MigrateFunc == nil {
|
||||
panic("ConfigMock.MigrateFunc: method is nil but Config.Migrate was just called")
|
||||
}
|
||||
callInfo := struct {
|
||||
Migration Migration
|
||||
Migration gh.Migration
|
||||
}{
|
||||
Migration: migration,
|
||||
}
|
||||
|
|
@ -459,10 +460,10 @@ func (mock *ConfigMock) Migrate(migration Migration) error {
|
|||
//
|
||||
// len(mockedConfig.MigrateCalls())
|
||||
func (mock *ConfigMock) MigrateCalls() []struct {
|
||||
Migration Migration
|
||||
Migration gh.Migration
|
||||
} {
|
||||
var calls []struct {
|
||||
Migration Migration
|
||||
Migration gh.Migration
|
||||
}
|
||||
mock.lockMigrate.RLock()
|
||||
calls = mock.calls.Migrate
|
||||
|
|
@ -1,22 +1,23 @@
|
|||
// Code generated by moq; DO NOT EDIT.
|
||||
// github.com/matryer/moq
|
||||
|
||||
package config
|
||||
package ghmock
|
||||
|
||||
import (
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
ghConfig "github.com/cli/go-gh/v2/pkg/config"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Ensure, that MigrationMock does implement Migration.
|
||||
// Ensure, that MigrationMock does implement gh.Migration.
|
||||
// If this is not the case, regenerate this file with moq.
|
||||
var _ Migration = &MigrationMock{}
|
||||
var _ gh.Migration = &MigrationMock{}
|
||||
|
||||
// MigrationMock is a mock implementation of Migration.
|
||||
// MigrationMock is a mock implementation of gh.Migration.
|
||||
//
|
||||
// func TestSomethingThatUsesMigration(t *testing.T) {
|
||||
//
|
||||
// // make and configure a mocked Migration
|
||||
// // make and configure a mocked gh.Migration
|
||||
// mockedMigration := &MigrationMock{
|
||||
// DoFunc: func(config *ghConfig.Config) error {
|
||||
// panic("mock out the Do method")
|
||||
|
|
@ -29,7 +30,7 @@ var _ Migration = &MigrationMock{}
|
|||
// },
|
||||
// }
|
||||
//
|
||||
// // use mockedMigration in code that requires Migration
|
||||
// // use mockedMigration in code that requires gh.Migration
|
||||
// // and then make assertions.
|
||||
//
|
||||
// }
|
||||
|
|
@ -4,14 +4,14 @@ import (
|
|||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
type DeleteOptions struct {
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
|
||||
Name string
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/google/shlex"
|
||||
|
|
@ -161,7 +162,7 @@ func TestDeleteRun(t *testing.T) {
|
|||
tt.opts.IO = ios
|
||||
|
||||
cfg := config.NewFromString(tt.config)
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmd/alias/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -15,7 +15,7 @@ import (
|
|||
)
|
||||
|
||||
type ImportOptions struct {
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
|
||||
Filename string
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmd/alias/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -309,7 +310,7 @@ func TestImportRun(t *testing.T) {
|
|||
|
||||
readConfigs := config.StubWriteConfig(t)
|
||||
cfg := config.NewFromString(tt.initConfig)
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package list
|
|||
|
||||
import (
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
type ListOptions struct {
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
@ -66,7 +67,7 @@ func TestAliasList(t *testing.T) {
|
|||
|
||||
factory := &cmdutil.Factory{
|
||||
IOStreams: ios,
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmd/alias/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -14,7 +14,7 @@ import (
|
|||
)
|
||||
|
||||
type SetOptions struct {
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
|
||||
Name string
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmd/alias/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -284,7 +285,7 @@ func TestSetRun(t *testing.T) {
|
|||
cfg.WriteFunc = func() error {
|
||||
return nil
|
||||
}
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghinstance"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/factory"
|
||||
|
|
@ -37,7 +37,7 @@ type ApiOptions struct {
|
|||
AppVersion string
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
Branch func() (string, error)
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
HttpClient func() (*http.Client, error)
|
||||
IO *iostreams.IOStreams
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command
|
|||
$ gh api repos/{owner}/{repo}/issues --template \
|
||||
'{{range .}}{{.title}} ({{.labels | pluck "name" | join ", " | color "yellow"}}){{"\n"}}{{end}}'
|
||||
|
||||
# update allowed values of the "environment" custom property in a deeply nested array
|
||||
# update allowed values of the "environment" custom property in a deeply nested array
|
||||
gh api --PATCH /orgs/{org}/properties/schema \
|
||||
-F 'properties[][property_name]=environment' \
|
||||
-F 'properties[][default_value]=production' \
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
ghmock "github.com/cli/cli/v2/internal/gh/mock"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -662,7 +664,7 @@ func Test_apiRun(t *testing.T) {
|
|||
ios.SetStdoutTTY(tt.isatty)
|
||||
|
||||
tt.options.IO = ios
|
||||
tt.options.Config = func() (config.Config, error) { return config.NewBlankConfig(), nil }
|
||||
tt.options.Config = func() (gh.Config, error) { return config.NewBlankConfig(), nil }
|
||||
tt.options.HttpClient = func() (*http.Client, error) {
|
||||
var tr roundTripper = func(req *http.Request) (*http.Response, error) {
|
||||
resp := tt.httpResponse
|
||||
|
|
@ -737,7 +739,7 @@ func Test_apiRun_paginationREST(t *testing.T) {
|
|||
}
|
||||
return &http.Client{Transport: tr}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
|
||||
|
|
@ -809,7 +811,7 @@ func Test_apiRun_arrayPaginationREST(t *testing.T) {
|
|||
}
|
||||
return &http.Client{Transport: tr}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
|
||||
|
|
@ -881,7 +883,7 @@ func Test_apiRun_arrayPaginationREST_with_headers(t *testing.T) {
|
|||
}
|
||||
return &http.Client{Transport: tr}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
|
||||
|
|
@ -950,7 +952,7 @@ func Test_apiRun_paginationGraphQL(t *testing.T) {
|
|||
}
|
||||
return &http.Client{Transport: tr}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
|
||||
|
|
@ -1049,7 +1051,7 @@ func Test_apiRun_paginationGraphQL_slurp(t *testing.T) {
|
|||
}
|
||||
return &http.Client{Transport: tr}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
|
||||
|
|
@ -1161,7 +1163,7 @@ func Test_apiRun_paginated_template(t *testing.T) {
|
|||
}
|
||||
return &http.Client{Transport: tr}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
|
||||
|
|
@ -1208,7 +1210,7 @@ func Test_apiRun_DELETE(t *testing.T) {
|
|||
var gotRequest *http.Request
|
||||
err := apiRun(&ApiOptions{
|
||||
IO: ios,
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
HttpClient: func() (*http.Client, error) {
|
||||
|
|
@ -1293,7 +1295,7 @@ func Test_apiRun_inputFile(t *testing.T) {
|
|||
}
|
||||
return &http.Client{Transport: tr}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
}
|
||||
|
|
@ -1324,9 +1326,9 @@ func Test_apiRun_cache(t *testing.T) {
|
|||
ios, _, stdout, stderr := iostreams.Test()
|
||||
options := ApiOptions{
|
||||
IO: ios,
|
||||
Config: func() (config.Config, error) {
|
||||
return &config.ConfigMock{
|
||||
AuthenticationFunc: func() *config.AuthConfig {
|
||||
Config: func() (gh.Config, error) {
|
||||
return &ghmock.ConfigMock{
|
||||
AuthenticationFunc: func() gh.AuthConfig {
|
||||
return &config.AuthConfig{}
|
||||
},
|
||||
// Cached responses are stored in a tempdir that gets automatically cleaned up
|
||||
|
|
@ -1738,7 +1740,7 @@ func Test_apiRun_acceptHeader(t *testing.T) {
|
|||
ios, _, _, _ := iostreams.Test()
|
||||
tt.options.IO = ios
|
||||
|
||||
tt.options.Config = func() (config.Config, error) {
|
||||
tt.options.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghinstance"
|
||||
"github.com/cli/cli/v2/pkg/cmd/auth/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -20,7 +20,7 @@ import (
|
|||
|
||||
type LoginOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
HttpClient func() (*http.Client, error)
|
||||
GitClient *git.Client
|
||||
Prompter shared.Prompt
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/internal/run"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -281,7 +282,7 @@ func Test_loginRun_nontty(t *testing.T) {
|
|||
opts *LoginOptions
|
||||
env map[string]string
|
||||
httpStubs func(*httpmock.Registry)
|
||||
cfgStubs func(*testing.T, config.Config)
|
||||
cfgStubs func(*testing.T, gh.Config)
|
||||
wantHosts string
|
||||
wantErr string
|
||||
wantStderr string
|
||||
|
|
@ -417,7 +418,7 @@ func Test_loginRun_nontty(t *testing.T) {
|
|||
Hostname: "github.com",
|
||||
Token: "newUserToken",
|
||||
},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
_, err := c.Authentication().Login("github.com", "monalisa", "abc123", "https", false)
|
||||
require.NoError(t, err)
|
||||
},
|
||||
|
|
@ -451,7 +452,7 @@ func Test_loginRun_nontty(t *testing.T) {
|
|||
if tt.cfgStubs != nil {
|
||||
tt.cfgStubs(t, cfg)
|
||||
}
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
@ -500,7 +501,7 @@ func Test_loginRun_Survey(t *testing.T) {
|
|||
httpStubs func(*httpmock.Registry)
|
||||
prompterStubs func(*prompter.PrompterMock)
|
||||
runStubs func(*run.CommandStubber)
|
||||
cfgStubs func(*testing.T, config.Config)
|
||||
cfgStubs func(*testing.T, gh.Config)
|
||||
wantHosts string
|
||||
wantErrOut *regexp.Regexp
|
||||
wantSecureToken string
|
||||
|
|
@ -700,7 +701,7 @@ func Test_loginRun_Survey(t *testing.T) {
|
|||
return -1, prompter.NoSuchPromptErr(prompt)
|
||||
}
|
||||
},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
_, err := c.Authentication().Login("github.com", "monalisa", "abc123", "https", false)
|
||||
require.NoError(t, err)
|
||||
},
|
||||
|
|
@ -744,7 +745,7 @@ func Test_loginRun_Survey(t *testing.T) {
|
|||
if tt.cfgStubs != nil {
|
||||
tt.cfgStubs(t, cfg)
|
||||
}
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"slices"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmd/auth/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
type LogoutOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
Prompter shared.Prompt
|
||||
Hostname string
|
||||
Username string
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -124,7 +125,7 @@ type hostUsers struct {
|
|||
users []user
|
||||
}
|
||||
|
||||
type tokenAssertion func(t *testing.T, cfg config.Config)
|
||||
type tokenAssertion func(t *testing.T, cfg gh.Config)
|
||||
|
||||
func Test_logoutRun_tty(t *testing.T) {
|
||||
tests := []struct {
|
||||
|
|
@ -322,7 +323,7 @@ func Test_logoutRun_tty(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
@ -516,7 +517,7 @@ func Test_logoutRun_nontty(t *testing.T) {
|
|||
)
|
||||
}
|
||||
}
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
@ -552,7 +553,7 @@ func Test_logoutRun_nontty(t *testing.T) {
|
|||
}
|
||||
|
||||
func hasNoToken(hostname string) tokenAssertion {
|
||||
return func(t *testing.T, cfg config.Config) {
|
||||
return func(t *testing.T, cfg gh.Config) {
|
||||
t.Helper()
|
||||
|
||||
token, _ := cfg.Authentication().ActiveToken(hostname)
|
||||
|
|
@ -561,7 +562,7 @@ func hasNoToken(hostname string) tokenAssertion {
|
|||
}
|
||||
|
||||
func hasActiveToken(hostname string, expectedToken string) tokenAssertion {
|
||||
return func(t *testing.T, cfg config.Config) {
|
||||
return func(t *testing.T, cfg gh.Config) {
|
||||
t.Helper()
|
||||
|
||||
token, _ := cfg.Authentication().ActiveToken(hostname)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/authflow"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmd/auth/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -21,7 +21,7 @@ type username string
|
|||
|
||||
type RefreshOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
HttpClient *http.Client
|
||||
GitClient *git.Client
|
||||
Prompter shared.Prompt
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
|
|
@ -441,7 +442,7 @@ func Test_refreshRun(t *testing.T) {
|
|||
_, err := cfg.Authentication().Login(hostname, "test-user", "abc123", "https", false)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmd/auth/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -18,7 +18,7 @@ type gitConfigurator interface {
|
|||
|
||||
type SetupGitOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
Hostname string
|
||||
Force bool
|
||||
gitConfigure gitConfigurator
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/google/shlex"
|
||||
|
|
@ -81,7 +82,7 @@ func Test_setupGitRun(t *testing.T) {
|
|||
name string
|
||||
opts *SetupGitOptions
|
||||
setupErr error
|
||||
cfgStubs func(*testing.T, config.Config)
|
||||
cfgStubs func(*testing.T, gh.Config)
|
||||
expectedHostsSetup []string
|
||||
expectedErr error
|
||||
expectedErrOut string
|
||||
|
|
@ -89,7 +90,7 @@ func Test_setupGitRun(t *testing.T) {
|
|||
{
|
||||
name: "opts.Config returns an error",
|
||||
opts: &SetupGitOptions{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return nil, fmt.Errorf("oops")
|
||||
},
|
||||
},
|
||||
|
|
@ -100,7 +101,7 @@ func Test_setupGitRun(t *testing.T) {
|
|||
opts: &SetupGitOptions{
|
||||
Hostname: "ghe.io",
|
||||
},
|
||||
cfgStubs: func(t *testing.T, cfg config.Config) {
|
||||
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`"),
|
||||
|
|
@ -118,7 +119,7 @@ func Test_setupGitRun(t *testing.T) {
|
|||
opts: &SetupGitOptions{
|
||||
Hostname: "ghe.io",
|
||||
},
|
||||
cfgStubs: func(t *testing.T, cfg config.Config) {
|
||||
cfgStubs: func(t *testing.T, cfg gh.Config) {
|
||||
login(t, cfg, "ghe.io", "test-user", "gho_ABCDEFG", "https", false)
|
||||
},
|
||||
expectedHostsSetup: []string{"ghe.io"},
|
||||
|
|
@ -129,7 +130,7 @@ func Test_setupGitRun(t *testing.T) {
|
|||
Hostname: "ghe.io",
|
||||
},
|
||||
setupErr: fmt.Errorf("broken"),
|
||||
cfgStubs: func(t *testing.T, cfg config.Config) {
|
||||
cfgStubs: func(t *testing.T, cfg gh.Config) {
|
||||
login(t, cfg, "ghe.io", "test-user", "gho_ABCDEFG", "https", false)
|
||||
},
|
||||
expectedErr: errors.New("failed to set up git credential helper: broken"),
|
||||
|
|
@ -144,7 +145,7 @@ func Test_setupGitRun(t *testing.T) {
|
|||
{
|
||||
name: "when there are known hosts, and no hostname is provided, set them all up",
|
||||
opts: &SetupGitOptions{},
|
||||
cfgStubs: func(t *testing.T, cfg config.Config) {
|
||||
cfgStubs: func(t *testing.T, cfg gh.Config) {
|
||||
login(t, cfg, "ghe.io", "test-user", "gho_ABCDEFG", "https", false)
|
||||
login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", false)
|
||||
},
|
||||
|
|
@ -154,7 +155,7 @@ func Test_setupGitRun(t *testing.T) {
|
|||
name: "when no hostname is provided but setting one up errors, that error is bubbled",
|
||||
opts: &SetupGitOptions{},
|
||||
setupErr: fmt.Errorf("broken"),
|
||||
cfgStubs: func(t *testing.T, cfg config.Config) {
|
||||
cfgStubs: func(t *testing.T, cfg gh.Config) {
|
||||
login(t, cfg, "ghe.io", "test-user", "gho_ABCDEFG", "https", false)
|
||||
},
|
||||
expectedErr: errors.New("failed to set up git credential helper: broken"),
|
||||
|
|
@ -177,7 +178,7 @@ func Test_setupGitRun(t *testing.T) {
|
|||
}
|
||||
|
||||
if tt.opts.Config == nil {
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
}
|
||||
|
|
@ -201,7 +202,7 @@ func Test_setupGitRun(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func login(t *testing.T, c config.Config, hostname, username, token, gitProtocol string, secureStorage bool) {
|
||||
func login(t *testing.T, c gh.Config, hostname, username, token, gitProtocol string, secureStorage bool) {
|
||||
t.Helper()
|
||||
_, err := c.Authentication().Login(hostname, username, token, gitProtocol, secureStorage)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ package shared
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
)
|
||||
|
||||
func AuthTokenWriteable(authCfg *config.AuthConfig, hostname string) (string, bool) {
|
||||
func AuthTokenWriteable(authCfg gh.AuthConfig, hostname string) (string, bool) {
|
||||
token, src := authCfg.ActiveToken(hostname)
|
||||
return src, (token == "" || !strings.HasSuffix(src, "_TOKEN"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmd/auth/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -124,7 +125,7 @@ func (e Entries) Strings(cs *iostreams.ColorScheme) []string {
|
|||
type StatusOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
|
||||
Hostname string
|
||||
ShowToken bool
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -80,7 +81,7 @@ func Test_statusRun(t *testing.T) {
|
|||
opts StatusOptions
|
||||
env map[string]string
|
||||
httpStubs func(*httpmock.Registry)
|
||||
cfgStubs func(*testing.T, config.Config)
|
||||
cfgStubs func(*testing.T, gh.Config)
|
||||
wantErr error
|
||||
wantOut string
|
||||
wantErrOut string
|
||||
|
|
@ -90,7 +91,7 @@ func Test_statusRun(t *testing.T) {
|
|||
opts: StatusOptions{
|
||||
Hostname: "github.com",
|
||||
},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
login(t, c, "github.com", "monalisa", "abc123", "https")
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
|
|
@ -110,7 +111,7 @@ func Test_statusRun(t *testing.T) {
|
|||
opts: StatusOptions{
|
||||
Hostname: "ghe.io",
|
||||
},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
login(t, c, "github.com", "monalisa", "gho_abc123", "https")
|
||||
login(t, c, "ghe.io", "monalisa-ghe", "gho_abc123", "https")
|
||||
},
|
||||
|
|
@ -130,7 +131,7 @@ func Test_statusRun(t *testing.T) {
|
|||
{
|
||||
name: "missing scope",
|
||||
opts: StatusOptions{},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
login(t, c, "ghe.io", "monalisa-ghe", "gho_abc123", "https")
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
|
|
@ -151,7 +152,7 @@ func Test_statusRun(t *testing.T) {
|
|||
{
|
||||
name: "bad token",
|
||||
opts: StatusOptions{},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
login(t, c, "ghe.io", "monalisa-ghe", "gho_abc123", "https")
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
|
|
@ -170,7 +171,7 @@ func Test_statusRun(t *testing.T) {
|
|||
{
|
||||
name: "all good",
|
||||
opts: StatusOptions{},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
login(t, c, "github.com", "monalisa", "gho_abc123", "https")
|
||||
login(t, c, "ghe.io", "monalisa-ghe", "gho_abc123", "ssh")
|
||||
},
|
||||
|
|
@ -204,7 +205,7 @@ func Test_statusRun(t *testing.T) {
|
|||
name: "token from env",
|
||||
opts: StatusOptions{},
|
||||
env: map[string]string{"GH_TOKEN": "gho_abc123"},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {},
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {},
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
reg.Register(
|
||||
httpmock.REST("GET", ""),
|
||||
|
|
@ -225,7 +226,7 @@ func Test_statusRun(t *testing.T) {
|
|||
{
|
||||
name: "server-to-server token",
|
||||
opts: StatusOptions{},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
login(t, c, "github.com", "monalisa", "ghs_abc123", "https")
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
|
|
@ -245,7 +246,7 @@ func Test_statusRun(t *testing.T) {
|
|||
{
|
||||
name: "PAT V2 token",
|
||||
opts: StatusOptions{},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
login(t, c, "github.com", "monalisa", "github_pat_abc123", "https")
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
|
|
@ -267,7 +268,7 @@ func Test_statusRun(t *testing.T) {
|
|||
opts: StatusOptions{
|
||||
ShowToken: true,
|
||||
},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
login(t, c, "github.com", "monalisa", "gho_abc123", "https")
|
||||
login(t, c, "ghe.io", "monalisa-ghe", "gho_xyz456", "https")
|
||||
},
|
||||
|
|
@ -298,7 +299,7 @@ func Test_statusRun(t *testing.T) {
|
|||
opts: StatusOptions{
|
||||
Hostname: "github.example.com",
|
||||
},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
login(t, c, "github.com", "monalisa", "abc123", "https")
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry) {},
|
||||
|
|
@ -308,7 +309,7 @@ func Test_statusRun(t *testing.T) {
|
|||
{
|
||||
name: "multiple accounts on a host",
|
||||
opts: StatusOptions{},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
login(t, c, "github.com", "monalisa", "gho_abc123", "https")
|
||||
login(t, c, "github.com", "monalisa-2", "gho_abc123", "https")
|
||||
},
|
||||
|
|
@ -335,7 +336,7 @@ func Test_statusRun(t *testing.T) {
|
|||
name: "multiple hosts with multiple accounts with environment tokens and with errors",
|
||||
opts: StatusOptions{},
|
||||
env: map[string]string{"GH_ENTERPRISE_TOKEN": "gho_abc123"},
|
||||
cfgStubs: func(t *testing.T, c config.Config) {
|
||||
cfgStubs: func(t *testing.T, c gh.Config) {
|
||||
login(t, c, "github.com", "monalisa", "gho_def456", "https")
|
||||
login(t, c, "github.com", "monalisa-2", "gho_ghi789", "https")
|
||||
login(t, c, "ghe.io", "monalisa-ghe", "gho_xyz123", "ssh")
|
||||
|
|
@ -398,7 +399,7 @@ func Test_statusRun(t *testing.T) {
|
|||
if tt.cfgStubs != nil {
|
||||
tt.cfgStubs(t, cfg)
|
||||
}
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
@ -430,7 +431,7 @@ func Test_statusRun(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func login(t *testing.T, c config.Config, hostname, username, protocol, token string) {
|
||||
func login(t *testing.T, c gh.Config, hostname, username, protocol, token string) {
|
||||
t.Helper()
|
||||
_, err := c.Authentication().Login(hostname, username, protocol, token, false)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"slices"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmd/auth/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
type SwitchOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
Prompter shared.Prompt
|
||||
Hostname string
|
||||
Username string
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/keyring"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -403,7 +404,7 @@ func TestSwitchRun(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
type TokenOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
|
||||
Hostname string
|
||||
Username string
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/google/shlex"
|
||||
|
|
@ -56,7 +57,7 @@ func TestNewCmdToken(t *testing.T) {
|
|||
ios, _, _, _ := iostreams.Test()
|
||||
f := &cmdutil.Factory{
|
||||
IOStreams: ios,
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
cfg := config.NewBlankConfig()
|
||||
return cfg, nil
|
||||
},
|
||||
|
|
@ -96,7 +97,7 @@ func TestTokenRun(t *testing.T) {
|
|||
name string
|
||||
opts TokenOptions
|
||||
env map[string]string
|
||||
cfgStubs func(*testing.T, config.Config)
|
||||
cfgStubs func(*testing.T, gh.Config)
|
||||
wantStdout string
|
||||
wantErr bool
|
||||
wantErrMsg string
|
||||
|
|
@ -104,7 +105,7 @@ func TestTokenRun(t *testing.T) {
|
|||
{
|
||||
name: "token",
|
||||
opts: TokenOptions{},
|
||||
cfgStubs: func(t *testing.T, cfg config.Config) {
|
||||
cfgStubs: func(t *testing.T, cfg gh.Config) {
|
||||
login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", false)
|
||||
},
|
||||
wantStdout: "gho_ABCDEFG\n",
|
||||
|
|
@ -114,7 +115,7 @@ func TestTokenRun(t *testing.T) {
|
|||
opts: TokenOptions{
|
||||
Hostname: "github.mycompany.com",
|
||||
},
|
||||
cfgStubs: func(t *testing.T, cfg config.Config) {
|
||||
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)
|
||||
},
|
||||
|
|
@ -138,7 +139,7 @@ func TestTokenRun(t *testing.T) {
|
|||
{
|
||||
name: "uses default host when one is not provided",
|
||||
opts: TokenOptions{},
|
||||
cfgStubs: func(t *testing.T, cfg config.Config) {
|
||||
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)
|
||||
},
|
||||
|
|
@ -151,7 +152,7 @@ func TestTokenRun(t *testing.T) {
|
|||
Hostname: "github.com",
|
||||
Username: "test-user",
|
||||
},
|
||||
cfgStubs: func(t *testing.T, cfg config.Config) {
|
||||
cfgStubs: func(t *testing.T, cfg gh.Config) {
|
||||
login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", false)
|
||||
login(t, cfg, "github.com", "test-user-2", "gho_1234567", "https", false)
|
||||
},
|
||||
|
|
@ -173,7 +174,7 @@ func TestTokenRun(t *testing.T) {
|
|||
tt.cfgStubs(t, cfg)
|
||||
}
|
||||
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
@ -193,7 +194,7 @@ func TestTokenRunSecureStorage(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
opts TokenOptions
|
||||
cfgStubs func(*testing.T, config.Config)
|
||||
cfgStubs func(*testing.T, gh.Config)
|
||||
wantStdout string
|
||||
wantErr bool
|
||||
wantErrMsg string
|
||||
|
|
@ -201,7 +202,7 @@ func TestTokenRunSecureStorage(t *testing.T) {
|
|||
{
|
||||
name: "token",
|
||||
opts: TokenOptions{},
|
||||
cfgStubs: func(t *testing.T, cfg config.Config) {
|
||||
cfgStubs: func(t *testing.T, cfg gh.Config) {
|
||||
login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", true)
|
||||
},
|
||||
wantStdout: "gho_ABCDEFG\n",
|
||||
|
|
@ -211,7 +212,7 @@ func TestTokenRunSecureStorage(t *testing.T) {
|
|||
opts: TokenOptions{
|
||||
Hostname: "mycompany.com",
|
||||
},
|
||||
cfgStubs: func(t *testing.T, cfg config.Config) {
|
||||
cfgStubs: func(t *testing.T, cfg gh.Config) {
|
||||
login(t, cfg, "mycompany.com", "test-user", "gho_1234567", "https", true)
|
||||
},
|
||||
wantStdout: "gho_1234567\n",
|
||||
|
|
@ -237,7 +238,7 @@ func TestTokenRunSecureStorage(t *testing.T) {
|
|||
Hostname: "github.com",
|
||||
Username: "test-user",
|
||||
},
|
||||
cfgStubs: func(t *testing.T, cfg config.Config) {
|
||||
cfgStubs: func(t *testing.T, cfg gh.Config) {
|
||||
login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", true)
|
||||
login(t, cfg, "github.com", "test-user-2", "gho_1234567", "https", true)
|
||||
},
|
||||
|
|
@ -256,7 +257,7 @@ func TestTokenRunSecureStorage(t *testing.T) {
|
|||
tt.cfgStubs(t, cfg)
|
||||
}
|
||||
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
|
@ -272,7 +273,7 @@ func TestTokenRunSecureStorage(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func login(t *testing.T, c config.Config, hostname, username, token, gitProtocol string, secureStorage bool) {
|
||||
func login(t *testing.T, c gh.Config, hostname, username, token, gitProtocol string, secureStorage bool) {
|
||||
t.Helper()
|
||||
_, err := c.Authentication().Login(hostname, username, token, gitProtocol, secureStorage)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
type GetOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config config.Config
|
||||
Config gh.Config
|
||||
|
||||
Hostname string
|
||||
Key string
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/google/shlex"
|
||||
|
|
@ -41,7 +42,7 @@ func TestNewCmdConfigGet(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
f := &cmdutil.Factory{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
}
|
||||
|
|
@ -86,7 +87,7 @@ func Test_getRun(t *testing.T) {
|
|||
name: "get key",
|
||||
input: &GetOptions{
|
||||
Key: "editor",
|
||||
Config: func() config.Config {
|
||||
Config: func() gh.Config {
|
||||
cfg := config.NewBlankConfig()
|
||||
cfg.Set("", "editor", "ed")
|
||||
return cfg
|
||||
|
|
@ -99,7 +100,7 @@ func Test_getRun(t *testing.T) {
|
|||
input: &GetOptions{
|
||||
Hostname: "github.com",
|
||||
Key: "editor",
|
||||
Config: func() config.Config {
|
||||
Config: func() gh.Config {
|
||||
cfg := config.NewBlankConfig()
|
||||
cfg.Set("", "editor", "ed")
|
||||
cfg.Set("github.com", "editor", "vim")
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -11,7 +12,7 @@ import (
|
|||
|
||||
type ListOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
|
||||
Hostname string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/google/shlex"
|
||||
|
|
@ -35,7 +36,7 @@ func TestNewCmdConfigList(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
f := &cmdutil.Factory{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
}
|
||||
|
|
@ -71,13 +72,13 @@ func Test_listRun(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
input *ListOptions
|
||||
config config.Config
|
||||
config gh.Config
|
||||
stdout string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "list",
|
||||
config: func() config.Config {
|
||||
config: func() gh.Config {
|
||||
cfg := config.NewBlankConfig()
|
||||
cfg.Set("HOST", "git_protocol", "ssh")
|
||||
cfg.Set("HOST", "editor", "/usr/bin/vim")
|
||||
|
|
@ -101,7 +102,7 @@ browser=brave
|
|||
for _, tt := range tests {
|
||||
ios, _, stdout, _ := iostreams.Test()
|
||||
tt.input.IO = ios
|
||||
tt.input.Config = func() (config.Config, error) {
|
||||
tt.input.Config = func() (gh.Config, error) {
|
||||
return tt.config, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -14,7 +15,7 @@ import (
|
|||
|
||||
type SetOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config config.Config
|
||||
Config gh.Config
|
||||
|
||||
Key string
|
||||
Value string
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/google/shlex"
|
||||
|
|
@ -49,7 +50,7 @@ func TestNewCmdConfigSet(t *testing.T) {
|
|||
_ = config.StubWriteConfig(t)
|
||||
|
||||
f := &cmdutil.Factory{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/charmbracelet/glamour"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/extensions"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -33,7 +33,7 @@ type ExtBrowseOpts struct {
|
|||
Em extensions.ExtensionManager
|
||||
Client *http.Client
|
||||
Logger *log.Logger
|
||||
Cfg config.Config
|
||||
Cfg gh.Config
|
||||
Rg *readmeGetter
|
||||
Debug bool
|
||||
SingleColumn bool
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/repo/view"
|
||||
"github.com/cli/cli/v2/pkg/extensions"
|
||||
|
|
@ -76,7 +77,7 @@ func Test_getExtensionRepos(t *testing.T) {
|
|||
}
|
||||
cfg := config.NewBlankConfig()
|
||||
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetDefaultHost("github.com", "")
|
||||
return authCfg
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -888,7 +889,7 @@ func TestNewCmdExtension(t *testing.T) {
|
|||
}
|
||||
|
||||
f := cmdutil.Factory{
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
IOStreams: ios,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import (
|
|||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/extensions"
|
||||
"github.com/cli/cli/v2/pkg/findsh"
|
||||
|
|
@ -36,7 +37,7 @@ type Manager struct {
|
|||
platform func() (string, string)
|
||||
client *http.Client
|
||||
gitClient gitClient
|
||||
config config.Config
|
||||
config gh.Config
|
||||
io *iostreams.IOStreams
|
||||
dryRunMode bool
|
||||
}
|
||||
|
|
@ -59,7 +60,7 @@ func NewManager(ios *iostreams.IOStreams, gc *git.Client) *Manager {
|
|||
}
|
||||
}
|
||||
|
||||
func (m *Manager) SetConfig(cfg config.Config) {
|
||||
func (m *Manager) SetConfig(cfg gh.Config) {
|
||||
m.config = cfg
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmd/extension"
|
||||
|
|
@ -134,10 +135,10 @@ func newPrompter(f *cmdutil.Factory) prompter.Prompter {
|
|||
return prompter.New(editor, io.In, io.Out, io.ErrOut)
|
||||
}
|
||||
|
||||
func configFunc() func() (config.Config, error) {
|
||||
var cachedConfig config.Config
|
||||
func configFunc() func() (gh.Config, error) {
|
||||
var cachedConfig gh.Config
|
||||
var configError error
|
||||
return func() (config.Config, error) {
|
||||
return func() (gh.Config, error) {
|
||||
if cachedConfig != nil || configError != nil {
|
||||
return cachedConfig, configError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import (
|
|||
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
ghmock "github.com/cli/cli/v2/internal/gh/mock"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -69,9 +71,9 @@ func Test_BaseRepo(t *testing.T) {
|
|||
readRemotes: func() (git.RemoteSet, error) {
|
||||
return tt.remotes, nil
|
||||
},
|
||||
getConfig: func() (config.Config, error) {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
getConfig: func() (gh.Config, error) {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
hosts := []string{"nonsense.com"}
|
||||
if tt.override != "" {
|
||||
|
|
@ -207,9 +209,9 @@ func Test_SmartBaseRepo(t *testing.T) {
|
|||
readRemotes: func() (git.RemoteSet, error) {
|
||||
return tt.remotes, nil
|
||||
},
|
||||
getConfig: func() (config.Config, error) {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
getConfig: func() (gh.Config, error) {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
hosts := []string{"nonsense.com"}
|
||||
if tt.override != "" {
|
||||
|
|
@ -256,7 +258,7 @@ func Test_OverrideBaseRepo(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
remotes git.RemoteSet
|
||||
config config.Config
|
||||
config gh.Config
|
||||
envOverride string
|
||||
argOverride string
|
||||
wantsErr bool
|
||||
|
|
@ -300,7 +302,7 @@ func Test_OverrideBaseRepo(t *testing.T) {
|
|||
readRemotes: func() (git.RemoteSet, error) {
|
||||
return tt.remotes, nil
|
||||
},
|
||||
getConfig: func() (config.Config, error) {
|
||||
getConfig: func() (gh.Config, error) {
|
||||
return tt.config, nil
|
||||
},
|
||||
}
|
||||
|
|
@ -323,7 +325,7 @@ func Test_ioStreams_pager(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
env map[string]string
|
||||
config config.Config
|
||||
config gh.Config
|
||||
wantPager string
|
||||
}{
|
||||
{
|
||||
|
|
@ -374,7 +376,7 @@ func Test_ioStreams_pager(t *testing.T) {
|
|||
}
|
||||
}
|
||||
f := New("1")
|
||||
f.Config = func() (config.Config, error) {
|
||||
f.Config = func() (gh.Config, error) {
|
||||
if tt.config == nil {
|
||||
return config.NewBlankConfig(), nil
|
||||
} else {
|
||||
|
|
@ -390,7 +392,7 @@ func Test_ioStreams_pager(t *testing.T) {
|
|||
func Test_ioStreams_prompt(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
config config.Config
|
||||
config gh.Config
|
||||
promptDisabled bool
|
||||
env map[string]string
|
||||
}{
|
||||
|
|
@ -417,7 +419,7 @@ func Test_ioStreams_prompt(t *testing.T) {
|
|||
}
|
||||
}
|
||||
f := New("1")
|
||||
f.Config = func() (config.Config, error) {
|
||||
f.Config = func() (gh.Config, error) {
|
||||
if tt.config == nil {
|
||||
return config.NewBlankConfig(), nil
|
||||
} else {
|
||||
|
|
@ -458,7 +460,7 @@ func TestSSOURL(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
f := New("1")
|
||||
f.Config = func() (config.Config, error) {
|
||||
f.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
ios, _, _, stderr := iostreams.Test()
|
||||
|
|
@ -487,7 +489,7 @@ func TestSSOURL(t *testing.T) {
|
|||
func TestNewGitClient(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
config config.Config
|
||||
config gh.Config
|
||||
executable string
|
||||
wantAuthHosts []string
|
||||
wantGhPath string
|
||||
|
|
@ -503,7 +505,7 @@ func TestNewGitClient(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
f := New("1")
|
||||
f.Config = func() (config.Config, error) {
|
||||
f.Config = func() (gh.Config, error) {
|
||||
if tt.config == nil {
|
||||
return config.NewBlankConfig(), nil
|
||||
} else {
|
||||
|
|
@ -522,16 +524,16 @@ func TestNewGitClient(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func defaultConfig() *config.ConfigMock {
|
||||
func defaultConfig() *ghmock.ConfigMock {
|
||||
cfg := config.NewFromString("")
|
||||
cfg.Set("nonsense.com", "oauth_token", "BLAH")
|
||||
return cfg
|
||||
}
|
||||
|
||||
func pagerConfig() config.Config {
|
||||
func pagerConfig() gh.Config {
|
||||
return config.NewFromString("pager: CONFIG_PAGER")
|
||||
}
|
||||
|
||||
func disablePromptConfig() config.Config {
|
||||
func disablePromptConfig() gh.Config {
|
||||
return config.NewFromString("prompt: disabled")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/cli/cli/v2/context"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghinstance"
|
||||
"github.com/cli/cli/v2/pkg/set"
|
||||
"github.com/cli/go-gh/v2/pkg/ssh"
|
||||
|
|
@ -19,7 +19,7 @@ const (
|
|||
|
||||
type remoteResolver struct {
|
||||
readRemotes func() (git.RemoteSet, error)
|
||||
getConfig func() (config.Config, error)
|
||||
getConfig func() (gh.Config, error)
|
||||
urlTranslator context.Translator
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import (
|
|||
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
ghmock "github.com/cli/cli/v2/internal/gh/mock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -19,7 +21,7 @@ func Test_remoteResolver(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
remotes func() (git.RemoteSet, error)
|
||||
config config.Config
|
||||
config gh.Config
|
||||
output []string
|
||||
wantsErr bool
|
||||
}{
|
||||
|
|
@ -30,9 +32,9 @@ func Test_remoteResolver(t *testing.T) {
|
|||
git.NewRemote("origin", "https://github.com/owner/repo.git"),
|
||||
}, nil
|
||||
},
|
||||
config: func() config.Config {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
config: func() gh.Config {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetHosts([]string{})
|
||||
authCfg.SetDefaultHost("github.com", "default")
|
||||
|
|
@ -47,9 +49,9 @@ func Test_remoteResolver(t *testing.T) {
|
|||
remotes: func() (git.RemoteSet, error) {
|
||||
return git.RemoteSet{}, nil
|
||||
},
|
||||
config: func() config.Config {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
config: func() gh.Config {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetHosts([]string{"example.com"})
|
||||
authCfg.SetDefaultHost("example.com", "hosts")
|
||||
|
|
@ -66,9 +68,9 @@ func Test_remoteResolver(t *testing.T) {
|
|||
git.NewRemote("origin", "https://test.com/owner/repo.git"),
|
||||
}, nil
|
||||
},
|
||||
config: func() config.Config {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
config: func() gh.Config {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetHosts([]string{"example.com"})
|
||||
authCfg.SetActiveToken("", "")
|
||||
|
|
@ -86,9 +88,9 @@ func Test_remoteResolver(t *testing.T) {
|
|||
git.NewRemote("origin", "https://github.com/owner/repo.git"),
|
||||
}, nil
|
||||
},
|
||||
config: func() config.Config {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
config: func() gh.Config {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetHosts([]string{"example.com"})
|
||||
authCfg.SetDefaultHost("example.com", "hosts")
|
||||
|
|
@ -105,9 +107,9 @@ func Test_remoteResolver(t *testing.T) {
|
|||
git.NewRemote("origin", "https://example.com/owner/repo.git"),
|
||||
}, nil
|
||||
},
|
||||
config: func() config.Config {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
config: func() gh.Config {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetHosts([]string{"example.com"})
|
||||
authCfg.SetDefaultHost("example.com", "default")
|
||||
|
|
@ -127,9 +129,9 @@ func Test_remoteResolver(t *testing.T) {
|
|||
git.NewRemote("fork", "https://example.com/owner/repo.git"),
|
||||
}, nil
|
||||
},
|
||||
config: func() config.Config {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
config: func() gh.Config {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetHosts([]string{"example.com"})
|
||||
authCfg.SetDefaultHost("example.com", "default")
|
||||
|
|
@ -146,9 +148,9 @@ func Test_remoteResolver(t *testing.T) {
|
|||
git.NewRemote("origin", "https://test.com/owner/repo.git"),
|
||||
}, nil
|
||||
},
|
||||
config: func() config.Config {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
config: func() gh.Config {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetHosts([]string{"example.com", "github.com"})
|
||||
authCfg.SetActiveToken("", "")
|
||||
|
|
@ -167,9 +169,9 @@ func Test_remoteResolver(t *testing.T) {
|
|||
git.NewRemote("origin", "https://example.com/owner/repo.git"),
|
||||
}, nil
|
||||
},
|
||||
config: func() config.Config {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
config: func() gh.Config {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetHosts([]string{"example.com", "github.com"})
|
||||
authCfg.SetDefaultHost("github.com", "default")
|
||||
|
|
@ -190,9 +192,9 @@ func Test_remoteResolver(t *testing.T) {
|
|||
git.NewRemote("test", "https://test.com/owner/repo.git"),
|
||||
}, nil
|
||||
},
|
||||
config: func() config.Config {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
config: func() gh.Config {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetHosts([]string{"example.com", "github.com"})
|
||||
authCfg.SetDefaultHost("github.com", "default")
|
||||
|
|
@ -209,9 +211,9 @@ func Test_remoteResolver(t *testing.T) {
|
|||
git.NewRemote("origin", "https://example.com/owner/repo.git"),
|
||||
}, nil
|
||||
},
|
||||
config: func() config.Config {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
config: func() gh.Config {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetHosts([]string{"example.com"})
|
||||
authCfg.SetDefaultHost("test.com", "GH_HOST")
|
||||
|
|
@ -229,9 +231,9 @@ func Test_remoteResolver(t *testing.T) {
|
|||
git.NewRemote("origin", "https://test.com/owner/repo.git"),
|
||||
}, nil
|
||||
},
|
||||
config: func() config.Config {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
config: func() gh.Config {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetHosts([]string{"example.com"})
|
||||
authCfg.SetDefaultHost("test.com", "GH_HOST")
|
||||
|
|
@ -250,9 +252,9 @@ func Test_remoteResolver(t *testing.T) {
|
|||
git.NewRemote("origin", "https://test.com/owner/repo.git"),
|
||||
}, nil
|
||||
},
|
||||
config: func() config.Config {
|
||||
cfg := &config.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() *config.AuthConfig {
|
||||
config: func() gh.Config {
|
||||
cfg := &ghmock.ConfigMock{}
|
||||
cfg.AuthenticationFunc = func() gh.AuthConfig {
|
||||
authCfg := &config.AuthConfig{}
|
||||
authCfg.SetHosts([]string{"example.com", "test.com"})
|
||||
authCfg.SetDefaultHost("test.com", "GH_HOST")
|
||||
|
|
@ -268,7 +270,7 @@ func Test_remoteResolver(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
rr := &remoteResolver{
|
||||
readRemotes: tt.remotes,
|
||||
getConfig: func() (config.Config, error) { return tt.config, nil },
|
||||
getConfig: func() (gh.Config, error) { return tt.config, nil },
|
||||
urlTranslator: identityTranslator{},
|
||||
}
|
||||
resolver := rr.Resolver()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghinstance"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -18,7 +18,7 @@ import (
|
|||
type CloneOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
GitClient *git.Client
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
|
||||
GitArgs []string
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/run"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
|
|
@ -22,7 +23,7 @@ func runCloneCommand(httpClient *http.Client, cli string) (*test.CmdOut, error)
|
|||
HttpClient: func() (*http.Client, error) {
|
||||
return httpClient, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
GitClient: &git.Client{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghinstance"
|
||||
"github.com/cli/cli/v2/internal/text"
|
||||
"github.com/cli/cli/v2/pkg/cmd/gist/shared"
|
||||
|
|
@ -34,7 +34,7 @@ type CreateOptions struct {
|
|||
FilenameOverride string
|
||||
WebMode bool
|
||||
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
HttpClient func() (*http.Client, error)
|
||||
Browser browser.Browser
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/run"
|
||||
"github.com/cli/cli/v2/pkg/cmd/gist/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -331,7 +332,7 @@ func Test_createRun(t *testing.T) {
|
|||
}
|
||||
tt.opts.HttpClient = mockClient
|
||||
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmd/gist/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
type DeleteOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
HttpClient func() (*http.Client, error)
|
||||
|
||||
Selector string
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -99,7 +100,7 @@ func Test_deleteRun(t *testing.T) {
|
|||
tt.opts.HttpClient = func() (*http.Client, error) {
|
||||
return &http.Client{Transport: reg}, nil
|
||||
}
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
ios, _, _, _ := iostreams.Test()
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmd/gist/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -27,7 +27,7 @@ var editNextOptions = []string{"Edit another file", "Submit", "Cancel"}
|
|||
type EditOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
HttpClient func() (*http.Client, error)
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
Prompter prompter.Prompter
|
||||
|
||||
Edit func(string, string, string, *iostreams.IOStreams) (string, error)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmd/gist/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -554,7 +555,7 @@ func Test_editRun(t *testing.T) {
|
|||
tt.opts.IO = ios
|
||||
tt.opts.Selector = "1234"
|
||||
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/tableprinter"
|
||||
"github.com/cli/cli/v2/internal/text"
|
||||
"github.com/cli/cli/v2/pkg/cmd/gist/shared"
|
||||
|
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ListOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
HttpClient func() (*http.Client, error)
|
||||
|
||||
Limit int
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -367,7 +368,7 @@ func Test_listRun(t *testing.T) {
|
|||
return &http.Client{Transport: reg}, nil
|
||||
}
|
||||
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmd/gist/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
type RenameOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
HttpClient func() (*http.Client, error)
|
||||
|
||||
Selector string
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmd/gist/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
|
|
@ -166,7 +167,7 @@ func TestRenameRun(t *testing.T) {
|
|||
tt.opts.NewFileName = "new.txt"
|
||||
tt.opts.IO = ios
|
||||
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghinstance"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/internal/text"
|
||||
|
|
@ -23,7 +23,7 @@ type browser interface {
|
|||
|
||||
type ViewOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
HttpClient func() (*http.Client, error)
|
||||
Browser browser
|
||||
Prompter prompter.Prompter
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmd/gist/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -370,7 +371,7 @@ func Test_viewRun(t *testing.T) {
|
|||
return &http.Client{Transport: reg}, nil
|
||||
}
|
||||
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
type AddOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
HTTPClient func() (*http.Client, error)
|
||||
|
||||
KeyFile string
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
@ -125,7 +126,7 @@ func Test_runAdd(t *testing.T) {
|
|||
if tt.httpStubs != nil {
|
||||
tt.httpStubs(reg)
|
||||
}
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
type DeleteOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
HttpClient func() (*http.Client, error)
|
||||
|
||||
KeyID string
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
|
|
@ -201,7 +202,7 @@ func Test_deleteRun(t *testing.T) {
|
|||
tt.opts.HttpClient = func() (*http.Client, error) {
|
||||
return &http.Client{Transport: reg}, nil
|
||||
}
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
ios, _, stdout, _ := iostreams.Test()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/tableprinter"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
type ListOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
HTTPClient func() (*http.Client, error)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
@ -130,7 +131,7 @@ func Test_listRun(t *testing.T) {
|
|||
ios.SetStderrTTY(tt.isTTY)
|
||||
opts := tt.opts
|
||||
opts.IO = ios
|
||||
opts.Config = func() (config.Config, error) { return config.NewBlankConfig(), nil }
|
||||
opts.Config = func() (gh.Config, error) { return config.NewBlankConfig(), nil }
|
||||
err := listRun(&opts)
|
||||
if tt.wantErr {
|
||||
assert.Error(t, err)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/text"
|
||||
prShared "github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
|
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
type CreateOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
Browser browser.Browser
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/internal/run"
|
||||
|
|
@ -364,7 +365,7 @@ func runCommandWithRootDirOverridden(rt http.RoundTripper, isTTY bool, cli strin
|
|||
HttpClient: func() (*http.Client, error) {
|
||||
return &http.Client{Transport: rt}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
BaseRepo: func() (ghrepo.Interface, error) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/issue/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
type DeleteOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
Prompter iprompter
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -31,7 +32,7 @@ func runCommand(rt http.RoundTripper, pm *prompter.MockPrompter, isTTY bool, cli
|
|||
HttpClient: func() (*http.Client, error) {
|
||||
return &http.Client{Transport: rt}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
BaseRepo: func() (ghrepo.Interface, error) {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
fd "github.com/cli/cli/v2/internal/featuredetection"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/text"
|
||||
issueShared "github.com/cli/cli/v2/pkg/cmd/issue/shared"
|
||||
|
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
type ListOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
Browser browser.Browser
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/run"
|
||||
prShared "github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
|
|
@ -34,7 +35,7 @@ func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, err
|
|||
HttpClient: func() (*http.Client, error) {
|
||||
return &http.Client{Transport: rt}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
BaseRepo: func() (ghrepo.Interface, error) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
issueShared "github.com/cli/cli/v2/pkg/cmd/issue/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -92,7 +92,7 @@ func fields() []string {
|
|||
|
||||
type LockOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
Prompter iprompter
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/issue/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type PinOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
SelectorArg string
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
|
|
@ -139,7 +140,7 @@ func TestPinRun(t *testing.T) {
|
|||
ios.SetStdoutTTY(tt.tty)
|
||||
tt.opts.IO = ios
|
||||
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/issue/shared"
|
||||
prShared "github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
|
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ReopenOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
|
|
@ -28,7 +29,7 @@ func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, err
|
|||
HttpClient: func() (*http.Client, error) {
|
||||
return &http.Client{Transport: rt}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
BaseRepo: func() (ghrepo.Interface, error) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
issueShared "github.com/cli/cli/v2/pkg/cmd/issue/shared"
|
||||
prShared "github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
|
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type StatusOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
|
|
@ -27,7 +28,7 @@ func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, err
|
|||
HttpClient: func() (*http.Client, error) {
|
||||
return &http.Client{Transport: rt}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
BaseRepo: func() (ghrepo.Interface, error) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/issue/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
type TransferOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
|
|
@ -24,7 +25,7 @@ func runCommand(rt http.RoundTripper, cli string) (*test.CmdOut, error) {
|
|||
HttpClient: func() (*http.Client, error) {
|
||||
return &http.Client{Transport: rt}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
BaseRepo: func() (ghrepo.Interface, error) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/issue/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type UnpinOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
SelectorArg string
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
|
|
@ -139,7 +140,7 @@ func TestUnpinRun(t *testing.T) {
|
|||
ios.SetStdoutTTY(tt.tty)
|
||||
tt.opts.IO = ios
|
||||
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/run"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -31,7 +32,7 @@ func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, err
|
|||
HttpClient: func() (*http.Client, error) {
|
||||
return &http.Client{Transport: rt}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
BaseRepo: func() (ghrepo.Interface, error) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/text"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
type ListOptions struct {
|
||||
IO *iostreams.IOStreams
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
HttpClient func() (*http.Client, error)
|
||||
|
||||
Limit int
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -95,7 +96,7 @@ func TestListRun(t *testing.T) {
|
|||
r.Register(
|
||||
httpmock.GraphQL(`query OrganizationList\b`),
|
||||
httpmock.StringResponse(`
|
||||
{ "data": { "user": {
|
||||
{ "data": { "user": {
|
||||
"organizations": { "nodes": [], "totalCount": 0 }
|
||||
} } }`,
|
||||
),
|
||||
|
|
@ -224,7 +225,7 @@ cli
|
|||
ios.SetStderrTTY(tt.isTTY)
|
||||
|
||||
tt.opts.IO = ios
|
||||
tt.opts.Config = func() (config.Config, error) {
|
||||
tt.opts.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/cli/cli/v2/api"
|
||||
cliContext "github.com/cli/cli/v2/context"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -20,7 +20,7 @@ import (
|
|||
type CheckoutOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
GitClient *git.Client
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
Remotes func() (cliContext.Remotes, error)
|
||||
Branch func() (string, error)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/cli/cli/v2/context"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/run"
|
||||
"github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
|
|
@ -82,7 +83,7 @@ func Test_checkoutRun(t *testing.T) {
|
|||
finder := shared.NewMockFinder("123", pr, baseRepo)
|
||||
return finder
|
||||
}(),
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
Branch: func() (string, error) {
|
||||
|
|
@ -111,7 +112,7 @@ func Test_checkoutRun(t *testing.T) {
|
|||
finder := shared.NewMockFinder("123", pr, baseRepo)
|
||||
return finder
|
||||
}(),
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
Branch: func() (string, error) {
|
||||
|
|
@ -138,7 +139,7 @@ func Test_checkoutRun(t *testing.T) {
|
|||
finder := shared.NewMockFinder("123", pr, baseRepo)
|
||||
return finder
|
||||
}(),
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
Branch: func() (string, error) {
|
||||
|
|
@ -222,7 +223,7 @@ func runCommand(rt http.RoundTripper, remotes context.Remotes, branch string, cl
|
|||
HttpClient: func() (*http.Client, error) {
|
||||
return &http.Client{Transport: rt}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
Remotes: func() (context.Remotes, error) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import (
|
|||
ghContext "github.com/cli/cli/v2/context"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/text"
|
||||
"github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
|
|
@ -32,7 +32,7 @@ type CreateOptions struct {
|
|||
// This struct stores user input and factory functions
|
||||
HttpClient func() (*http.Client, error)
|
||||
GitClient *git.Client
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
Remotes func() (ghContext.Remotes, error)
|
||||
Branch func() (string, error)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import (
|
|||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/internal/run"
|
||||
|
|
@ -1411,7 +1412,7 @@ func Test_createRun(t *testing.T) {
|
|||
opts.HttpClient = func() (*http.Client, error) {
|
||||
return &http.Client{Transport: reg}, nil
|
||||
}
|
||||
opts.Config = func() (config.Config, error) {
|
||||
opts.Config = func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
}
|
||||
opts.Remotes = func() (context.Remotes, error) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
shared "github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -309,7 +309,7 @@ type EditorRetriever interface {
|
|||
}
|
||||
|
||||
type editorRetriever struct {
|
||||
config func() (config.Config, error)
|
||||
config func() (gh.Config, error)
|
||||
}
|
||||
|
||||
func (e editorRetriever) Retrieve() (string, error) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/cli/cli/v2/api"
|
||||
ghContext "github.com/cli/cli/v2/context"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -680,7 +680,7 @@ func confirmSubmission(client *http.Client, opts *MergeOptions, action shared.Ac
|
|||
|
||||
type userEditor struct {
|
||||
io *iostreams.IOStreams
|
||||
config func() (config.Config, error)
|
||||
config func() (gh.Config, error)
|
||||
}
|
||||
|
||||
func (e *userEditor) Edit(filename, startingText string) (string, error) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
|
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
type ReviewOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
Prompter prompter.Prompter
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
|
|
@ -176,7 +177,7 @@ func runCommand(rt http.RoundTripper, prompter prompter.Prompter, isTTY bool, cl
|
|||
HttpClient: func() (*http.Client, error) {
|
||||
return &http.Client{Transport: rt}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
Prompter: prompter,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/text"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -206,7 +206,7 @@ func CommentableConfirmSubmitSurvey(p Prompt) func() (bool, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func CommentableInteractiveEditSurvey(cf func() (config.Config, error), io *iostreams.IOStreams) func(string) (string, error) {
|
||||
func CommentableInteractiveEditSurvey(cf func() (gh.Config, error), io *iostreams.IOStreams) func(string) (string, error) {
|
||||
return func(initialValue string) (string, error) {
|
||||
editorCommand, err := cmdutil.DetermineEditor(cf)
|
||||
if err != nil {
|
||||
|
|
@ -219,7 +219,7 @@ func CommentableInteractiveEditSurvey(cf func() (config.Config, error), io *iost
|
|||
}
|
||||
}
|
||||
|
||||
func CommentableEditSurvey(cf func() (config.Config, error), io *iostreams.IOStreams) func(string) (string, error) {
|
||||
func CommentableEditSurvey(cf func() (gh.Config, error), io *iostreams.IOStreams) func(string) (string, error) {
|
||||
return func(initialValue string) (string, error) {
|
||||
editorCommand, err := cmdutil.DetermineEditor(cf)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import (
|
|||
"github.com/cli/cli/v2/api"
|
||||
ghContext "github.com/cli/cli/v2/context"
|
||||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
fd "github.com/cli/cli/v2/internal/featuredetection"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/text"
|
||||
"github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
|
|
@ -26,7 +26,7 @@ import (
|
|||
type StatusOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
GitClient *git.Client
|
||||
Config func() (config.Config, error)
|
||||
Config func() (gh.Config, error)
|
||||
IO *iostreams.IOStreams
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
Remotes func() (ghContext.Remotes, error)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/cli/cli/v2/git"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
fd "github.com/cli/cli/v2/internal/featuredetection"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/internal/run"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -37,7 +38,7 @@ func runCommandWithDetector(rt http.RoundTripper, branch string, isTTY bool, cli
|
|||
HttpClient: func() (*http.Client, error) {
|
||||
return &http.Client{Transport: rt}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
Config: func() (gh.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
BaseRepo: func() (ghrepo.Interface, error) {
|
||||
|
|
|
|||
|
|
@ -2,18 +2,19 @@ package link
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/project/shared/client"
|
||||
"github.com/cli/cli/v2/pkg/cmd/project/shared/queries"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/spf13/cobra"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type linkOpts struct {
|
||||
|
|
@ -30,7 +31,7 @@ type linkOpts struct {
|
|||
|
||||
type linkConfig struct {
|
||||
httpClient func() (*http.Client, error)
|
||||
config func() (config.Config, error)
|
||||
config func() (gh.Config, error)
|
||||
client *queries.Client
|
||||
opts linkOpts
|
||||
io *iostreams.IOStreams
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue