| 664 | |
| 665 | async readFileMetadata(path: string, sha: string | null | undefined) { |
| 666 | const fetchFileMetadata = async () => { |
| 667 | try { |
| 668 | const result: Endpoints['GET /repos/{owner}/{repo}/commits']['response']['data'] = |
| 669 | await this.request(`${this.originRepoURL}/commits`, { |
| 670 | params: { path, sha: this.branch }, |
| 671 | }); |
| 672 | const { commit } = result[0]; |
| 673 | return { |
| 674 | author: commit.author?.name || commit.author?.email || '', |
| 675 | updatedOn: commit.author?.date || '', |
| 676 | }; |
| 677 | } catch (e) { |
| 678 | return { author: '', updatedOn: '' }; |
| 679 | } |
| 680 | }; |
| 681 | const fileMetadata = await readFileMetadata(sha, fetchFileMetadata, localForage); |
| 682 | return fileMetadata; |
| 683 | } |