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

defaultWrittenConfig change baseBranch from master to main #677

Closed
wants to merge 1 commit into from
Closed

defaultWrittenConfig change baseBranch from master to main #677

wants to merge 1 commit into from

Conversation

janosh
Copy link
Contributor

@janosh janosh commented Nov 22, 2021

Closes #675.

Should I add a changelog entry?

@atlassian-cla-bot
Copy link

atlassian-cla-bot bot commented Nov 22, 2021

Hooray! All contributors have signed the CLA.

@changeset-bot
Copy link

changeset-bot bot commented Nov 22, 2021

⚠️ No Changeset found

Latest commit: b397c6a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -40,7 +40,7 @@ test("read reads the config", async () => {
changelog: false,
commit: true,
access: "restricted",
baseBranch: "master",
baseBranch: "main",
Copy link
Member

Choose a reason for hiding this comment

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

Correct me if I'm wrong but it looks like this is actually a breaking change. I've looked into the new-config fixture and it only has such .changeset/config.json:

{
  "changelog": false,
  "commit": true
}

I think the point of this PR was only to initialize the .changeset/config.json with the new value but not to change what it defaults to when it is not explicitly given etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the point of this PR was only to initialize the .changeset/config.json with the new value but not to change what it defaults to when it is not explicitly given etc.

What's the difference there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Andarist Happy to make changes here as necessary but I didn't quite understand your point.

Copy link
Member

Choose a reason for hiding this comment

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

The problem with the current solution is that if somebody already has a config like:

{
  "changelog": false,
  "commit": true
}

then with this change Changesets would start using main as their baseBranch and thus it would change behavior, by potentially crashing because a main branch might not even exist in a given repository.

When initializing Changesets we write defaultBranch into the generated .changeset/config.json, even though it's not strictly required because that property has a default. But since we are outputting this property it can be changed somewhat safely because people who are already using Changesets are not running changesets init, they have already done that in the past.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, makes sense. So we need two separate objects, one like defaultWrittenConfig which sets the default values in a new config file and another defaultConfigValues that sets the values for configs that don't specify optional keys??

Copy link
Member

Choose a reason for hiding this comment

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

Ye, smth like that would work. Please only that because this is a monorepo we might have to implement this in a non-intuitive way. We don't want to break people who don't upgrade all of the transitive dependencies at once.

I think that the safest solution is to not touch defautlWrittenConfig at all (as weirdly as it might be) - and to just override this value before we actually write it in the config file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that the safest solution is to not touch defautlWrittenConfig at all (as weirdly as it might be) - and to just override this value before we actually write it in the config file.

I agree, seems like the best solution here.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 8, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b397c6a:

Sandbox Source
Vanilla Configuration

@janosh janosh mentioned this pull request Dec 8, 2021
@janosh
Copy link
Contributor Author

janosh commented Mar 11, 2022

@Andarist Could you let me know if this change is still acceptable?

@@ -44,7 +46,7 @@ export default async function init(cwd: string) {
await fs.copy(path.resolve(pkgPath, "./default-files"), changesetBase);
await fs.writeFile(
path.resolve(changesetBase, "config.json"),
JSON.stringify(defaultWrittenConfig, null, 2)
JSON.stringify({ ...defaultWrittenConfig, baseBranch: "main" }, null, 2)
Copy link
Member

Choose a reason for hiding this comment

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

I would extract this to a variable on the top of the file, so the added comment could be added to that variable so it would be visible~ in a common place for both places that have been touched here.

@Andarist
Copy link
Member

@janosh sorry for the delay, it's just sometimes hard to get to everything on time. The PR looks good - I just left a single nit-level comment. Could you also add a changeset to this PR?

@janosh
Copy link
Contributor Author

janosh commented Mar 12, 2022

@Andarist I had deleted my fork so couldn't make any further changes here. Closing in favor of #776 where I addressed your comments.

@janosh janosh closed this Mar 12, 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.

Change default base branch: master -> main
2 participants