MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / recoverDeletedBumpFiles

Function recoverDeletedBumpFiles

packages/bumpy/src/core/bump-file.ts:270–298  ·  view source on GitHub ↗
(rootDir: string)

Source from the content-addressed store, hash-verified

268 * once HEAD diverges, leaving releases with no changelog body.
269 */
270export function recoverDeletedBumpFiles(rootDir: string): BumpFile[] {
271 // The most recent commit that deleted any .bumpy/*.md file — i.e. the version
272 // commit that consumed them.
273 const versionCommit = tryRunArgs(['git', 'log', '--diff-filter=D', '--format=%H', '-n', '1', '--', '.bumpy/*.md'], {
274 cwd: rootDir,
275 })
276 ?.split('\n')
277 .filter(Boolean)[0]
278 ?.trim();
279 if (!versionCommit) return [];
280
281 // Read the deleted files' content from the commit's parent.
282 const parent = `${versionCommit}~1`;
283 const deleted = tryRunArgs(
284 ['git', 'diff', '--diff-filter=D', '--name-only', parent, versionCommit, '--', '.bumpy/*.md'],
285 { cwd: rootDir },
286 );
287 if (!deleted) return [];
288
289 const bumpFiles: BumpFile[] = [];
290 for (const filePath of deleted.split('\n').filter(Boolean)) {
291 if (filePath.endsWith('README.md')) continue;
292 const content = tryRunArgs(['git', 'show', `${parent}:${filePath}`], { cwd: rootDir });
293 if (!content) continue;
294 const { bumpFile } = parseBumpFile(content, fileToId(filePath));
295 if (bumpFile) bumpFiles.push(bumpFile);
296 }
297 return bumpFiles;
298}
299
300/**
301 * Move bump files into a channel's shipped directory (`.bumpy/<channel>/`).

Callers 2

ciReleaseCommandFunction · 0.90

Calls 3

tryRunArgsFunction · 0.90
parseBumpFileFunction · 0.85
fileToIdFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…