fetch refuses a manifest whose paths differ only in letter case (closes #154)
check / check (push) Failing after 2s
check / check (push) Failing after 2s
On a case-insensitive filesystem such paths are one name. Of two files, one replaced the other and fetch exited 0. For a file and a directory another file is in, fetch stopped partway with a non-zero exit, leaving a partial tree. For two spellings of one directory, both files landed in one directory, one under a spelling the manifest does not list, and check reported that file as not in the manifest. The existing name-clash check now also records each listed file and each directory one is in. A listed file at a name already taken, or a directory spelled differently from one already there, is refused on every filesystem, before the destination is created. The message names both paths. Model: opus-5-5
This commit was merged in pull request #157.
This commit is contained in:
@@ -1236,6 +1236,69 @@ func TestFetchRefusesListedTempName(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestFetchRefusesNamesEqualIgnoringCase fetches manifests that list two
|
||||
// paths that are one name on a case-insensitive filesystem. Fetched
|
||||
// there, of two such files, at the top of the tree or in a directory,
|
||||
// one replaces the other and fetch exits 0. A file and a directory
|
||||
// another file is in stop fetch partway with a non-zero exit, leaving a
|
||||
// partial tree. Two spellings of one directory put both files in one
|
||||
// directory, one of them under a spelling the manifest does not list,
|
||||
// and check reports that file as not in the manifest. So fetch must
|
||||
// refuse each on every filesystem before it creates the destination or
|
||||
// requests any file. A file and a directory with the same name, and a
|
||||
// file listed twice, are refused the same way. A manifest whose names
|
||||
// differ in more than letter case is fetched in full.
|
||||
func TestFetchRefusesNamesEqualIgnoringCase(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, tc := range []struct{ first, second, message string }{
|
||||
{"X.txt", "x.txt", "x.txt (the file X.txt)"},
|
||||
{"sub/X.txt", "sub/x.txt", "sub/x.txt (the file sub/X.txt)"},
|
||||
{"Dir", "dir/x", "dir/x (the file Dir)"},
|
||||
{"Dir/a.txt", "dir/b.txt", "dir/b.txt (the directory Dir)"},
|
||||
{"dir", "dir/x", "dir/x (the file dir)"},
|
||||
{"./x.txt", "x.txt", "x.txt (the file ./x.txt)"},
|
||||
} {
|
||||
t.Run(tc.first+" and "+tc.second, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := map[string][]byte{
|
||||
tc.first: []byte("the first file"),
|
||||
tc.second: []byte("the second file"),
|
||||
}
|
||||
|
||||
assertFetchRefused(t, builtManifest(t, files), files,
|
||||
"manifest lists a file where fetch writes another file: "+tc.message)
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("names that differ in more than letter case", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := map[string][]byte{
|
||||
"A.txt": []byte("at the top"),
|
||||
"B.txt": []byte("also at the top"),
|
||||
"dir/a.txt": []byte("in a directory"),
|
||||
"dir/b.txt": []byte("in the same directory"),
|
||||
}
|
||||
manifest := builtManifest(t, files)
|
||||
|
||||
server := httptest.NewServer(fetchTestHandler(manifest, files))
|
||||
defer server.Close()
|
||||
|
||||
dest := t.TempDir()
|
||||
|
||||
opts := testOpts([]string{
|
||||
testApp, cmdFetch, "-q", "--" + flagDest, dest, server.URL,
|
||||
}, afero.NewOsFs())
|
||||
require.Equal(t, 0, runCLI(opts), testStderr(t, opts))
|
||||
|
||||
want := maps.Clone(files)
|
||||
want[defaultManifestName] = manifest
|
||||
assert.Equal(t, want, filesUnder(t, dest))
|
||||
})
|
||||
}
|
||||
|
||||
// builtManifest returns a manifest of files, built directly rather than
|
||||
// scanned, since a scan lists no hidden files and never a path starting
|
||||
// with "./".
|
||||
|
||||
Reference in New Issue
Block a user