File tree Expand file tree Collapse file tree 3 files changed +47
-1
lines changed
Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @cloudflare/shell " : patch
3+ ---
4+
5+ Fix ` git.clone() ` without ` depth ` failing with ` ENOENT: .git/shallow ` . The git fs adapter's ` unlink ` now wraps errors with ` .code ` so isomorphic-git can handle missing files gracefully.
Original file line number Diff line number Diff line change @@ -119,7 +119,11 @@ export function createGitFs(fs: FileSystem) {
119119 } ,
120120
121121 async unlink ( path : string ) : Promise < void > {
122- await fs . rm ( path ) ;
122+ try {
123+ await fs . rm ( path ) ;
124+ } catch ( err ) {
125+ throw fsError ( path , err ) ;
126+ }
123127 } ,
124128
125129 async readdir ( path : string ) : Promise < string [ ] > {
Original file line number Diff line number Diff line change 1+ /**
2+ * Unit tests for the git fs adapter (createGitFs).
3+ *
4+ * Uses InMemoryFs so these run without a Durable Object or network access.
5+ */
6+
7+ import { describe , expect , it } from "vitest" ;
8+ import { InMemoryFs } from "../fs/in-memory-fs" ;
9+ import { createGitFs } from "../git/fs-adapter" ;
10+
11+ function setup ( ) {
12+ const fs = new InMemoryFs ( ) ;
13+ const gitFs = createGitFs ( fs ) . promises ;
14+ return { fs, gitFs } ;
15+ }
16+
17+ describe ( "createGitFs" , ( ) => {
18+ describe ( "unlink" , ( ) => {
19+ it ( "deletes an existing file" , async ( ) => {
20+ const { fs, gitFs } = setup ( ) ;
21+ await fs . writeFile ( "/file.txt" , "content" ) ;
22+ await gitFs . unlink ( "/file.txt" ) ;
23+ await expect ( fs . exists ( "/file.txt" ) ) . resolves . toBe ( false ) ;
24+ } ) ;
25+
26+ it ( "throws with code ENOENT for missing files" , async ( ) => {
27+ const { gitFs } = setup ( ) ;
28+ try {
29+ await gitFs . unlink ( "/nonexistent.txt" ) ;
30+ expect . unreachable ( "should have thrown" ) ;
31+ } catch ( err : unknown ) {
32+ expect ( err ) . toBeInstanceOf ( Error ) ;
33+ expect ( ( err as Error & { code : string } ) . code ) . toBe ( "ENOENT" ) ;
34+ }
35+ } ) ;
36+ } ) ;
37+ } ) ;
You can’t perform that action at this time.
0 commit comments