From 168ee43f71f005baa11edf98e518593443e1807a Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Tue, 25 Jan 2022 17:13:33 -0800 Subject: [PATCH] [tools] Update default branch to main --- tools/src/Git.ts | 2 +- .../src/check-packages/getPackagesToCheckAsync.ts | 2 +- .../reviewers/checkMissingChangelogs.ts | 2 +- tools/src/commands/AddChangelog.ts | 2 +- tools/src/commands/CheckPackages.ts | 4 ++-- tools/src/commands/GenerateSDKDocs.ts | 4 ++-- tools/src/commands/PublishPackages.ts | 2 +- .../tasks/checkRepositoryStatus.ts | 14 +++++++------- .../publish-packages/tasks/commentOnIssuesTask.ts | 6 +++--- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tools/src/Git.ts b/tools/src/Git.ts index 193a5f047eb703..0cf70ad30722e8 100644 --- a/tools/src/Git.ts +++ b/tools/src/Git.ts @@ -416,7 +416,7 @@ export class GitDirectory { static async shallowCloneAsync( directory: string, remoteUrl: string, - ref: string = 'master' + ref: string = 'main' ): Promise { const git = new GitDirectory(directory); diff --git a/tools/src/check-packages/getPackagesToCheckAsync.ts b/tools/src/check-packages/getPackagesToCheckAsync.ts index 45844cc575229d..c7659a996150ba 100644 --- a/tools/src/check-packages/getPackagesToCheckAsync.ts +++ b/tools/src/check-packages/getPackagesToCheckAsync.ts @@ -37,7 +37,7 @@ export default async function getPackagesToCheckAsync(options: ActionOptions) { }); } - const sinceRef = options.since ?? 'master'; + const sinceRef = options.since ?? 'main'; const mergeBase = await safeGetMergeBaseAsync(sinceRef); if (!mergeBase) { diff --git a/tools/src/code-review/reviewers/checkMissingChangelogs.ts b/tools/src/code-review/reviewers/checkMissingChangelogs.ts index e508fbb6164549..3bf2ccc960eff8 100644 --- a/tools/src/code-review/reviewers/checkMissingChangelogs.ts +++ b/tools/src/code-review/reviewers/checkMissingChangelogs.ts @@ -28,7 +28,7 @@ export default async function ({ pullRequest, diff }: ReviewInput): Promise { ) .option( '--no-pull-request', - 'If changes were pushed directly to the master.', + 'If changes were pushed directly to the main.', (value, previous) => { // we need to change how no-flag works in commander to be able to pass an array if (!value) { diff --git a/tools/src/commands/CheckPackages.ts b/tools/src/commands/CheckPackages.ts index 7f1cc902101f39..b22bbfbcc14546 100644 --- a/tools/src/commands/CheckPackages.ts +++ b/tools/src/commands/CheckPackages.ts @@ -14,8 +14,8 @@ export default (program: Command) => { .alias('check', 'cp') .option( '-s, --since ', - 'Reference to the commit since which you want to run incremental checks. Defaults to HEAD of the master branch.', - 'master' + 'Reference to the commit since which you want to run incremental checks. Defaults to HEAD of the main branch.', + 'main' ) .option('-a, --all', 'Whether to check all packages and ignore `--since` option.', false) .option('--no-build', 'Whether to skip `yarn build` check.', false) diff --git a/tools/src/commands/GenerateSDKDocs.ts b/tools/src/commands/GenerateSDKDocs.ts index b95a6e4c998510..a8a0b0de7a9a1e 100644 --- a/tools/src/commands/GenerateSDKDocs.ts +++ b/tools/src/commands/GenerateSDKDocs.ts @@ -36,7 +36,7 @@ async function action(options) { console.log(`Updating ${chalk.cyan('react-native-website')} submodule...`); - await spawnAsync('git', ['checkout', 'master'], { + await spawnAsync('git', ['checkout', 'main'], { cwd: reactNativeWebsiteDir, }); @@ -80,7 +80,7 @@ async function action(options) { const apiFilePath = path.join(targetSdkDirectory, 'sdk', api); await transformFileAsync(apiFilePath, [ { - find: /(sourceCodeUrl:.*?\/tree\/)(master)(\/packages[^\n]*)/, + find: /(sourceCodeUrl:.*?\/tree\/)(main)(\/packages[^\n]*)/, replaceWith: `$1sdk-${sdk.substring(0, 2)}$3`, }, ]); diff --git a/tools/src/commands/PublishPackages.ts b/tools/src/commands/PublishPackages.ts index a74a261a36cfc4..ebc624c0efda30 100644 --- a/tools/src/commands/PublishPackages.ts +++ b/tools/src/commands/PublishPackages.ts @@ -67,7 +67,7 @@ export default (program: Command) => { /* debug options */ .option( '-S, --skip-repo-checks', - 'Skips checking whether the command is run on master branch and there are no unstaged changes.', + 'Skips checking whether the command is run on main branch and there are no unstaged changes.', false ) .option( diff --git a/tools/src/publish-packages/tasks/checkRepositoryStatus.ts b/tools/src/publish-packages/tasks/checkRepositoryStatus.ts index 7feb8bcf8068f6..7e0836d2d35afb 100644 --- a/tools/src/publish-packages/tasks/checkRepositoryStatus.ts +++ b/tools/src/publish-packages/tasks/checkRepositoryStatus.ts @@ -53,24 +53,24 @@ export const checkRepositoryStatus = new Task( ); /** - * Checks whether the command is run on master branch or package side-branch. + * Checks whether the command is run on main branch or package side-branch. * Otherwise, it prompts to confirm that you know what you're doing. - * On CI it returns `true` only if run on `master` branch. + * On CI it returns `true` only if run on `main` branch. */ async function checkBranchNameAsync(branchName: string) { if (process.env.CI) { - // CI is allowed to publish only from master. - return branchName === 'master'; + // CI is allowed to publish only from main. + return branchName === 'main'; } - // Publishes can be run on `master` or package's side-branches like `expo-package/1.x.x` - if (branchName === 'master' || /^[\w\-@]+\/\d+\.(x\.x|\d+\.x)$/.test(branchName)) { + // Publishes can be run on `main` or package's side-branches like `expo-package/1.x.x` + if (branchName === 'main' || /^[\w\-@]+\/\d+\.(x\.x|\d+\.x)$/.test(branchName)) { return true; } logger.warn( '⚠️ ', - `It's recommended to publish from ${blue('master')} branch, while you're at ${blue(branchName)}` + `It's recommended to publish from ${blue('main')} branch, while you're at ${blue(branchName)}` ); const { confirmed } = await inquirer.prompt<{ confirmed: boolean }>([ diff --git a/tools/src/publish-packages/tasks/commentOnIssuesTask.ts b/tools/src/publish-packages/tasks/commentOnIssuesTask.ts index 47b748c952d404..122d0145c874fb 100644 --- a/tools/src/publish-packages/tasks/commentOnIssuesTask.ts +++ b/tools/src/publish-packages/tasks/commentOnIssuesTask.ts @@ -55,8 +55,8 @@ export const commentOnIssuesTask = new Task( const currentBranchName = await Git.getCurrentBranchNameAsync(); // Sometimes we publish from different branches (especially for testing) where comments are not advisable. - if (currentBranchName !== 'master') { - logger.warn('This feature is disabled on branches other than master'); + if (currentBranchName !== 'main') { + logger.warn('This feature is disabled on branches other than main'); logManualFallback(payload); return; } @@ -195,5 +195,5 @@ function linkToNpmPackage(packageName: string, version: string): string { */ function linkToChangelog(pkg: Package): string { const changelogRelativePath = path.relative(EXPO_DIR, pkg.changelogPath); - return `[CHANGELOG.md](https://github.com/expo/expo/blob/master/${changelogRelativePath})`; + return `[CHANGELOG.md](https://github.com/expo/expo/blob/main/${changelogRelativePath})`; }