mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
pseudo-version: Fix annotated tag detection and support pre-versions
This commit is contained in:
parent
0eb4a7831b
commit
cbcb41842f
@ -19,7 +19,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
versionRegex = regexp.MustCompile(`^v\d+\.\d+\.\d+$`)
|
versionRegex = regexp.MustCompile(`^v\d+\.\d+\.\d+(?:-pre)?$`)
|
||||||
tagReference = regexp.MustCompile(`^refs/tags/([^/]+)$`)
|
tagReference = regexp.MustCompile(`^refs/tags/([^/]+)$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -123,11 +123,15 @@ func (g *Git) tagsByRevisionHash() (map[string][]string, error) {
|
|||||||
}
|
}
|
||||||
if err := refs.ForEach(
|
if err := refs.ForEach(
|
||||||
func(ref *plumbing.Reference) error {
|
func(ref *plumbing.Reference) error {
|
||||||
|
hash, err := g.tagRefToHash(ref)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
message, err := tagRefToName(ref)
|
message, err := tagRefToName(ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tags[ref.Hash().String()] = append(tags[ref.Hash().String()], message)
|
tags[hash] = append(tags[hash], message)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
@ -146,6 +150,19 @@ func (g *Git) findVersionTag(tags []string) *string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Git) tagRefToHash(tagRef *plumbing.Reference) (string, error) {
|
||||||
|
tagObject, err := g.repo.TagObject(tagRef.Hash())
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return tagObject.Target.String(), nil
|
||||||
|
case plumbing.ErrObjectNotFound:
|
||||||
|
return tagRef.Hash().String(), nil
|
||||||
|
default:
|
||||||
|
// Some other error
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// tagRefToName extracts the name of a tag reference.
|
// tagRefToName extracts the name of a tag reference.
|
||||||
func tagRefToName(tagRef *plumbing.Reference) (string, error) {
|
func tagRefToName(tagRef *plumbing.Reference) (string, error) {
|
||||||
matches := tagReference.FindStringSubmatch(tagRef.Name().String())
|
matches := tagReference.FindStringSubmatch(tagRef.Name().String())
|
||||||
|
Loading…
Reference in New Issue
Block a user