mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
pseudo-version: always use tag name instead of message
Signed-off-by: Malte Poll <mp@edgeless.systems>
This commit is contained in:
parent
ea9450dcfd
commit
50188d1d93
@ -86,28 +86,11 @@ 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 {
|
||||||
tag, err := g.repo.TagObject(ref.Hash())
|
message, err := tagRefToName(ref)
|
||||||
switch err {
|
if err != nil {
|
||||||
case nil:
|
|
||||||
// Tag object present
|
|
||||||
commit, err := tag.Commit()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
commitHash := commit.Hash.String()
|
|
||||||
tags[commitHash] = append(tags[commitHash], tag.Name)
|
|
||||||
case plumbing.ErrObjectNotFound:
|
|
||||||
// Not a tag object
|
|
||||||
message, err := tagRefToMessage(ref)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
tags[ref.Hash().String()] = append(tags[ref.Hash().String()], message)
|
|
||||||
default:
|
|
||||||
// Some other error
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
tags[ref.Hash().String()] = append(tags[ref.Hash().String()], message)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
@ -126,7 +109,8 @@ func (g *Git) findVersionTag(tags []string) *string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func tagRefToMessage(tagRef *plumbing.Reference) (string, error) {
|
// tagRefToName extracts the name of a tag reference.
|
||||||
|
func tagRefToName(tagRef *plumbing.Reference) (string, error) {
|
||||||
matches := tagReference.FindStringSubmatch(tagRef.Name().String())
|
matches := tagReference.FindStringSubmatch(tagRef.Name().String())
|
||||||
if len(matches) != 2 {
|
if len(matches) != 2 {
|
||||||
return "", errors.New("invalid tag reference")
|
return "", errors.New("invalid tag reference")
|
||||||
|
Loading…
Reference in New Issue
Block a user