vole
Clone
Read only, no credentials:
https://rodent.software/git/vole.git
Write over SSH with a registered key:
git clone ssh://git@0.0.0.0:2222/vole.git
A free and open-source forge that lives in your Git repo.
|
727df386
Keenan Nemetz
8d ago
|
1 | // Package role is the ordered access role shared by a repository's rules and by |
| 2 | // workflow event filters. It lives in core because both the access store and the | |
| 3 | // workflow schema need to name a role without one importing the other. | |
| 4 | package role | |
| 5 | ||
| 6 | import ( | |
| 7 | "fmt" | |
| 8 | "strings" | |
| 9 | ) | |
| 10 | ||
| 11 | type Role int | |
| 12 | ||
| 13 | const ( | |
| 14 | None Role = iota | |
| 15 | Read | |
| 16 | Contribute | |
| 17 | Maintain | |
| 18 | Admin | |
| 19 | ) | |
| 20 | ||
| 21 | // Parse accepts the canonical names and the historical spellings used by ACL rows | |
| 22 | // and scripts, so a workflow can say "write" or "maintain" and mean the same thing. | |
| 23 | func Parse(s string) (Role, error) { | |
| 24 | switch strings.ToLower(strings.TrimSpace(s)) { | |
| 25 | case "", "none": | |
| 26 | return None, nil | |
| 27 | case "read": | |
| 28 | return Read, nil | |
| 29 | case "contribute", "contributor", "contrib": | |
| 30 | return Contribute, nil | |
| 31 | case "maintain", "maintainer", "write": | |
| 32 | return Maintain, nil | |
| 33 | case "admin", "owner": | |
| 34 | return Admin, nil | |
| 35 | } | |
| 36 | return None, fmt.Errorf("unknown role %q (want none, read, contribute, maintain or admin)", s) | |
| 37 | } | |
| 38 | ||
| 39 | func (r Role) String() string { | |
| 40 | switch r { | |
| 41 | case Read: | |
| 42 | return "read" | |
| 43 | case Contribute: | |
| 44 | return "contribute" | |
| 45 | case Maintain: | |
| 46 | return "maintain" | |
| 47 | case Admin: | |
| 48 | return "admin" | |
| 49 | } | |
| 50 | return "none" | |
| 51 | } | |
| 52 | ||
| 53 | func (r Role) AtLeast(need Role) bool { return r >= need } |