зеркало из https://github.com/mislav/hub.git
Rename Config.DefaultCredential()
This commit is contained in:
Родитель
72516fc377
Коммит
070d5e7b86
|
@ -59,7 +59,7 @@ func transformCloneArgs(args *Args) {
|
|||
var credential *github.Credential
|
||||
if owner == "" {
|
||||
configs := github.CurrentConfigs()
|
||||
credential = configs.DefaultCredentials()
|
||||
credential = configs.DefaultCredential()
|
||||
owner = credential.User
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,12 @@ package commands
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/github/hub/git"
|
||||
"github.com/github/hub/github"
|
||||
"github.com/github/hub/utils"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var cmdCreate = &Command{
|
||||
|
@ -73,7 +74,7 @@ func create(command *Command, args *Args) {
|
|||
}
|
||||
|
||||
configs := github.CurrentConfigs()
|
||||
credentials := configs.DefaultCredentials()
|
||||
credentials := configs.DefaultCredential()
|
||||
|
||||
owner := credentials.User
|
||||
if strings.Contains(newRepoName, "/") {
|
||||
|
|
|
@ -2,9 +2,10 @@ package commands
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/github/hub/github"
|
||||
"github.com/github/hub/utils"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var cmdRemote = &Command{
|
||||
|
@ -64,7 +65,7 @@ func transformRemoteArgs(args *Args) {
|
|||
isPriavte := parseRemotePrivateFlag(args)
|
||||
if len(words) == 2 && words[1] == "origin" {
|
||||
// gh add origin
|
||||
credentials := github.CurrentConfigs().DefaultCredentials()
|
||||
credentials := github.CurrentConfigs().DefaultCredential()
|
||||
owner = credentials.User
|
||||
name = repoName
|
||||
} else if len(words) == 2 {
|
||||
|
|
|
@ -125,12 +125,8 @@ func saveTo(filename string, v interface{}) error {
|
|||
return enc.Encode(v)
|
||||
}
|
||||
|
||||
func loadFrom(filename string, c *Configs) error {
|
||||
return loadFromFile(filename, c)
|
||||
}
|
||||
|
||||
func loadFromFile(filename string, v interface{}) (err error) {
|
||||
_, err = toml.DecodeFile(filename, v)
|
||||
func loadFrom(filename string, c *Configs) (err error) {
|
||||
_, err = toml.DecodeFile(filename, c)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -153,7 +149,7 @@ func CurrentConfigs() *Configs {
|
|||
return c
|
||||
}
|
||||
|
||||
func (c *Configs) DefaultCredentials() (credential *Credential) {
|
||||
func (c *Configs) DefaultCredential() (credential *Credential) {
|
||||
if GitHubHostEnv != "" {
|
||||
credential = c.PromptFor(GitHubHostEnv)
|
||||
} else if len(c.Credentials) > 0 {
|
||||
|
|
Загрузка…
Ссылка в новой задаче