Notes added by 'git notes append'
This commit is contained in:
parent
55dc4d55e8
commit
332563bf83
|
@ -34,3 +34,174 @@ google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTm
|
||||||
google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||||
|
|
||||||
// `autogen:gitTag.find.pb.go`
|
// `autogen:gitTag.find.pb.go`
|
||||||
|
|
||||||
|
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
|
||||||
|
// This file was autogenerated with autogenpb v0.0.40-20-g95afc5e 2025.01.11_0606
|
||||||
|
// go install go.wit.com/apps/autogenpb@latest
|
||||||
|
//
|
||||||
|
// define which structs (messages) you want to use in the .proto file
|
||||||
|
// Then sort.pb.go and marshal.pb.go files are autogenerated
|
||||||
|
//
|
||||||
|
// autogenpb uses it and has an example .proto file with instructions
|
||||||
|
//
|
||||||
|
|
||||||
|
package gitpb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
// a simple global lock
|
||||||
|
var gitTagMu sync.RWMutex
|
||||||
|
|
||||||
|
// just a simple Append() shortcut (but still uses the mutex lock)
|
||||||
|
func (x *GitTags) Append(y *GitTag) {
|
||||||
|
gitTagMu.Lock()
|
||||||
|
defer gitTagMu.Unlock()
|
||||||
|
|
||||||
|
x.GitTags = append(x.GitTags, y)
|
||||||
|
}
|
||||||
|
|
||||||
|
// lookup a GitTags by the Refname
|
||||||
|
func (x *GitTags) FindByRefname(s string) *GitTag {
|
||||||
|
if x == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
gitTagMu.RLock()
|
||||||
|
defer gitTagMu.RUnlock()
|
||||||
|
|
||||||
|
for i, _ := range x.GitTags {
|
||||||
|
if x.GitTags[i].Refname == s {
|
||||||
|
return x.GitTags[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// lookup a GitTags by the Hash
|
||||||
|
func (x *GitTags) FindByHash(s string) *GitTag {
|
||||||
|
if x == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
gitTagMu.RLock()
|
||||||
|
defer gitTagMu.RUnlock()
|
||||||
|
|
||||||
|
for i, _ := range x.GitTags {
|
||||||
|
if x.GitTags[i].Hash == s {
|
||||||
|
return x.GitTags[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// enforces GitTag.Refname is unique in GitTags.GitTags
|
||||||
|
func (x *GitTags) AppendUniqueRefname(newP *GitTag) bool {
|
||||||
|
gitTagMu.Lock()
|
||||||
|
defer gitTagMu.Unlock()
|
||||||
|
|
||||||
|
for _, p := range x.GitTags {
|
||||||
|
if p.Refname == newP.Refname {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x.GitTags = append(x.GitTags, newP)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// enforces GitTag.Hash is unique in GitTags.GitTags
|
||||||
|
func (x *GitTags) AppendUniqueHash(newP *GitTag) bool {
|
||||||
|
gitTagMu.Lock()
|
||||||
|
defer gitTagMu.Unlock()
|
||||||
|
|
||||||
|
for _, p := range x.GitTags {
|
||||||
|
if p.Hash == newP.Hash {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x.GitTags = append(x.GitTags, newP)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// enforces GitTag is unique in GitTags.GitTags
|
||||||
|
func (x *GitTags) AppendUnique(newP *GitTag) bool {
|
||||||
|
gitTagMu.Lock()
|
||||||
|
defer gitTagMu.Unlock()
|
||||||
|
|
||||||
|
for _, p := range x.GitTags {
|
||||||
|
if p.Refname == newP.Refname {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if p.Hash == newP.Hash {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x.GitTags = append(x.GitTags, newP)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GitTags) DeleteByRefname(s string) bool {
|
||||||
|
gitTagMu.Lock()
|
||||||
|
defer gitTagMu.Unlock()
|
||||||
|
|
||||||
|
for i, _ := range x.GitTags {
|
||||||
|
if x.GitTags[i].Refname == s {
|
||||||
|
x.GitTags[i] = x.GitTags[len(x.GitTags)-1]
|
||||||
|
x.GitTags = x.GitTags[:len(x.GitTags)-1]
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GitTags) DeleteByHash(s string) bool {
|
||||||
|
gitTagMu.Lock()
|
||||||
|
defer gitTagMu.Unlock()
|
||||||
|
|
||||||
|
for i, _ := range x.GitTags {
|
||||||
|
if x.GitTags[i].Hash == s {
|
||||||
|
x.GitTags[i] = x.GitTags[len(x.GitTags)-1]
|
||||||
|
x.GitTags = x.GitTags[:len(x.GitTags)-1]
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns an GitTag if Refname matches, otherwise create
|
||||||
|
func (x *GitTags) InsertByRefname(y string) *GitTag {
|
||||||
|
gitTagMu.Lock()
|
||||||
|
defer gitTagMu.Unlock()
|
||||||
|
|
||||||
|
for _, p := range x.GitTags {
|
||||||
|
if p.Refname == y {
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
z := new(GitTag)
|
||||||
|
z.Refname = y
|
||||||
|
x.GitTags = append(x.GitTags, z)
|
||||||
|
return z
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns an GitTag if Hash matches, otherwise create
|
||||||
|
func (x *GitTags) InsertByHash(y string) *GitTag {
|
||||||
|
gitTagMu.Lock()
|
||||||
|
defer gitTagMu.Unlock()
|
||||||
|
|
||||||
|
for _, p := range x.GitTags {
|
||||||
|
if p.Hash == y {
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
z := new(GitTag)
|
||||||
|
z.Hash = y
|
||||||
|
x.GitTags = append(x.GitTags, z)
|
||||||
|
return z
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue