Skip to content

Commit f4b0fc3

Browse files
committed
feat: Enable mirroring non-forked repos
This is a pretty simplistic change to add the ability to mirror repos which are not actually forks of upstream projects. This is useful for demos and testing but it also can be helpful if the public organization actually *is* the upstream, because the repo contains a project we own, so we're the top of the fork network. Addresses github-community-projects#251
1 parent 7a86863 commit f4b0fc3

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

env.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const env = createEnv({
1919
// Optional environment variables
2020
LOGGING_LEVEL: z.string().optional().default('debug'),
2121
NODE_ENV: z.string().optional().default('development'),
22+
FORKS_ONLY: z.string().optional().default('true'),
2223
PUBLIC_ORG: z.string().optional(),
2324
PRIVATE_ORG: z.string().optional(),
2425
// Custom validation for a comma separated list of strings
@@ -62,6 +63,7 @@ export const env = createEnv({
6263
PRIVATE_KEY: process.env.PRIVATE_KEY,
6364
LOGGING_LEVEL: process.env.LOGGING_LEVEL,
6465
NODE_ENV: process.env.NODE_ENV,
66+
FORKS_ONLY: process.env.FORKS_ONLY,
6567
PUBLIC_ORG: process.env.PUBLIC_ORG,
6668
PRIVATE_ORG: process.env.PRIVATE_ORG,
6769
ALLOWED_HANDLES: process.env.ALLOWED_HANDLES,

src/hooks/useForks.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ import { logger } from '../utils/logger'
88

99
const forksLogger = logger.getSubLogger({ name: 'useForks' })
1010

11+
interface QueryVariables {
12+
login: string
13+
isFork?: boolean
14+
}
15+
1116
const getForksInOrg = async (accessToken: string, login: string) => {
17+
const queryVariables: QueryVariables = { login }
18+
if (process.env.FORKS_ONLY === 'true') {
19+
queryVariables.isFork = true
20+
}
1221
const res = await personalOctokit(accessToken)
13-
.graphql.paginate<ForksObject>(getReposInOrgGQL, {
14-
login,
15-
isFork: true,
16-
})
22+
.graphql.paginate<ForksObject>(getReposInOrgGQL, queryVariables)
1723
.catch((error: Error & { data: ForksObject }) => {
1824
forksLogger.error('Error fetching forks', { error })
1925
return error.data

0 commit comments

Comments
 (0)