({
repo,
hostUrl,
branches,
tags,
isAutoCleanupDisabled,
}: {
repo: OctokitRepository,
hostUrl: string,
branches?: string[],
tags?: string[],
isAutoCleanupDisabled?: boolean,
})
| 89 | } |
| 90 | |
| 91 | export const createGitHubRepoRecord = ({ |
| 92 | repo, |
| 93 | hostUrl, |
| 94 | branches, |
| 95 | tags, |
| 96 | isAutoCleanupDisabled, |
| 97 | }: { |
| 98 | repo: OctokitRepository, |
| 99 | hostUrl: string, |
| 100 | branches?: string[], |
| 101 | tags?: string[], |
| 102 | isAutoCleanupDisabled?: boolean, |
| 103 | }) => { |
| 104 | const repoNameRoot = new URL(hostUrl) |
| 105 | .toString() |
| 106 | .replace(/^https?:\/\//, ''); |
| 107 | |
| 108 | const repoDisplayName = repo.full_name; |
| 109 | const repoName = path.join(repoNameRoot, repoDisplayName); |
| 110 | const cloneUrl = new URL(repo.clone_url!); |
| 111 | const isPublic = repo.private === false; |
| 112 | |
| 113 | logger.debug(`Found github repo ${repoDisplayName} with webUrl: ${repo.html_url}`); |
| 114 | |
| 115 | const record: Prisma.RepoCreateInput = { |
| 116 | external_id: repo.id.toString(), |
| 117 | external_codeHostType: 'github', |
| 118 | external_codeHostUrl: hostUrl, |
| 119 | cloneUrl: cloneUrl.toString(), |
| 120 | webUrl: repo.html_url, |
| 121 | name: repoName, |
| 122 | defaultBranch: repo.default_branch, |
| 123 | displayName: repoDisplayName, |
| 124 | imageUrl: repo.owner.avatar_url, |
| 125 | isFork: repo.fork, |
| 126 | isArchived: !!repo.archived, |
| 127 | isPublic: isPublic, |
| 128 | isAutoCleanupDisabled, |
| 129 | org: { |
| 130 | connect: { |
| 131 | id: SINGLE_TENANT_ORG_ID, |
| 132 | }, |
| 133 | }, |
| 134 | metadata: { |
| 135 | gitConfig: { |
| 136 | 'zoekt.web-url-type': 'github', |
| 137 | 'zoekt.web-url': repo.html_url, |
| 138 | 'zoekt.name': repoName, |
| 139 | 'zoekt.github-stars': (repo.stargazers_count ?? 0).toString(), |
| 140 | 'zoekt.github-watchers': (repo.watchers_count ?? 0).toString(), |
| 141 | 'zoekt.github-subscribers': (repo.subscribers_count ?? 0).toString(), |
| 142 | 'zoekt.github-forks': (repo.forks_count ?? 0).toString(), |
| 143 | 'zoekt.archived': marshalBool(repo.archived), |
| 144 | 'zoekt.fork': marshalBool(repo.fork), |
| 145 | 'zoekt.public': marshalBool(isPublic), |
| 146 | 'zoekt.display-name': repoDisplayName, |
| 147 | }, |
| 148 | branches, |
no test coverage detected