Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update default branch text to "main" #1143

Merged

Conversation

eskwisit
Copy link
Contributor

@eskwisit eskwisit commented Sep 25, 2021

Motivation?

When creating a new workspace, nx init a git repository. Since git default branch name policy has changed from master to main. This lead commands such as nx affected:build to crash after a fresh install. All people new to nx will eventually face this issue.

What's been done?

Replacing master with main where needed.

Breaking changes?

If running nx migrate replaces some of the updated files, then the commands will break for projects having master as their default base. The solution is to use the --base flag on such commands.

@nx-cloud
Copy link

nx-cloud bot commented Sep 25, 2021

☁️ Nx Cloud Report

CI ran the following commands for commit b2d3681. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

Copy link
Member

@AgentEnder AgentEnder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should wait until nrwl/nx#7111 is merged and released. Current default behavior with create-nx-workspace is to have a default branch of master (and I'd argue that most Nx workspaces still use master since the change is somewhat recent)

nx.json Outdated
@@ -6,7 +6,7 @@
".eslintrc.json": "*"
},
"affected": {
"defaultBase": "master"
"defaultBase": "main"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This affects this repo, not projects using nx console. Since this repo still has master for main branch changing this would cause commands ran in this repo to break, without changing the end user experience.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't know that 😓 Thanks for the good look @AgentEnder o7

@AgentEnder
Copy link
Member

This is definitely something we will want to merge when the time is right though! Thanks for the PR 😄

@Cammisuli
Copy link
Member

I appreciate the work in this. It's definitely something on the radar to do :D

Copy link
Member

@AgentEnder AgentEnder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you revert the changes in package-scripts.js, and nx.json, this PR should be good to merge. The master -> main change in the main nx repo is complete and should handle most concerns.

Comment on lines 6 to 7
'origin-main': `nx affected:${affectedCommand} --base=origin/main --parallel --silent --ci`,
'upstream-main': `nx affected:${affectedCommand} --base=upstream/main --parallel --silent --ci`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are also for this repo, not downstream consumers

Comment on lines 55 to 62
default: 'nx format:write --base=upstream/main',
and: {
lint: {
check: nps.concurrent.nps('format.check', 'lint'),
},
},
write: 'nx format:write --base=upstream/master',
check: 'nx format:check --base=upstream/master',
write: 'nx format:write --base=upstream/main',
check: 'nx format:check --base=upstream/main',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are also for this repo, not downstream consumers

@Cammisuli
Copy link
Member

I'm going to do some cleanup and get this one merged in.

@Cammisuli Cammisuli changed the title chore(git-init): update default master branch to main fix: update default branch text to "main" Jan 14, 2022
@Cammisuli Cammisuli force-pushed the chore/replace-git-default-branch-to-main branch from 7c33e14 to 51369f9 Compare January 14, 2022 15:23
@Cammisuli Cammisuli enabled auto-merge (squash) January 14, 2022 15:26
@Cammisuli Cammisuli merged commit a15f2b4 into nrwl:master Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants