MCPcopy Index your code
hub / github.com/git-bug/git-bug / Configure

Method Configure

bridge/github/config.go:42–162  ·  view source on GitHub ↗
(repo *cache.RepoCache, params core.BridgeParams, interactive bool)

Source from the content-addressed store, hash-verified

40}
41
42func (g *Github) Configure(repo *cache.RepoCache, params core.BridgeParams, interactive bool) (core.Configuration, error) {
43 var err error
44 var owner string
45 var project string
46 var ok bool
47
48 // getting owner and project name
49 switch {
50 case params.Owner != "" && params.Project != "":
51 // first try to use params if both or project and owner are provided
52 owner = params.Owner
53 project = params.Project
54 case params.URL != "":
55 // try to parse params URL and extract owner and project
56 owner, project, err = splitURL(params.URL)
57 if err != nil {
58 return nil, err
59 }
60 default:
61 // terminal prompt
62 if !interactive {
63 return nil, fmt.Errorf("Non-interactive-mode is active. Please specify the remote repository with --owner and --project, or via --url option.")
64 }
65 owner, project, err = promptURL(repo)
66 if err != nil {
67 return nil, err
68 }
69 }
70
71 // validate project owner and override with the correct case
72 ok, owner, err = validateUsername(owner)
73 if err != nil {
74 return nil, err
75 }
76 if !ok {
77 return nil, fmt.Errorf("invalid parameter owner: %v", owner)
78 }
79
80 var login string
81 var cred auth.Credential
82
83 switch {
84 case params.CredPrefix != "":
85 cred, err = auth.LoadWithPrefix(repo, params.CredPrefix)
86 if err != nil {
87 return nil, err
88 }
89 l, ok := cred.GetMetadata(auth.MetaKeyLogin)
90 if !ok {
91 return nil, fmt.Errorf("credential doesn't have a login")
92 }
93 login = l
94 case params.TokenRaw != "":
95 token := auth.NewToken(target, params.TokenRaw)
96 login, err = getLoginFromToken(token)
97 if err != nil {
98 return nil, err
99 }

Callers

nothing calls this directly

Calls 15

GetMetadataMethod · 0.95
ValidateConfigMethod · 0.95
IDMethod · 0.95
LoadWithPrefixFunction · 0.92
NewTokenFunction · 0.92
IdExistFunction · 0.92
StoreFunction · 0.92
FinishConfigFunction · 0.92
promptURLFunction · 0.85
validateUsernameFunction · 0.85
promptLoginFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected