(paths: string[])
| 109 | * it up on the next cycle. |
| 110 | */ |
| 111 | export function pathListSignature(paths: string[]): string { |
| 112 | const n = paths.length |
| 113 | const stride = Math.max(1, Math.floor(n / 500)) |
| 114 | let h = 0x811c9dc5 | 0 |
| 115 | for (let i = 0; i < n; i += stride) { |
| 116 | const p = paths[i]! |
| 117 | for (let j = 0; j < p.length; j++) { |
| 118 | h = ((h ^ p.charCodeAt(j)) * 0x01000193) | 0 |
| 119 | } |
| 120 | h = (h * 0x01000193) | 0 |
| 121 | } |
| 122 | // Stride starts at 0 (first path always hashed); explicitly include last |
| 123 | // so single-file add/rm at the tail is caught |
| 124 | if (n > 0) { |
| 125 | const last = paths[n - 1]! |
| 126 | for (let j = 0; j < last.length; j++) { |
| 127 | h = ((h ^ last.charCodeAt(j)) * 0x01000193) | 0 |
| 128 | } |
| 129 | } |
| 130 | return `${n}:${(h >>> 0).toString(16)}` |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Stat .git/index to detect git state changes without spawning git ls-files. |
no test coverage detected