forked from Masterminds/glide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
semver.go
35 lines (29 loc) · 753 Bytes
/
semver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package repo
import (
"github.com/Masterminds/semver"
"github.com/Masterminds/vcs"
)
// Filter a list of versions to only included semantic versions. The response
// is a mapping of the original version to the semantic version.
func getSemVers(refs []string) []*semver.Version {
sv := []*semver.Version{}
for _, r := range refs {
v, err := semver.NewVersion(r)
if err == nil {
sv = append(sv, v)
}
}
return sv
}
// Get all the references for a repo. This includes the tags and branches.
func getAllVcsRefs(repo vcs.Repo) ([]string, error) {
tags, err := repo.Tags()
if err != nil {
return []string{}, err
}
branches, err := repo.Branches()
if err != nil {
return []string{}, err
}
return append(branches, tags...), nil
}