Major rewrite with just breaking changes

This commit is contained in:
Roman Vynar
2024-04-16 13:54:18 +03:00
parent f91c3b9aca
commit e334d4c6c7
44 changed files with 1201 additions and 1156 deletions

View File

@@ -5,7 +5,6 @@ import (
"os"
"reflect"
"sort"
"strings"
"time"
"github.com/sirupsen/logrus"
@@ -60,14 +59,18 @@ func ItemInSlice(item string, slice []string) bool {
return false
}
// Sprit repo path by namespace and repo name
func SplitRepoPath(repoPath string) (string, string) {
namespace := "library"
repo := repoPath
if strings.Contains(repoPath, "/") {
f := strings.SplitN(repoPath, "/", 2)
namespace = f[0]
repo = f[1]
// UniqueSortedSlice filter out duplicate items from slice
func UniqueSortedSlice(slice []string) []string {
sort.Strings(slice)
seen := make(map[string]struct{}, len(slice))
j := 0
for _, i := range slice {
if _, ok := seen[i]; ok {
continue
}
seen[i] = struct{}{}
slice[j] = i
j++
}
return namespace, repo
return slice[:j]
}