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

Method completeLogin

internal/config/config.go:548–565  ·  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

546// completeLogin sets the host git protocol, ensures the user entry is persisted, and activates the user. It is shared
547// by Login and LoginRefreshable once the credential has been stored.
548func (c *AuthConfig) completeLogin(hostname, username, gitProtocol string) error {
549 if gitProtocol != "" {
550 // Set the host level git protocol
551 // Although it might be expected that this is handled by switch, git protocol
552 // is currently a host level config and not a user level config, so any change
553 // will overwrite the protocol for all users on the host.
554 c.cfg.Set([]string{hostsKey, hostname, gitProtocolKey}, gitProtocol)
555 }
556
557 // Create the username key with an empty value so it will be
558 // written even when there are no keys set under it.
559 if _, getErr := c.cfg.Get([]string{hostsKey, hostname, usersKey, username}); getErr != nil {
560 c.cfg.Set([]string{hostsKey, hostname, usersKey, username}, "")
561 }
562
563 // Then we activate the new user
564 return c.activateUser(hostname, username)
565}
566
567func (c *AuthConfig) SwitchUser(hostname, user string) error {
568 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