Skip to content

Commit 2cccd4b

Browse files
authored
fix reverse tags (Azure#18900)
* fix reverse tags * upgrade to @autorest/gotest@4.2.2 * fix * fix * add releaseTagsSort
1 parent 912f496 commit 2cccd4b

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

eng/scripts/MgmtTestLib.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function Invoke-MgmtTestgen ()
2121
[string]$config = "autorest.md",
2222
[string]$autorestVersion = "3.8.2",
2323
[string]$goExtension = "@autorest/go@4.0.0-preview.43",
24-
[string]$testExtension = "@autorest/gotest@4.2.1",
24+
[string]$testExtension = "@autorest/gotest@4.2.2",
2525
[string]$outputFolder
2626
)
2727
if ($clean)

eng/tools/generator/cmd/v2/common/changlogProcessor.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,29 @@ func GetAllVersionTags(rpName, namespaceName string) ([]string, error) {
4848
tags = append(tags, tag["ref"].(string))
4949
}
5050
}
51-
sort.Sort(sort.Reverse(sort.StringSlice(tags)))
51+
sort.Sort(releaseTagsSort(tags))
5252

5353
return tags, nil
5454
}
5555

56+
type releaseTagsSort []string
57+
58+
func (t releaseTagsSort) Len() int {
59+
return len(t)
60+
}
61+
62+
func (t releaseTagsSort) Swap(i, j int) {
63+
t[i], t[j] = t[j], t[i]
64+
}
65+
66+
func (t releaseTagsSort) Less(i, j int) bool {
67+
if t[i] > t[j] {
68+
return !strings.Contains(t[i], t[j])
69+
} else {
70+
return strings.Contains(t[j], t[i])
71+
}
72+
}
73+
5674
func ContainsPreviewAPIVersion(packagePath string) (bool, error) {
5775
log.Printf("Judge whether contains preview API version from '%s' ...", packagePath)
5876

0 commit comments

Comments
 (0)