(ignoreErrors: 'all' | 'pathspec' | 'none' = 'none')
| 218 | }); |
| 219 | |
| 220 | async function add(ignoreErrors: 'all' | 'pathspec' | 'none' = 'none') { |
| 221 | const input = getInput('add'); |
| 222 | if (!input) return []; |
| 223 | |
| 224 | const parsed = parseInputArray(input); |
| 225 | const res: (string | void)[] = []; |
| 226 | |
| 227 | for (const args of parsed) { |
| 228 | res.push( |
| 229 | // Push the result of every git command (which are executed in order) to the array |
| 230 | // If any of them fails, the whole function will return a Promise rejection |
| 231 | await git |
| 232 | .add(matchGitArgs(args), (err, data) => |
| 233 | log(ignoreErrors === 'all' ? null : err, data), |
| 234 | ) |
| 235 | .catch((e: Error) => { |
| 236 | // if I should ignore every error, return |
| 237 | if (ignoreErrors === 'all') return; |
| 238 | |
| 239 | // if it's a pathspec error... |
| 240 | if ( |
| 241 | e.message.includes('fatal: pathspec') && |
| 242 | e.message.includes('did not match any files') |
| 243 | ) { |
| 244 | if (ignoreErrors === 'pathspec') return; |
| 245 | |
| 246 | const peh = getInput('pathspec_error_handling'), |
| 247 | err = new Error( |
| 248 | `Add command did not match any file: git add ${args}`, |
| 249 | ); |
| 250 | if (peh === 'exitImmediately') throw err; |
| 251 | if (peh === 'exitAtEnd') exitErrors.push(err); |
| 252 | } else throw e; |
| 253 | }), |
| 254 | ); |
| 255 | } |
| 256 | |
| 257 | return res; |
| 258 | } |
| 259 | |
| 260 | async function remove( |
| 261 | ignoreErrors: 'all' | 'pathspec' | 'none' = 'none', |
no test coverage detected