Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software:2222/vole.git

A free and open-source forge that lives in your Git repo.

refactor

c5902451905acdaa478f8476844ccd4a510d9ca9 · Keenan Nemetz · 17d ago · parent ec2aba4b

internal/hook/lfs.go → server/hook/lfs.go +6−18

@@ -16,13 +16,14 @@ import (
16 16 "sort"
17 17 "strings"
18 18
19 "github.com/rodent-software/vole/internal/gitx"
20 "github.com/rodent-software/vole/internal/lfs"
19 "github.com/rodent-software/vole/core/git"
20 "github.com/rodent-software/vole/core/lfs"
21 "github.com/rodent-software/vole/internal/format"
21 22 )
22 23
23 24 // lfsFindings scans the blobs of the tree a pushed ref will serve. problems
24 25 // reject the push, warnings are printed and the push proceeds.
25 func lfsFindings(g *gitx.Repo, repo, new string, store *lfs.Store, warnBytes int64) (problems, warnings []string, err error) {
26 func lfsFindings(g *git.Repo, repo, new string, store *lfs.Store, warnBytes int64) (problems, warnings []string, err error) {
26 27 if store == nil {
27 28 return nil, nil, fmt.Errorf("no LFS store configured")
28 29 }
@@ -64,7 +65,7 @@ func lfsFindings(g *gitx.Repo, repo, new string, store *lfs.Store, warnBytes int
64 65 "%s is %s and stored in git. Track it with LFS instead:\n"+
65 66 " git lfs track %q && git add .gitattributes %s\n"+
66 67 " (a file already in history needs `git lfs migrate import --include=%q`)",
67 b.Path, humanSize(b.Size), trackPattern(b.Path), b.Path, trackPattern(b.Path)))
68 b.Path, format.Bytes(b.Size), trackPattern(b.Path), b.Path, trackPattern(b.Path)))
68 69 }
69 70 return problems, warnings, nil
70 71 }
@@ -76,7 +77,7 @@ func pointerProblem(store *lfs.Store, repo string, p lfs.Pointer, path string) [
76 77 "%s points at LFS object %s (%s), which is not on this server. "+
77 78 "Upload it first: git lfs push origin <ref> for a tracked file, "+
78 79 "or vole release attach <tag> <file> for a release artifact",
79 path, oidShort(p.OID), humanSize(p.Size))}
80 path, oidShort(p.OID), format.Bytes(p.Size))}
80 81 }
81 82 if p.Size > 0 && size != p.Size {
82 83 return []string{fmt.Sprintf(
@@ -121,19 +122,6 @@ func trackPattern(path string) string {
121 122 return path
122 123 }
123 124
124 func humanSize(n int64) string {
125 const unit = 1024
126 if n < unit {
127 return fmt.Sprintf("%d B", n)
128 }
129 div, exp := int64(unit), 0
130 for m := n / unit; m >= unit; m /= unit {
131 div *= unit
132 exp++
133 }
134 return fmt.Sprintf("%.1f %ciB", float64(n)/float64(div), "KMGTPE"[exp])
135 }
136
137 125 // printWarnings writes findings the push accepts anyway. They go to the same
138 126 // stream as rejections, which git forwards to the client as remote: lines.
139 127 func printWarnings(w io.Writer, warnings []string) {