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.
refactor
c5902451905acdaa478f8476844ccd4a510d9ca9 · Keenan Nemetz · 16d ago · parent ec2aba4b
internal/format/format.go +45
| @@ -0,0 +1,45 @@ | |||
| 1 | // Package format renders values the way Vole's human-facing surfaces show them. | ||
| 2 | // | ||
| 3 | // It is deliberately internal: these are presentation choices for the CLI, the | ||
| 4 | // web UI and hook messages, not part of the API a developer embeds. | ||
| 5 | package format | ||
| 6 | |||
| 7 | import "fmt" | ||
| 8 | |||
| 9 | // Bytes renders a byte count in binary units ("1.4 MiB"). | ||
| 10 | func Bytes(n int64) string { | ||
| 11 | const unit = 1024 | ||
| 12 | if n < unit { | ||
| 13 | return fmt.Sprintf("%d B", n) | ||
| 14 | } | ||
| 15 | div, exp := int64(unit), 0 | ||
| 16 | for m := n / unit; m >= unit; m /= unit { | ||
| 17 | div *= unit | ||
| 18 | exp++ | ||
| 19 | } | ||
| 20 | return fmt.Sprintf("%.1f %ciB", float64(n)/float64(div), "KMGTPE"[exp]) | ||
| 21 | } | ||
| 22 | |||
| 23 | // SHA is the short form of a commit id used in links and log lines. | ||
| 24 | func SHA(s string) string { | ||
| 25 | if len(s) > 8 { | ||
| 26 | return s[:8] | ||
| 27 | } | ||
| 28 | return s | ||
| 29 | } | ||
| 30 | |||
| 31 | // OID is the short form of an object id shown beside an upload. | ||
| 32 | func OID(s string) string { | ||
| 33 | if len(s) > 12 { | ||
| 34 | return s[:12] | ||
| 35 | } | ||
| 36 | return s | ||
| 37 | } | ||
| 38 | |||
| 39 | // ID is the short form of an entity id (issue, request, comment, run). | ||
| 40 | func ID(s string) string { | ||
| 41 | if len(s) > 8 { | ||
| 42 | return s[:8] | ||
| 43 | } | ||
| 44 | return s | ||
| 45 | } | ||