({ fs, dir, gitdir, entries })
| 58 | } |
| 59 | |
| 60 | async function processTreeEntries({ fs, dir, gitdir, entries }) { |
| 61 | // make sure each tree entry has valid oid |
| 62 | async function processTreeEntry(entry) { |
| 63 | if (entry.type === 'tree') { |
| 64 | if (!entry.oid) { |
| 65 | // Process children entries if the current entry is a tree |
| 66 | const children = await Promise.all(entry.children.map(processTreeEntry)) |
| 67 | // Write the tree with the processed children |
| 68 | entry.oid = await _writeTree({ |
| 69 | fs, |
| 70 | gitdir, |
| 71 | tree: children, |
| 72 | }) |
| 73 | entry.mode = 0o40000 // directory |
| 74 | } |
| 75 | } else if (entry.type === 'blob') { |
| 76 | entry.oid = await checkAndWriteBlob( |
| 77 | fs, |
| 78 | gitdir, |
| 79 | dir, |
| 80 | entry.path, |
| 81 | entry.oid |
| 82 | ) |
| 83 | entry.mode = 0o100644 // file |
| 84 | } |
| 85 | |
| 86 | // remove path from entry.path |
| 87 | entry.path = entry.path.split('/').pop() |
| 88 | return entry |
| 89 | } |
| 90 | |
| 91 | return Promise.all(entries.map(processTreeEntry)) |
| 92 | } |
| 93 | |
| 94 | export async function writeTreeChanges({ |
| 95 | fs, |
no outgoing calls
no test coverage detected
searching dependent graphs…