MCPcopy Create free account
hub / github.com/cli/cli / completeLogin

Method completeLogin

internal/config/config.go:572–589  ·  view source on GitHub ↗

completeLogin sets the host git protocol, ensures the user entry is persisted, and activates the user. It is shared by Login and LoginRefreshable once the credential has been stored.

(hostname, username, gitProtocol string)

Source from the content-addressed store, hash-verified

570// completeLogin sets the host git protocol, ensures the user entry is persisted, and activates the user. It is shared
571// by Login and LoginRefreshable once the credential has been stored.
572func (c *AuthConfig) completeLogin(hostname, username, gitProtocol string) error {
573 if gitProtocol != "" {
574 // Set the host level git protocol
575 // Although it might be expected that this is handled by switch, git protocol
576 // is currently a host level config and not a user level config, so any change
577 // will overwrite the protocol for all users on the host.
578 c.cfg.Set([]string{hostsKey, hostname, gitProtocolKey}, gitProtocol)
579 }
580
581 // Create the username key with an empty value so it will be
582 // written even when there are no keys set under it.
583 if _, getErr := c.cfg.Get([]string{hostsKey, hostname, usersKey, username}); getErr != nil {
584 c.cfg.Set([]string{hostsKey, hostname, usersKey, username}, "")
585 }
586
587 // Then we activate the new user
588 return c.activateUser(hostname, username)
589}
590
591func (c *AuthConfig) SwitchUser(hostname, user string) error {
592 previouslyActiveUser, err := c.ActiveUser(hostname)

Callers 2

loginRefreshableMethod · 0.95
loginMethod · 0.95

Calls 3

activateUserMethod · 0.95
SetMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected