| 41 | }; |
| 42 | |
| 43 | export const getStagedFiles = async (): Promise<string[]> => { |
| 44 | const gitDir = await getGitDir(); |
| 45 | |
| 46 | const { stdout: files } = await execa( |
| 47 | 'git', |
| 48 | ['diff', '--name-only', '--cached', '--relative'], |
| 49 | { cwd: gitDir } |
| 50 | ); |
| 51 | |
| 52 | if (!files) return []; |
| 53 | |
| 54 | const filesList = files.split('\n'); |
| 55 | |
| 56 | const ig = await getOpenCommitIgnore(); |
| 57 | const allowedFiles = filesList.filter((file) => !ig.ignores(file)); |
| 58 | |
| 59 | if (!allowedFiles) return []; |
| 60 | |
| 61 | return allowedFiles.sort(); |
| 62 | }; |
| 63 | |
| 64 | export const getChangedFiles = async (): Promise<string[]> => { |
| 65 | const gitDir = await getGitDir(); |