Ejemplo n.º 1
0
func fetchTags(releasePattern string, sortON bool) []string {
	out, _ := exec.Command("git", "log", "--tags", "--simplify-by-decoration", "--pretty=\"%ai @%d\"").Output()
	uncuratedTags := strings.Split(string(out), "\n")

	var tags []string
	validTag := regexp.MustCompile(fmt.Sprintf(`(.*\s)@\s.*tag:\s(%v)`, releasePattern))

	var match [][]string
	for _, tag := range uncuratedTags {
		match = validTag.FindAllStringSubmatch(tag, -1)
		if len(match) > 0 && len(match[0]) > 2 {
			// fmt.Printf("%v => %v \n", match[0][1], match[0][2])
			tags = append(tags, strings.Replace(match[0][2], ",", "", -1))
		}
	}
	if sortON {
		tags = utils.OnlyStable(tags)
		sort.Sort(utils.ByVersion(tags))
	}
	return tags
}
Ejemplo n.º 2
0
func TestOnlyStable(t *testing.T) {
	versions := []string{"1.2.rc2", "1.3.beta3", "0.0.1alfa", "0.1.1"}
	versions = utils.OnlyStable(versions)
	assert.Equal(t, []string{"0.1.1"}, versions)
}