| 1 | package configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/ |
| 2 | |
| 3 | import ( |
| 4 | "errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/" |
| 5 | "sortscip-go gomod github.com/golang/go/src go1.25.0 sort/" |
| 6 | |
| 7 | "github.com/git-lfs/git-lfs/v3/trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/" |
| 8 | ) |
| 9 | |
| 10 | // An Extension describes how to manipulate files during smudge and clean. |
| 11 | // Extensions are parsed from the Git config. |
| 12 | type Extensionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Extension# struct { |
| 13 | Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Extension#Name. string |
| 14 | Cleanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Extension#Clean. string |
| 15 | Smudgescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Extension#Smudge. string |
| 16 | Priorityscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Extension#Priority. int |
| 17 | } |
| 18 | |
| 19 | // SortExtensions sorts a map of extensions in ascending order by Priority |
| 20 | func SortExtensionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/SortExtensions().(m map[string]Extensionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Extension#) ([]Extensionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Extension#, error) { |
| 21 | pMap := make(map[int]Extensionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Extension#) |
| 22 | priorities := make([]int, 0, len(m)) |
| 23 | for n, ext := range m { |
| 24 | p := ext.Priorityscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Extension#Priority. |
| 25 | if _, exist := pMap[p]; exist { |
| 26 | err := errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("duplicate priority %d on %s", p, n)) |
| 27 | return nil, err |
| 28 | } |
| 29 | pMap[p] = ext |
| 30 | priorities = append(priorities, p) |
| 31 | } |
| 32 | |
| 33 | sortscip-go gomod github.com/golang/go/src go1.25.0 sort/.Intsscip-go gomod github.com/golang/go/src go1.25.0 sort/Ints().(priorities) |
| 34 | |
| 35 | result := make([]Extensionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Extension#, len(priorities)) |
| 36 | for i, p := range priorities { |
| 37 | result[i] = pMap[p] |
| 38 | } |
| 39 | |
| 40 | return result, nil |
| 41 | } |