Git backed by object storage because you can't stop me
git object-storage kefka
10

Configure Feed

Select the types of activity you want to include in your feed.

test(ssh): use absolute stat paths and harden the test harness

Address code-review feedback:
- Stat the absolute "/test.git/config" path (memfs can resolve
relative vs absolute lookups differently); matches the rest of
the package.
- Close the listener in startSSHServer cleanup as well as the
server, avoiding a listener leak if Cleanup fires before the
concurrent Serve registers the listener.
- Quote the key path in GIT_SSH_COMMAND so paths with spaces are
not mis-split when git execs ssh.
- Rename the TestGitServiceFor loop variable tc -> tt for
package-wide consistency.

Assisted-by: Claude Opus 4.8 via Claude Code

Xe Iaso (May 28, 2026, 11:38 PM EDT) ae5d6a27 d2ced24b

+13 -15
+13 -15
cmd/objgitd/ssh_test.go
··· 2 2 3 3 import ( 4 4 "bytes" 5 + "fmt" 5 6 "io" 6 7 "log/slog" 7 8 "net" ··· 19 20 ) 20 21 21 22 func TestGitServiceFor(t *testing.T) { 22 - tt := []struct { 23 + tests := []struct { 23 24 name string 24 25 command string 25 26 service string ··· 56 57 ok: false, 57 58 }, 58 59 } 59 - for _, tc := range tt { 60 - t.Run(tc.name, func(t *testing.T) { 61 - got, ok := gitServiceFor(tc.command) 62 - if ok != tc.ok { 63 - t.Errorf("gitServiceFor(%q) ok=%v, want %v", tc.command, ok, tc.ok) 60 + for _, tt := range tests { 61 + t.Run(tt.name, func(t *testing.T) { 62 + got, ok := gitServiceFor(tt.command) 63 + if ok != tt.ok { 64 + t.Errorf("gitServiceFor(%q) ok=%v, want %v", tt.command, ok, tt.ok) 64 65 } 65 - if got != tc.service { 66 - t.Errorf("gitServiceFor(%q) service=%q, want %q", tc.command, got, tc.service) 66 + if got != tt.service { 67 + t.Errorf("gitServiceFor(%q) service=%q, want %q", tt.command, got, tt.service) 67 68 } 68 69 }) 69 70 } ··· 142 143 t.Fatalf("listen: %v", err) 143 144 } 144 145 go srv.Serve(ln) //nolint:errcheck // returns when ln closes 145 - t.Cleanup(func() { srv.Close() }) 146 + t.Cleanup(func() { srv.Close(); ln.Close() }) 146 147 return ln.Addr().String(), fs 147 148 } 148 149 ··· 156 157 if out, err := exec.Command("ssh-keygen", "-t", "ed25519", "-N", "", "-f", key).CombinedOutput(); err != nil { 157 158 t.Fatalf("ssh-keygen: %v\n%s", err, out) 158 159 } 159 - sshCmd := "ssh -i " + key + 160 - " -o IdentitiesOnly=yes" + 161 - " -o StrictHostKeyChecking=no" + 162 - " -o UserKnownHostsFile=/dev/null" 160 + sshCmd := fmt.Sprintf("ssh -i %q -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null", key) 163 161 return append(os.Environ(), 164 162 "GIT_SSH_COMMAND="+sshCmd, 165 163 "GIT_TERMINAL_PROMPT=0", ··· 216 214 remote := "ssh://git@" + addr + "/test.git" 217 215 218 216 // Confirm no repo exists before any push. 219 - _, preStatErr := fs.Stat("test.git/config") 217 + _, preStatErr := fs.Stat("/test.git/config") 220 218 if preStatErr == nil { 221 219 t.Fatal("test.git must not exist before any push") 222 220 } ··· 237 235 } 238 236 239 237 // The bare repo must exist iff a push was expected to land. 240 - _, statErr := fs.Stat("test.git/config") 238 + _, statErr := fs.Stat("/test.git/config") 241 239 pushLanded := tt.doPush && !tt.wantPushErr 242 240 if pushLanded && statErr != nil { 243 241 t.Fatalf("expected repo to be created on push, but config missing: %v", statErr)