({
fs,
cache,
onSign,
gitdir,
ref = 'refs/notes/commits',
oid,
author,
committer,
signingKey,
})
| 30 | */ |
| 31 | |
| 32 | export async function _removeNote({ |
| 33 | fs, |
| 34 | cache, |
| 35 | onSign, |
| 36 | gitdir, |
| 37 | ref = 'refs/notes/commits', |
| 38 | oid, |
| 39 | author, |
| 40 | committer, |
| 41 | signingKey, |
| 42 | }) { |
| 43 | // Get the current note commit |
| 44 | let parent |
| 45 | try { |
| 46 | parent = await GitRefManager.resolve({ gitdir, fs, ref }) |
| 47 | } catch (err) { |
| 48 | if (!(err instanceof NotFoundError)) { |
| 49 | throw err |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | // I'm using the "empty tree" magic number here for brevity |
| 54 | const result = await _readTree({ |
| 55 | fs, |
| 56 | cache, |
| 57 | gitdir, |
| 58 | oid: parent || '4b825dc642cb6eb9a060e54bf8d69288fbee4904', |
| 59 | }) |
| 60 | let tree = result.tree |
| 61 | |
| 62 | // Remove the note blob entry from the tree |
| 63 | tree = tree.filter(entry => entry.path !== oid) |
| 64 | |
| 65 | // Create the new note tree |
| 66 | const treeOid = await _writeTree({ |
| 67 | fs, |
| 68 | gitdir, |
| 69 | tree, |
| 70 | }) |
| 71 | |
| 72 | // Create the new note commit |
| 73 | const commitOid = await _commit({ |
| 74 | fs, |
| 75 | cache, |
| 76 | onSign, |
| 77 | gitdir, |
| 78 | ref, |
| 79 | tree: treeOid, |
| 80 | parent: parent && [parent], |
| 81 | message: `Note removed by 'isomorphic-git removeNote'\n`, |
| 82 | author, |
| 83 | committer, |
| 84 | signingKey, |
| 85 | }) |
| 86 | |
| 87 | return commitOid |
| 88 | } |
no test coverage detected
searching dependent graphs…