Skip to content

Commit

Permalink
Merge pull request #204 from github-community-projects/sutterj/code-r…
Browse files Browse the repository at this point in the history
…ename

feat: rename icf to pma in code
  • Loading branch information
ahpook authored Jul 9, 2024
2 parents d071c5c + 8c930f8 commit 08990e1
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <ajhenry@github.com>",
"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",
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/header/MainHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const MainHeader = () => {
</Header.Item>
<Header.Item full>
<Text sx={{ color: 'fg.default', fontSize: '2', fontWeight: 'bold' }}>
Internal Contribution Forks
Private Mirrors
</Text>
</Header.Item>
{session && session.data?.user && (
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/header/WelcomeHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const WelcomeHeader = () => {
</Stack.Item>
<Stack.Item>
<Text sx={{ color: 'fg.default', fontSize: '3', fontWeight: 'bold' }}>
Welcome to Internal Contribution Forks!
Welcome to Private Mirrors App!
</Text>
</Stack.Item>
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const Login = () => {
</Box>
<Box sx={{ textAlign: 'center' }}>
<Text sx={{ fontSize: '1', color: 'fg.muted' }}>
Internal Contribution Forks
Private Mirrors
</Text>
</Box>
</Box>
Expand Down
15 changes: 6 additions & 9 deletions src/bot/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof pmaConfig> & Configuration

export const getGitHubConfig = async (orgId: string) => {
const installationId = await appOctokit().rest.apps.getOrgInstallation({
Expand Down Expand Up @@ -44,17 +41,17 @@ 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
}
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(
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/bot/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const createAllPushProtection = async (
await createBranchProtectionRuleset(
context,
actorNodeId,
'all-branch-protections-icf',
'all-branch-protections-pma',
['~ALL'],
)
} catch (error) {
Expand Down Expand Up @@ -96,7 +96,7 @@ export const createDefaultBranchProtection = async (
await createBranchProtectionRuleset(
context,
actorNodeId,
'default-branch-protection-icf',
'default-branch-protection-pma',
['~DEFAULT_BRANCH'],
true,
)
Expand Down
4 changes: 2 additions & 2 deletions src/server/git/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export const syncReposHandler = async ({

const options: Partial<SimpleGitOptions> = {
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',
],
Expand Down
4 changes: 2 additions & 2 deletions src/server/repos/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export const createMirrorHandler = async ({

const options: Partial<SimpleGitOptions> = {
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',
],
Expand Down
4 changes: 2 additions & 2 deletions test/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions test/fixtures/mirror.created.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,22 @@
"updated_at": "2023-10-16T19:51:20Z"
},
"sender": {
"login": "icf-sutterj[bot]",
"login": "pma-sutterj[bot]",
"id": 165810367,
"node_id": "BOT_kgDOCeIQvw",
"avatar_url": "https://avatars.githubusercontent.com/u/22358079?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/icf-sutterj%5Bbot%5D",
"html_url": "https://github.com/apps/icf-sutterj",
"followers_url": "https://api.github.com/users/icf-sutterj%5Bbot%5D/followers",
"following_url": "https://api.github.com/users/icf-sutterj%5Bbot%5D/following{/other_user}",
"gists_url": "https://api.github.com/users/icf-sutterj%5Bbot%5D/gists{/gist_id}",
"starred_url": "https://api.github.com/users/icf-sutterj%5Bbot%5D/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/icf-sutterj%5Bbot%5D/subscriptions",
"organizations_url": "https://api.github.com/users/icf-sutterj%5Bbot%5D/orgs",
"repos_url": "https://api.github.com/users/icf-sutterj%5Bbot%5D/repos",
"events_url": "https://api.github.com/users/icf-sutterj%5Bbot%5D/events{/privacy}",
"received_events_url": "https://api.github.com/users/icf-sutterj%5Bbot%5D/received_events",
"url": "https://api.github.com/users/pma-sutterj%5Bbot%5D",
"html_url": "https://github.com/apps/pma-sutterj",
"followers_url": "https://api.github.com/users/pma-sutterj%5Bbot%5D/followers",
"following_url": "https://api.github.com/users/pma-sutterj%5Bbot%5D/following{/other_user}",
"gists_url": "https://api.github.com/users/pma-sutterj%5Bbot%5D/gists{/gist_id}",
"starred_url": "https://api.github.com/users/pma-sutterj%5Bbot%5D/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/pma-sutterj%5Bbot%5D/subscriptions",
"organizations_url": "https://api.github.com/users/pma-sutterj%5Bbot%5D/orgs",
"repos_url": "https://api.github.com/users/pma-sutterj%5Bbot%5D/repos",
"events_url": "https://api.github.com/users/pma-sutterj%5Bbot%5D/events{/privacy}",
"received_events_url": "https://api.github.com/users/pma-sutterj%5Bbot%5D/received_events",
"type": "Bot",
"site_admin": false
},
Expand Down

0 comments on commit 08990e1

Please sign in to comment.