| 1 | package gitscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/ |
| 2 | |
| 3 | import ( |
| 4 | "unicodescip-go gomod github.com/golang/go/src go1.16 unicode/" |
| 5 | |
| 6 | "github.com/go-git/go-git/v5/plumbing/objectscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/object`/" |
| 7 | ) |
| 8 | |
| 9 | // Alphabetical slice is the re-ordered *Repository slice that sorted according |
| 10 | // to alphabetical order (A-Z) |
| 11 | type Alphabeticalscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Alphabetical# []*Repositoryscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Repository# |
| 12 | |
| 13 | // Len is the interface implementation for Alphabetical sorting function |
| 14 | func (s Alphabeticalscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Alphabetical#) Lenscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Alphabetical#Len().() int { return len(s) } |
| 15 | |
| 16 | // Swap is the interface implementation for Alphabetical sorting function |
| 17 | func (s Alphabeticalscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Alphabetical#) Swapscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Alphabetical#Swap().(i, j int) { s[i], s[j] = s[j], s[i] } |
| 18 | |
| 19 | // Less is the interface implementation for Alphabetical sorting function |
| 20 | func (s Alphabeticalscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Alphabetical#) Lessscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Alphabetical#Less().(i, j int) bool { |
| 21 | iRunes := []rune(s[i].Namescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Repository#Name.) |
| 22 | jRunes := []rune(s[j].Namescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Repository#Name.) |
| 23 | |
| 24 | max := len(iRunes) |
| 25 | if max > len(jRunes) { |
| 26 | max = len(jRunes) |
| 27 | } |
| 28 | |
| 29 | for idx := 0; idx < max; idx++ { |
| 30 | ir := iRunes[idx] |
| 31 | jr := jRunes[idx] |
| 32 | |
| 33 | lir := unicodescip-go gomod github.com/golang/go/src go1.16 unicode/.ToLowerscip-go gomod github.com/golang/go/src go1.16 unicode/ToLower().(ir) |
| 34 | ljr := unicodescip-go gomod github.com/golang/go/src go1.16 unicode/.ToLowerscip-go gomod github.com/golang/go/src go1.16 unicode/ToLower().(jr) |
| 35 | |
| 36 | if lir != ljr { |
| 37 | return lir < ljr |
| 38 | } |
| 39 | |
| 40 | // the lowercase runes are the same, so compare the original |
| 41 | if ir != jr { |
| 42 | return ir < jr |
| 43 | } |
| 44 | } |
| 45 | return false |
| 46 | } |
| 47 | |
| 48 | // LastModified slice is the re-ordered *Repository slice that sorted according |
| 49 | // to last modified date of the repository directory |
| 50 | type LastModifiedscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/LastModified# []*Repositoryscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Repository# |
| 51 | |
| 52 | // Len is the interface implementation for LastModified sorting function |
| 53 | func (s LastModifiedscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/LastModified#) Lenscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/LastModified#Len().() int { return len(s) } |
| 54 | |
| 55 | // Swap is the interface implementation for LastModified sorting function |
| 56 | func (s LastModifiedscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/LastModified#) Swapscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/LastModified#Swap().(i, j int) { s[i], s[j] = s[j], s[i] } |
| 57 | |
| 58 | // Less is the interface implementation for LastModified sorting function |
| 59 | func (s LastModifiedscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/LastModified#) Lessscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/LastModified#Less().(i, j int) bool { |
| 60 | return s[i].ModTimescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Repository#ModTime..Unixscip-go gomod github.com/golang/go/src go1.16 time/Time#Unix().() > s[j].ModTimescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Repository#ModTime..Unixscip-go gomod github.com/golang/go/src go1.16 time/Time#Unix().() |
| 61 | } |
| 62 | |
| 63 | // Less returns a comparison between to repositories by name |
| 64 | func Lessscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Less().(ri, rj *Repositoryscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Repository#) bool { |
| 65 | iRunes := []rune(ri.Namescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Repository#Name.) |
| 66 | jRunes := []rune(rj.Namescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Repository#Name.) |
| 67 | |
| 68 | max := len(iRunes) |
| 69 | if max > len(jRunes) { |
| 70 | max = len(jRunes) |
| 71 | } |
| 72 | |
| 73 | for idx := 0; idx < max; idx++ { |
| 74 | ir := iRunes[idx] |
| 75 | jr := jRunes[idx] |
| 76 | |
| 77 | lir := unicodescip-go gomod github.com/golang/go/src go1.16 unicode/.ToLowerscip-go gomod github.com/golang/go/src go1.16 unicode/ToLower().(ir) |
| 78 | ljr := unicodescip-go gomod github.com/golang/go/src go1.16 unicode/.ToLowerscip-go gomod github.com/golang/go/src go1.16 unicode/ToLower().(jr) |
| 79 | |
| 80 | if lir != ljr { |
| 81 | return lir < ljr |
| 82 | } |
| 83 | |
| 84 | // the lowercase runes are the same, so compare the original |
| 85 | if ir != jr { |
| 86 | return ir < jr |
| 87 | } |
| 88 | } |
| 89 | return false |
| 90 | } |
| 91 | |
| 92 | // CommitTime slice is the re-ordered *object.Commit slice that sorted according |
| 93 | // commit date |
| 94 | type CommitTimescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/CommitTime# []*objectscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/object`/.Commitscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/object`/Commit# |
| 95 | |
| 96 | // Len is the interface implementation for LastModified sorting function |
| 97 | func (s CommitTimescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/CommitTime#) Lenscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/CommitTime#Len().() int { return len(s) } |
| 98 | |
| 99 | // Swap is the interface implementation for LastModified sorting function |
| 100 | func (s CommitTimescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/CommitTime#) Swapscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/CommitTime#Swap().(i, j int) { s[i], s[j] = s[j], s[i] } |
| 101 | |
| 102 | // Less is the interface implementation for LastModified sorting function |
| 103 | func (s CommitTimescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/CommitTime#) Lessscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/CommitTime#Less().(i, j int) bool { |
| 104 | return s[i].Authorscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/object`/Commit#Author..Whenscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/object`/Signature#When..Unixscip-go gomod github.com/golang/go/src go1.16 time/Time#Unix().() > s[j].Authorscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/object`/Commit#Author..Whenscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/object`/Signature#When..Unixscip-go gomod github.com/golang/go/src go1.16 time/Time#Unix().() |
| 105 | } |