| 689 | |
| 690 | async readFileMetadata(path: string, sha: string | null | undefined) { |
| 691 | const fetchFileMetadata = async () => { |
| 692 | try { |
| 693 | const result: Endpoints['GET /repos/{owner}/{repo}/commits']['response']['data'] = |
| 694 | await this.request(`${this.originRepoURL}/commits`, { |
| 695 | params: { path, sha: this.branch }, |
| 696 | }); |
| 697 | const { commit } = result[0]; |
| 698 | return { |
| 699 | author: commit.author?.name || commit.author?.email || '', |
| 700 | updatedOn: commit.author?.date || '', |
| 701 | }; |
| 702 | } catch (e) { |
| 703 | return { author: '', updatedOn: '' }; |
| 704 | } |
| 705 | }; |
| 706 | const fileMetadata = await readFileMetadata(sha, fetchFileMetadata, localForage); |
| 707 | return fileMetadata; |
| 708 | } |