From b27377acb1217188da27c67b7ae8630d38e18662 Mon Sep 17 00:00:00 2001 From: sutterj Date: Mon, 8 Jul 2024 14:11:00 -0400 Subject: [PATCH] feat: rename icf to pma in code --- .github/workflows/docker-build.yml | 2 +- package-lock.json | 4 ++-- package.json | 4 ++-- src/app/components/header/MainHeader.tsx | 2 +- src/app/components/header/WelcomeHeader.tsx | 2 +- src/app/components/login/Login.tsx | 2 +- src/bot/config.ts | 15 ++++++--------- src/bot/rules.ts | 4 ++-- src/server/git/controller.ts | 4 ++-- src/server/repos/controller.ts | 4 ++-- test/app.test.ts | 4 ++-- test/config.test.ts | 2 +- 12 files changed, 23 insertions(+), 26 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index cd207b9..45b21d4 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -14,4 +14,4 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin@v4 - name: Build Docker image - run: docker build -t internal-contribution-forks . + run: docker build -t private-mirrors . diff --git a/package-lock.json b/package-lock.json index ad67c85..adada2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "internal-contribution-forks", + "name": "private-mirrors", "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "internal-contribution-forks", + "name": "private-mirrors", "version": "0.1.0", "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index de19a30..e83992e 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { - "name": "internal-contribution-forks", + "name": "private-mirrors", "version": "0.1.0", "private": true, "description": "A GitHub App that allows you to contribute upstream using a 'private fork'", "author": "Andrew Henry ", "license": "MIT", - "homepage": "https://github.com/github-community-projects/internal-contribution-forks", + "homepage": "https://github.com/github-community-projects/private-mirrors", "scripts": { "dev": "concurrently -c \"auto\" -n webhooks,app \"dotenv-load node scripts/webhook-relay.mjs\" \"next dev\"", "webhook": "dotenv-load node scripts/webhook-relay.mjs", diff --git a/src/app/components/header/MainHeader.tsx b/src/app/components/header/MainHeader.tsx index c328349..027622a 100644 --- a/src/app/components/header/MainHeader.tsx +++ b/src/app/components/header/MainHeader.tsx @@ -22,7 +22,7 @@ export const MainHeader = () => { - Internal Contribution Forks + Private Mirrors {session && session.data?.user && ( diff --git a/src/app/components/header/WelcomeHeader.tsx b/src/app/components/header/WelcomeHeader.tsx index c799ea3..45eeeda 100644 --- a/src/app/components/header/WelcomeHeader.tsx +++ b/src/app/components/header/WelcomeHeader.tsx @@ -11,7 +11,7 @@ export const WelcomeHeader = () => { - Welcome to Internal Contribution Forks! + Welcome to Private Mirrors App! diff --git a/src/app/components/login/Login.tsx b/src/app/components/login/Login.tsx index 9c76148..f514131 100644 --- a/src/app/components/login/Login.tsx +++ b/src/app/components/login/Login.tsx @@ -41,7 +41,7 @@ export const Login = () => { - Internal Contribution Forks + Private Mirrors diff --git a/src/bot/config.ts b/src/bot/config.ts index d5b815f..5389824 100644 --- a/src/bot/config.ts +++ b/src/bot/config.ts @@ -5,15 +5,12 @@ import { appOctokit, installationOctokit } from './octokit' const configLogger = logger.getSubLogger({ name: 'config' }) -const internalContributionForksConfig = z.object({ +const pmaConfig = z.object({ publicOrg: z.string(), privateOrg: z.string(), }) -type InternalContributionForksConfig = z.infer< - typeof internalContributionForksConfig -> & - Configuration +type pmaConfig = z.infer & Configuration export const getGitHubConfig = async (orgId: string) => { const installationId = await appOctokit().rest.apps.getOrgInstallation({ @@ -44,7 +41,7 @@ export const getEnvConfig = () => { const config = { publicOrg: process.env.PUBLIC_ORG, privateOrg: process.env.PUBLIC_ORG, - } as InternalContributionForksConfig + } as pmaConfig if (process.env.PRIVATE_ORG) { config.privateOrg = process.env.PRIVATE_ORG @@ -52,9 +49,9 @@ export const getEnvConfig = () => { return config } -export const validateConfig = (config: InternalContributionForksConfig) => { +export const validateConfig = (config: pmaConfig) => { try { - internalContributionForksConfig.parse(config) + pmaConfig.parse(config) } catch (error) { configLogger.error('Invalid config found!', { error }) throw new Error( @@ -71,7 +68,7 @@ export const validateConfig = (config: InternalContributionForksConfig) => { * @returns Configuration file */ export const getConfig = async (orgId?: string) => { - let config: InternalContributionForksConfig | null = null + let config: pmaConfig | null = null // First check for environment variables config = getEnvConfig() diff --git a/src/bot/rules.ts b/src/bot/rules.ts index 9e8dd4d..bc6bc12 100644 --- a/src/bot/rules.ts +++ b/src/bot/rules.ts @@ -35,7 +35,7 @@ export const createAllPushProtection = async ( await createBranchProtectionRuleset( context, actorNodeId, - 'all-branch-protections-icf', + 'all-branch-protections-pma', ['~ALL'], ) } catch (error) { @@ -96,7 +96,7 @@ export const createDefaultBranchProtection = async ( await createBranchProtectionRuleset( context, actorNodeId, - 'default-branch-protection-icf', + 'default-branch-protection-pma', ['~DEFAULT_BRANCH'], true, ) diff --git a/src/server/git/controller.ts b/src/server/git/controller.ts index 8bda0e8..a0e9131 100644 --- a/src/server/git/controller.ts +++ b/src/server/git/controller.ts @@ -60,8 +60,8 @@ export const syncReposHandler = async ({ const options: Partial = { config: [ - `user.name=internal-contribution-forks[bot]`, - `user.email=${privateInstallationId}+internal-contribution-forks[bot]@users.noreply.github.com`, + `user.name=pma[bot]`, + `user.email=${privateInstallationId}+pma[bot]@users.noreply.github.com`, // Disable any global git hooks to prevent potential interference when running the app locally 'core.hooksPath=/dev/null', ], diff --git a/src/server/repos/controller.ts b/src/server/repos/controller.ts index c9aba8b..21b828d 100644 --- a/src/server/repos/controller.ts +++ b/src/server/repos/controller.ts @@ -90,9 +90,9 @@ export const createMirrorHandler = async ({ const options: Partial = { config: [ - `user.name=internal-contribution-forks[bot]`, + `user.name=pma[bot]`, // We want to use the private installation ID as the email so that we can push to the private repo - `user.email=${privateInstallationId}+internal-contribution-forks[bot]@users.noreply.github.com`, + `user.email=${privateInstallationId}+pma[bot]@users.noreply.github.com`, // Disable any global git hooks to prevent potential interference when running the app locally 'core.hooksPath=/dev/null', ], diff --git a/test/app.test.ts b/test/app.test.ts index 09ce8d4..092ba3e 100644 --- a/test/app.test.ts +++ b/test/app.test.ts @@ -90,7 +90,7 @@ describe('Webhooks events', () => { query: forkBranchProtectionRulesetGQL, variables: { repositoryId: forkCreatedPayload.repository.node_id, - ruleName: 'all-branch-protections-icf', + ruleName: 'all-branch-protections-pma', }, }) return body @@ -155,7 +155,7 @@ describe('Webhooks events', () => { query: mirrorBranchProtectionRulesetGQL, variables: { repositoryId: mirrorCreatedPayload.repository.node_id, - ruleName: 'default-branch-protection-icf', + ruleName: 'default-branch-protection-pma', }, }) return body diff --git a/test/config.test.ts b/test/config.test.ts index a309415..a67897c 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -8,7 +8,7 @@ jest.mock('../src/bot/octokit', () => ({ installationOctokit: () => om.getOctokitImplementation(), })) -describe('ICF Config', () => { +describe('PMA Config', () => { beforeEach(() => { jest.resetAllMocks() delete process.env.PUBLIC_ORG