Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func Fetch(ctx context.Context, cacheRoot, name, repo, commit, version, path, ds

if !ok {
return time.Time{}, clierr.New(clierr.CodeConfig,
fmt.Sprintf("path %q of dependency %q not found at commit %.12s", path, name, commit),
"an empty or missing path is almost always a mistyped `path` — check the manifest",
fmt.Sprintf("subdir %q of dependency %q not found at commit %.12s", path, name, commit),
"an empty or missing subdir is almost always a typo — check the manifest",
)
}
}
Expand All @@ -74,8 +74,8 @@ func Fetch(ctx context.Context, cacheRoot, name, repo, commit, version, path, ds

if info, err := os.Stat(treeRoot); err != nil || !info.IsDir() {
return time.Time{}, clierr.New(clierr.CodeConfig,
fmt.Sprintf("path %q of dependency %q not found at commit %.12s", path, name, commit),
"an empty or missing path is almost always a mistyped `path` — check the manifest",
fmt.Sprintf("subdir %q of dependency %q is not a directory at commit %.12s", path, name, commit),
"a subdir must point at a directory in the dependency repo — check the manifest",
)
}
}
Expand Down
15 changes: 15 additions & 0 deletions internal/fetcher/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,21 @@ func TestFetch_missingPath(t *testing.T) {
}
}

func TestFetch_pathIsFile(t *testing.T) {
t.Parallel()

r := gittest.New(t)
r.WriteFile("a.txt", "x\n")
sha := r.Commit("first")

// ls-tree reports the blob, so the pre-checkout existence check passes and
// the "not a directory" branch after checkout must catch it.
_, err := fetcher.Fetch(t.Context(), cacheRoot(t), depName, r.URL(), sha, "", "a.txt", fetchDst(t))
if got := clierr.ExitCode(err); got != int(clierr.CodeConfig) {
t.Fatalf("exit code = %d, want %d (error: %v)", got, clierr.CodeConfig, err)
}
}

func TestFetch_commitGone(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion internal/hasher/hasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func HashTree(root string) (string, error) {
if len(digests) == 0 {
return "", clierr.New(clierr.CodeConfig,
"the dependency tree contains no files",
"an empty dependency is almost always a mistyped `path` — check the manifest",
"an empty dependency is almost always a mistyped `subdir` — check the manifest",
)
}

Expand Down
Loading