Notes added by 'git notes append'
This commit is contained in:
parent
da33119a9d
commit
cb9b2b8e5b
|
@ -557,3 +557,101 @@ func file_gitTag_proto_init() {
|
|||
}
|
||||
|
||||
// `autogen:gitTag.sort.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 (
|
||||
"fmt"
|
||||
"sort"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type GitTagIterator struct {
|
||||
sync.RWMutex
|
||||
|
||||
things []*GitTag
|
||||
index int
|
||||
}
|
||||
|
||||
// NewGitTagIterator initializes a new iterator.
|
||||
func NewGitTagIterator(things []*GitTag) *GitTagIterator {
|
||||
return &GitTagIterator{things: things}
|
||||
}
|
||||
|
||||
// Scan moves to the next element and returns false if there are no more things.
|
||||
// Use Scan() in a loop, similar to a while loop
|
||||
//
|
||||
// for iterator.Scan()
|
||||
// d := iterator.Next(
|
||||
// fmt.Println("found UUID:", d.Uuid
|
||||
// }
|
||||
func (it *GitTagIterator) Scan() bool {
|
||||
if it.index >= len(it.things) {
|
||||
return false
|
||||
}
|
||||
it.index++
|
||||
return true
|
||||
}
|
||||
|
||||
// Next() returns the next thing in the array
|
||||
func (it *GitTagIterator) Next() *GitTag {
|
||||
if it.things[it.index-1] == nil {
|
||||
for i, d := range it.things {
|
||||
fmt.Println("i =", i, d)
|
||||
}
|
||||
}
|
||||
return it.things[it.index-1]
|
||||
}
|
||||
|
||||
func (x *GitTags) All() *GitTagIterator {
|
||||
GitTagPointers := x.selectAllGitTag()
|
||||
|
||||
iterator := NewGitTagIterator(GitTagPointers)
|
||||
return iterator
|
||||
}
|
||||
|
||||
func (x *GitTags) Len() int {
|
||||
gitTagMu.RLock()
|
||||
defer gitTagMu.RUnlock()
|
||||
|
||||
return len(x.GitTags)
|
||||
}
|
||||
|
||||
// safely returns a slice of pointers to the GitTag protobufs
|
||||
func (x *GitTags) selectAllGitTag() []*GitTag {
|
||||
gitTagMu.RLock()
|
||||
defer gitTagMu.RUnlock()
|
||||
|
||||
// Create a new slice to hold pointers to each GitTag
|
||||
var tmp []*GitTag
|
||||
tmp = make([]*GitTag, len(x.GitTags))
|
||||
for i, p := range x.GitTags {
|
||||
tmp[i] = p // Copy pointers for safe iteration
|
||||
}
|
||||
|
||||
return tmp
|
||||
}
|
||||
func (x *GitTags) SortByRefname() *GitTagIterator {
|
||||
things := x.selectAllGitTag()
|
||||
|
||||
sort.Sort(GitTagRefname(things))
|
||||
|
||||
iterator := NewGitTagIterator(things)
|
||||
return iterator
|
||||
}
|
||||
|
||||
type GitTagRefname []*GitTag
|
||||
|
||||
func (a GitTagRefname) Len() int { return len(a) }
|
||||
func (a GitTagRefname) Less(i, j int) bool { return a[i].Refname < a[j].Refname }
|
||||
func (a GitTagRefname) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
|
|
Loading…
Reference in New Issue