MCPcopy
hub / github.com/cli/cli / preMigrationLogin

Function preMigrationLogin

internal/config/auth_config_test.go:929–949  ·  view source on GitHub ↗

Copied and pasted directly from the trunk branch before doing any work on login, plus the addition of AuthConfig as the first arg since it is a method receiver in the real implementation.

(c *AuthConfig, hostname, username, token, gitProtocol string, secureStorage bool)

Source from the content-addressed store, hash-verified

927// login, plus the addition of AuthConfig as the first arg since it is a method
928// receiver in the real implementation.
929func preMigrationLogin(c *AuthConfig, hostname, username, token, gitProtocol string, secureStorage bool) (bool, error) {
930 var setErr error
931 if secureStorage {
932 if setErr = keyring.Set(keyringServiceName(hostname), "", token); setErr == nil {
933 // Clean up the previous oauth_token from the config file.
934 _ = c.cfg.Remove([]string{hostsKey, hostname, oauthTokenKey})
935 }
936 }
937 insecureStorageUsed := false
938 if !secureStorage || setErr != nil {
939 c.cfg.Set([]string{hostsKey, hostname, oauthTokenKey}, token)
940 insecureStorageUsed = true
941 }
942
943 c.cfg.Set([]string{hostsKey, hostname, userKey}, username)
944
945 if gitProtocol != "" {
946 c.cfg.Set([]string{hostsKey, hostname, gitProtocolKey}, gitProtocol)
947 }
948 return insecureStorageUsed, ghConfig.Write(c.cfg)
949}

Calls 5

SetFunction · 0.92
keyringServiceNameFunction · 0.70
RemoveMethod · 0.65
SetMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected