-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.go
61 lines (55 loc) · 1.08 KB
/
core.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package gitkeys
import (
"net/url"
"sort"
"strings"
)
// addOwner ...
func (r *Repo) addOwner(ownerName, keys string) {
keySET, _, isEmpty := parseKeys([]byte(keys))
newOwner := &owner{
name: ownerName,
empty: isEmpty,
keySET: keySET,
}
newOwner.checkSum()
r.idMap[ownerName] = newOwner
}
// addEmptyOwner ...
func (r *Repo) addEmptyOwner(ownerName string) {
newOwner := &owner{
name: ownerName,
empty: true,
}
newOwner.checkSum()
r.idMap[ownerName] = newOwner
}
// getRepoOwner ...
func getRepoOwner(u *url.URL) string {
var owner string
if u.Scheme == "https" && strings.Contains(u.Host, _dot) {
s := strings.Split(u.Path, _slashfwd)
if len(s) > 0 {
owner = u.Host + _slashfwd + s[1]
}
}
return owner
}
// sortedOwnerMapIdx ...
func sortedOwnerMapIdx(ownerMap *map[string]*owner) []string {
var s []string
for k := range *ownerMap {
s = append(s, k)
}
sort.Strings(s)
return s
}
// sortedBoolMapIdx ...
func sortedBoolMapIdx(ids *map[string]bool) []string {
var s []string
for k := range *ids {
s = append(s, k)
}
sort.Strings(s)
return s
}