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

Add support for the changedFilePatterns config #1033

Merged
merged 7 commits into from
Dec 18, 2022

Conversation

Andarist
Copy link
Member

This PR introduces a new config option: changedFilesPatterns.

At first, I thought about introducing this just as a CLI argument for changeset status. However, I realized that changeset add should also use this to split packages between changed and not changed in the prompt. That's why I went with the config option approach.

The main purpose of this new feature is to have a way to optionally validate PRs that changesets are added for changed packages but without requiring changesets to be added for test file changes, docs changes etc.

@Andarist Andarist requested review from chaance and emmatown December 14, 2022 23:13
@changeset-bot
Copy link

changeset-bot bot commented Dec 14, 2022

🦋 Changeset detected

Latest commit: 1d229e0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@changesets/config Minor
@changesets/git Minor
@changesets/types Patch
@changesets/cli Minor
@changesets/apply-release-plan Patch
@changesets/assemble-release-plan Patch
@changesets/get-release-plan Patch
@changesets/read Patch
@changesets/release-utils Patch
@changesets/changelog-git Patch
@changesets/changelog-github Patch
@changesets/get-dependents-graph Patch
get-workspaces Patch
@changesets/parse Patch
@changesets/pre Patch
@changesets/write Patch

Not sure what this means? Click here to learn what changesets are.

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 14, 2022

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 1d229e0:

Sandbox Source
Vanilla Configuration

Comment on lines 103 to 110
"changedFilesPatterns": {
"type": "array",
"items": {
"type": "string"
},
"default": ["**"],
"description": "Glob patterns for changed files that should determining the package as changed."
},
Copy link
Member Author

Choose a reason for hiding this comment

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

I went with an array because it's much easier to write a couple of small globs than one big one - especially if some negated pattern is involved.

Copy link
Member Author

Choose a reason for hiding this comment

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

perhaps this should be named changedFilePatterns? WDYT?

}: {
cwd: string;
ref: string;
}) {
changedFilesPatterns?: readonly string[];
}): Promise<Package[]> {
Copy link
Member Author

Choose a reason for hiding this comment

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

The core of the change is really in this method. I also rewrote this looping to be more efficient.

@@ -102,3 +103,33 @@ export async function testdir(dir: Fixture) {
}

export const tempdir = f.temp;

export async function gitdir(dir: Fixture) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Extracted this here to reuse in the refactored tests for changeset status

@Andarist Andarist changed the title Add support for the changedFilesPatterns config Add support for the changedFilePatterns config Dec 18, 2022
@Andarist Andarist merged commit 521205d into main Dec 18, 2022
@Andarist Andarist deleted the andarist/changed-files-patterns branch December 18, 2022 11:16
@github-actions github-actions bot mentioned this pull request Dec 18, 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.

1 participant