( commitSha: string, commitsCount: number, )
| 47 | } |
| 48 | |
| 49 | async function getRepoAge( |
| 50 | commitSha: string, |
| 51 | commitsCount: number, |
| 52 | ): Promise<[committedDate: string, lastCommitsPageUrl: string]> { |
| 53 | const {repository} = await api.v4(GetRepoAge, { |
| 54 | variables: { |
| 55 | cursor: `${commitSha} ${commitsCount - Math.min(6, commitsCount)}`, |
| 56 | }, |
| 57 | }); |
| 58 | |
| 59 | const {committedDate} = repository.defaultBranchRef.target.history.nodes |
| 60 | // Filter out any invalid commit dates #3185 |
| 61 | .findLast((commit: CommitTarget) => new Date(commit.committedDate).getFullYear() > 1970); |
| 62 | |
| 63 | const lastCommitsPageUrl = buildLastCommitsPageUrl(commitSha, commitsCount); |
| 64 | return [committedDate, lastCommitsPageUrl]; |
| 65 | } |
| 66 | |
| 67 | const firstCommit = new CachedFunction('first-commit', { |
| 68 | async updater(): Promise<[committedDate: string, lastCommitsPageUrl: string]> { |
no test coverage detected