( localPath: string, message: string, files: string[], )
| 184 | * Does NOT push — the user pushes their business repo on their own cadence. |
| 185 | */ |
| 186 | export async function commitPaths( |
| 187 | localPath: string, |
| 188 | message: string, |
| 189 | files: string[], |
| 190 | ): Promise<boolean> { |
| 191 | const git = createGit(localPath); |
| 192 | const existing = files.filter((f) => fs.existsSync(path.join(localPath, f))); |
| 193 | if (existing.length === 0) return false; |
| 194 | // Add each path individually and tolerate `git add` failing on an |
| 195 | // explicitly-gitignored path (it errors "Use -f if you really want to add |
| 196 | // them"). Callers should not pass ignored paths, but a stray one must not |
| 197 | // abort the whole commit. `--` guards against paths that look like options. |
| 198 | let added = 0; |
| 199 | for (const f of existing) { |
| 200 | try { |
| 201 | await git.add(['--', f]); |
| 202 | added++; |
| 203 | } catch { |
| 204 | // ignored/unaddable path — skip it |
| 205 | } |
| 206 | } |
| 207 | if (added === 0) return false; |
| 208 | const status = await git.status(); |
| 209 | if (status.staged.length === 0) return false; |
| 210 | await git.commit(message); |
| 211 | return true; |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Pull the latest changes from origin into a local team-repo clone. |
no test coverage detected