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

Method SetMetadata

entities/identity/identity.go:531–542  ·  view source on GitHub ↗

SetMetadata store arbitrary metadata along the last not-commit version. If the version has been commit to git already, a new identical version is added and will need to be commit.

(key string, value string)

Source from the content-addressed store, hash-verified

529// If the version has been commit to git already, a new identical version is added and will need to be
530// commit.
531func (i *Identity) SetMetadata(key string, value string) {
532 // once commit, data is immutable so we create a new version
533 if i.lastVersion().commitHash != "" {
534 i.versions = append(i.versions, i.lastVersion().Clone())
535 }
536 // if Id() has been called, we can't change the first version anymore, so we create a new version
537 if len(i.versions) == 1 && i.versions[0].id != entity.UnsetId && i.versions[0].id != "" {
538 i.versions = append(i.versions, i.lastVersion().Clone())
539 }
540
541 i.lastVersion().SetMetadata(key, value)
542}
543
544// ImmutableMetadata return all metadata for this Identity, accumulated from each version.
545// If multiple value are found, the first defined takes precedence.

Callers 3

TestGithubImporterFunction · 0.95
TestGitlabImportFunction · 0.95
TestMetadataFunction · 0.95

Calls 3

lastVersionMethod · 0.95
SetMetadataMethod · 0.65
CloneMethod · 0.45

Tested by 3

TestGithubImporterFunction · 0.76
TestGitlabImportFunction · 0.76
TestMetadataFunction · 0.76