({
cwd,
ref,
fullPath = false,
}: {
cwd: string;
ref: string;
fullPath?: boolean;
})
| 185 | } |
| 186 | |
| 187 | export async function getChangedFilesSince({ |
| 188 | cwd, |
| 189 | ref, |
| 190 | fullPath = false, |
| 191 | }: { |
| 192 | cwd: string; |
| 193 | ref: string; |
| 194 | fullPath?: boolean; |
| 195 | }): Promise<Array<string>> { |
| 196 | const divergedAt = await getDivergedCommit(cwd, ref); |
| 197 | // Now we can find which files we added |
| 198 | const cmd = await spawn( |
| 199 | "git", |
| 200 | ["diff", "--name-only", "--no-relative", divergedAt], |
| 201 | { cwd } |
| 202 | ); |
| 203 | if (cmd.code !== 0) { |
| 204 | throw new Error( |
| 205 | `Failed to diff against ${divergedAt}. Is ${divergedAt} a valid ref?` |
| 206 | ); |
| 207 | } |
| 208 | |
| 209 | const files = cmd.stdout |
| 210 | .toString() |
| 211 | .trim() |
| 212 | .split("\n") |
| 213 | .filter((a) => a); |
| 214 | if (!fullPath) return files; |
| 215 | |
| 216 | const repoRoot = await getRepoRoot({ cwd }); |
| 217 | return files.map((file) => path.resolve(repoRoot, file)); |
| 218 | } |
| 219 | |
| 220 | // below are less generic functions that we use in combination with other things we are doing |
| 221 | export async function getChangedChangesetFilesSinceRef({ |
no test coverage detected