(path: string, { repoURL = this.repoURL, branch = this.branch } = {})
| 426 | } |
| 427 | |
| 428 | async getFileSha(path: string, { repoURL = this.repoURL, branch = this.branch } = {}) { |
| 429 | /** |
| 430 | * We need to request the tree first to get the SHA. We use extended SHA-1 |
| 431 | * syntax (<rev>:<path>) to get a blob from a tree without having to recurse |
| 432 | * through the tree. |
| 433 | */ |
| 434 | |
| 435 | const pathArray = path.split('/'); |
| 436 | const filename = last(pathArray); |
| 437 | const directory = initial(pathArray).join('/'); |
| 438 | const fileDataPath = encodeURIComponent(directory); |
| 439 | const fileDataURL = `${repoURL}/git/trees/${branch}:${fileDataPath}`; |
| 440 | |
| 441 | const result: GitGetTreeResponse = await this.request(fileDataURL); |
| 442 | const file = result.tree.find(file => file.path === filename); |
| 443 | if (file) { |
| 444 | return file.sha; |
| 445 | } else { |
| 446 | throw new APIError('Not Found', 404, API_NAME); |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | async deleteFiles(paths: string[], message: string) { |
| 451 | const operations: ChangeFileOperation[] = await Promise.all( |
no test coverage detected