Skip to content

Commit b8ca959

Browse files
committed
Fix gitfs tests
1 parent 0af44fa commit b8ca959

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

internal/forks/rsc.io/gitfs/fs.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
hashpkg "hash"
1313
"io"
1414
"io/fs"
15-
"log"
1615
"runtime/debug"
1716
"strings"
1817
"time"
@@ -249,14 +248,14 @@ func (t *treeFS) Open(name string) (f fs.File, err error) {
249248
}
250249
}()
251250

252-
prefix := t.s.repo.root + "@" + t.commit.String()
253-
log.Printf("name=%q, prefix=%q", name, prefix)
254-
name = strings.TrimPrefix(name, prefix)
255-
name = strings.TrimPrefix(name, "/")
256-
if name == "" {
257-
name = "."
251+
if t.s.repo != nil {
252+
prefix := t.s.repo.root + "@" + t.commit.String()
253+
name = strings.TrimPrefix(name, prefix)
254+
name = strings.TrimPrefix(name, "/")
255+
if name == "" {
256+
name = "."
257+
}
258258
}
259-
log.Printf("cleaned=%q", name)
260259

261260
// Process each element in the slash-separated path, producing hash identified by name.
262261
h := t.tree

internal/forks/rsc.io/gitfs/git_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestGerrit(t *testing.T) {
1919
if err != nil {
2020
t.Fatal(err)
2121
}
22-
_, fsys, err := r.Clone("HEAD")
22+
_, fsys, err := r.Clone(context.Background(), "HEAD")
2323
if err != nil {
2424
t.Fatal(err)
2525
}
@@ -38,7 +38,7 @@ func TestGitHub(t *testing.T) {
3838
if err != nil {
3939
t.Fatal(err)
4040
}
41-
_, fsys, err := r.Clone("HEAD")
41+
_, fsys, err := r.Clone(context.Background(), "HEAD")
4242
if err != nil {
4343
t.Fatal(err)
4444
}
@@ -61,7 +61,7 @@ func TestPack(t *testing.T) {
6161
}
6262

6363
h := Hash{0xf6, 0xf7, 0x39, 0x2a, 0x99, 0x9b, 0x3d, 0x75, 0xe2, 0x1c, 0xae, 0xe3, 0x3a, 0xeb, 0x6d, 0x01, 0x92, 0xe8, 0xdc, 0x6b}
64-
tfs, err := s.Commit(h)
64+
tfs, _, err := s.Commit(h)
6565
if err != nil {
6666
t.Fatal(err)
6767
}

0 commit comments

Comments
 (0)