MCPcopy Create free account
hub / github.com/git-bug/git-bug / Store

Function Store

bridge/core/auth/credential.go:192–217  ·  view source on GitHub ↗

Store stores a credential in the global git config

(repo repository.RepoKeyring, cred Credential)

Source from the content-addressed store, hash-verified

190
191// Store stores a credential in the global git config
192func Store(repo repository.RepoKeyring, cred Credential) error {
193 if len(cred.Salt()) != 16 {
194 panic("credentials need to be salted")
195 }
196
197 confs := cred.toConfig()
198
199 confs[keyringKeyKind] = string(cred.Kind())
200 confs[keyringKeyTarget] = cred.Target()
201 confs[keyringKeyCreateTime] = strconv.Itoa(int(cred.CreateTime().Unix()))
202 confs[keyringKeySalt] = base64.StdEncoding.EncodeToString(cred.Salt())
203
204 for key, val := range cred.Metadata() {
205 confs[keyringKeyPrefixMeta+key] = val
206 }
207
208 data, err := json.Marshal(confs)
209 if err != nil {
210 return err
211 }
212
213 return repo.Keyring().Set(repository.Item{
214 Key: keyringKeyPrefix + cred.ID().String(),
215 Data: data,
216 })
217}
218
219// Remove removes a credential from the global git config
220func Remove(repo repository.RepoKeyring, id entity.Id) error {

Callers 10

TestGithubImporterFunction · 0.92
TestGithubPushPullFunction · 0.92
ConfigureMethod · 0.92
TestGitlabImportFunction · 0.92
TestGitlabPushPullFunction · 0.92
ConfigureMethod · 0.92
ConfigureMethod · 0.92
runBridgeAuthAddTokenFunction · 0.92
TestCredentialFunction · 0.85
testCredentialSerialFunction · 0.85

Calls 10

SetMethod · 0.80
SaltMethod · 0.65
toConfigMethod · 0.65
KindMethod · 0.65
TargetMethod · 0.65
CreateTimeMethod · 0.65
MetadataMethod · 0.65
KeyringMethod · 0.65
StringMethod · 0.65
IDMethod · 0.65

Tested by 6

TestGithubImporterFunction · 0.74
TestGithubPushPullFunction · 0.74
TestGitlabImportFunction · 0.74
TestGitlabPushPullFunction · 0.74
TestCredentialFunction · 0.68
testCredentialSerialFunction · 0.68