refactor(ninja): use slices.Equal in mutateTags
This commit is contained in:
parent
03d32aba26
commit
e16655aed8
@ -3,6 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -133,7 +134,7 @@ func mutateTags(op string, args []string) error {
|
|||||||
sort.Strings(sortedBefore)
|
sort.Strings(sortedBefore)
|
||||||
sort.Strings(sortedAfter)
|
sort.Strings(sortedAfter)
|
||||||
fmt.Printf("Tags: [%s] → [%s]\n", strings.Join(sortedBefore, ", "), strings.Join(sortedAfter, ", "))
|
fmt.Printf("Tags: [%s] → [%s]\n", strings.Join(sortedBefore, ", "), strings.Join(sortedAfter, ", "))
|
||||||
if !equalStringSlices(sortedBefore, sortedAfter) {
|
if !slices.Equal(sortedBefore, sortedAfter) {
|
||||||
fmt.Println("Run 'ninja plugin publish' to push to the registry.")
|
fmt.Println("Run 'ninja plugin publish' to push to the registry.")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -166,14 +167,3 @@ func writeLocalModTags(mod *core.ModFile, tags []string) error {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func equalStringSlices(a, b []string) bool {
|
|
||||||
if len(a) != len(b) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for i := range a {
|
|
||||||
if a[i] != b[i] {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user