(files: { path: string; newPath?: string }[], branch: string)
| 392 | } |
| 393 | |
| 394 | async getChangeFileOperations(files: { path: string; newPath?: string }[], branch: string) { |
| 395 | const items: ChangeFileOperation[] = await Promise.all( |
| 396 | files.map(async file => { |
| 397 | const content = await result( |
| 398 | file, |
| 399 | 'toBase64', |
| 400 | partial(this.toBase64, (file as DataFile).raw), |
| 401 | ); |
| 402 | let sha; |
| 403 | let operation; |
| 404 | let from_path; |
| 405 | let path = trimStart(file.path, '/'); |
| 406 | try { |
| 407 | sha = await this.getFileSha(file.path, { branch }); |
| 408 | operation = FileOperation.UPDATE; |
| 409 | from_path = file.newPath && path; |
| 410 | path = file.newPath ? trimStart(file.newPath, '/') : path; |
| 411 | } catch { |
| 412 | sha = undefined; |
| 413 | operation = FileOperation.CREATE; |
| 414 | } |
| 415 | |
| 416 | return { |
| 417 | operation, |
| 418 | content, |
| 419 | path, |
| 420 | from_path, |
| 421 | sha, |
| 422 | } as ChangeFileOperation; |
| 423 | }), |
| 424 | ); |
| 425 | return items; |
| 426 | } |
| 427 | |
| 428 | async getFileSha(path: string, { repoURL = this.repoURL, branch = this.branch } = {}) { |
| 429 | /** |
no test coverage detected