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/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/hook/hook_test.go → server/hook/hook_test.go +10−11

@@ -8,11 +8,10 @@ import (
8 8 "strings"
9 9 "testing"
10 10
11 "github.com/rodent-software/vole/internal/access"
12 "github.com/rodent-software/vole/internal/acl"
13 "github.com/rodent-software/vole/internal/gitx"
14 "github.com/rodent-software/vole/internal/repo"
15 "github.com/rodent-software/vole/internal/runs"
11 "github.com/rodent-software/vole/ci/runs"
12 "github.com/rodent-software/vole/core/git"
13 "github.com/rodent-software/vole/forge/access"
14 "github.com/rodent-software/vole/forge/repo"
16 15 )
17 16
18 17 type fixture struct {
@@ -52,7 +51,7 @@ func newFixture(t *testing.T, blob string) *fixture {
52 51 if err != nil {
53 52 t.Fatal(err)
54 53 }
55 tree, err := g.MkTree([]gitx.Entry{{Mode: "100644", Type: "blob", SHA: blobSHA, Name: "readme.md"}})
54 tree, err := g.MkTree([]git.Entry{{Mode: "100644", Type: "blob", SHA: blobSHA, Name: "readme.md"}})
56 55 if err != nil {
57 56 t.Fatal(err)
58 57 }
@@ -93,12 +92,12 @@ func (f *fixture) runWith(cfg Config, ref string) (int, string) {
93 92 cfg.UsersDB = f.usersDB
94 93 }
95 94 var out bytes.Buffer
96 cfg.In = strings.NewReader(gitx.ZeroSHA + " " + f.head + " " + ref + "\n")
95 cfg.In = strings.NewReader(git.ZeroSHA + " " + f.head + " " + ref + "\n")
97 96 cfg.Out = &out
98 97 return PreReceive(cfg), out.String()
99 98 }
100 99
101 func (f *fixture) setACL(mut func(*acl.ACL)) {
100 func (f *fixture) setACL(mut func(*access.ACL)) {
102 101 f.t.Helper()
103 102 a, err := f.m.ACL()
104 103 if err != nil {
@@ -151,7 +150,7 @@ func TestAnonymousCannotPush(t *testing.T) {
151 150 func TestProtectedBranch(t *testing.T) {
152 151 t.Parallel()
153 152 f := newFixture(t, "hello\n")
154 f.setACL(func(a *acl.ACL) { a.Protected = []string{"refs/heads/main"} })
153 f.setACL(func(a *access.ACL) { a.Protected = []string{"refs/heads/main"} })
155 154
156 155 if code, out := f.run("writer", "refs/heads/main", 0); code == 0 {
157 156 t.Fatal("writer was allowed to push a protected branch")
@@ -205,7 +204,7 @@ func TestPostReceiveRecordsThePush(t *testing.T) {
205 204 t.Parallel()
206 205 dir := t.TempDir()
207 206 repoDir := filepath.Join(dir, "demo.git")
208 if err := gitx.InitBare(repoDir, "main"); err != nil {
207 if err := git.InitBare(repoDir, "main"); err != nil {
209 208 t.Fatal(err)
210 209 }
211 210 audit := filepath.Join(dir, "audit.log")
@@ -260,7 +259,7 @@ func TestPostReceiveSurvivesAnUnwritableLog(t *testing.T) {
260 259 t.Parallel()
261 260 dir := t.TempDir()
262 261 repoDir := filepath.Join(dir, "demo.git")
263 if err := gitx.InitBare(repoDir, "main"); err != nil {
262 if err := git.InitBare(repoDir, "main"); err != nil {
264 263 t.Fatal(err)
265 264 }
266 265 code := PostReceive(Config{