(opts: PullWithDeps)
| 296 | } |
| 297 | |
| 298 | export async function pullWith(opts: PullWithDeps): Promise<void> { |
| 299 | const dir = opts.dir ?? "/"; |
| 300 | // pull may need to write a merge commit. If we don't have an |
| 301 | // identity from anywhere, fail fast with the same error commit |
| 302 | // raises so the failure mode is consistent. |
| 303 | const author = resolveIdent( |
| 304 | opts.author, |
| 305 | opts.env?.GIT_AUTHOR_NAME, |
| 306 | opts.env?.GIT_AUTHOR_EMAIL, |
| 307 | opts.defaultIdentity, |
| 308 | ); |
| 309 | const committer = |
| 310 | resolveIdent( |
| 311 | opts.committer, |
| 312 | opts.env?.GIT_COMMITTER_NAME ?? opts.env?.GIT_AUTHOR_NAME, |
| 313 | opts.env?.GIT_COMMITTER_EMAIL ?? opts.env?.GIT_AUTHOR_EMAIL, |
| 314 | opts.defaultIdentity, |
| 315 | ) ?? author; |
| 316 | try { |
| 317 | await opts.git.pull({ |
| 318 | fs: opts.fs, |
| 319 | http: opts.http, |
| 320 | dir, |
| 321 | url: opts.url, |
| 322 | remote: opts.remote, |
| 323 | ref: opts.ref, |
| 324 | remoteRef: opts.remoteRef, |
| 325 | fastForward: opts.fastForward, |
| 326 | fastForwardOnly: opts.fastForwardOnly, |
| 327 | singleBranch: opts.singleBranch, |
| 328 | headers: opts.headers, |
| 329 | onAuth: opts.onAuth, |
| 330 | onProgress: opts.onProgress, |
| 331 | onMessage: opts.onMessage, |
| 332 | author, |
| 333 | committer, |
| 334 | cache: opts.cache, |
| 335 | }); |
| 336 | } catch (cause) { |
| 337 | if (isNotARepositoryCause(cause)) throw new NotARepositoryError(dir, { cause }); |
| 338 | // isomorphic-git's MissingNameError fires when pull tries to |
| 339 | // write a merge commit without an identity. Map it to the |
| 340 | // typed surface so callers see one error class for the case. |
| 341 | if ( |
| 342 | cause instanceof Error && |
| 343 | /Missing(Name|Email)Error|identity|cannot author/i.test(cause.message) |
| 344 | ) { |
| 345 | throw new MissingIdentityError({ cause }); |
| 346 | } |
| 347 | throw new GitError("EPULLFAIL", `git pull failed: ${errorMessage(cause)}`, { cause }); |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | // --------------------------------------------------------------- |
| 352 | // merge |
no test coverage detected