* Use `git log` to get the commit timestamp when each bump file was first added. * Returns a map of bump file ID → unix timestamp (seconds).
(rootDir: string)
| 93 | * Returns a map of bump file ID → unix timestamp (seconds). |
| 94 | */ |
| 95 | function getBumpFileCreationOrder(rootDir: string): Map<string, number> { |
| 96 | const order = new Map<string, number>(); |
| 97 | |
| 98 | // git log with --diff-filter=A shows only commits that added files |
| 99 | // --format="%at" gives unix timestamp, --name-only lists files |
| 100 | const result = tryRunArgs(['git', 'log', '--diff-filter=A', '--format=%at', '--name-only', '--', '.bumpy/*.md'], { |
| 101 | cwd: rootDir, |
| 102 | }); |
| 103 | if (!result) return order; |
| 104 | |
| 105 | // Output format: timestamp line, then filename lines, then blank line, repeat |
| 106 | let currentTimestamp = 0; |
| 107 | for (const line of result.split('\n')) { |
| 108 | const trimmed = line.trim(); |
| 109 | if (!trimmed) continue; |
| 110 | if (/^\d+$/.test(trimmed)) { |
| 111 | currentTimestamp = parseInt(trimmed, 10); |
| 112 | } else if (trimmed.startsWith('.bumpy/') && trimmed.endsWith('.md')) { |
| 113 | // Use the basename as the ID — bump files keep their ID when moved into |
| 114 | // a channel subdir, and the move shows up as a new "A" entry, so taking |
| 115 | // the oldest timestamp below preserves the original creation order. |
| 116 | const id = fileToId(trimmed); |
| 117 | // Only record the first (oldest) commit — git log is newest-first, |
| 118 | // so later entries overwrite with earlier timestamps |
| 119 | order.set(id, currentTimestamp); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | return order; |
| 124 | } |
| 125 | |
| 126 | /** Parse a single bump file from disk */ |
| 127 | export async function parseBumpFileFromPath(filePath: string): Promise<BumpFileParseResult> { |
no test coverage detected
searching dependent graphs…