Skip to content

Ignore find changed packages error in changeset add - #1485

Merged
Andarist merged 4 commits into
mainfrom
ignore-base-branch-invalid
Nov 12, 2024
Merged

Andarist merged 4 commits into
mainfrom
ignore-base-branch-invalid

Conversation

@bluwy

@bluwy bluwy commented Oct 5, 2024

Copy link
Copy Markdown
Member

Resolves the issue noted in #1473 (comment). If baseBranch can't be found locally, you'd no longer get a hard error, but a warning.

Before:
image

After:
image

@changeset-bot

changeset-bot Bot commented Oct 5, 2024 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d95273c

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

This PR includes changesets to release 1 package
Name Type
@changesets/cli 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

@codecov

codecov Bot commented Oct 5, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 81.01%. Comparing base (7ce17f5) to head (d95273c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/cli/src/commands/add/index.ts 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1485      +/-   ##
==========================================
- Coverage   81.07%   81.01%   -0.06%     
==========================================
  Files          54       54              
  Lines        2224     2228       +4     
  Branches      662      662              
==========================================
+ Hits         1803     1805       +2     
- Misses        417      419       +2     
  Partials        4        4              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread packages/git/src/index.ts Resolved
cwd,
})
).map((pkg) => pkg.packageJson.name);
} catch (e: any) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should strive to handle specific errors here. We can throw custom errors in @changesets/git and handle them here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do you mean we should only handle the specific error from getDivergedCommit, and otherwise we re-throw the other errors?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I looked through the call paths for getVersionableChangedPackages and it looks like there's many spawns or git operations that could throw a generic error that fails, so we'd have to go through more of the codebase to update the error class.

I think my intention with the catch-all here is also because the changedPackagesNames is a best-effort call to show users changed packages for easier selection. If any error happens there it shouldn't block creating changesets at all. So I think a catch-all may still be feasible here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, I see your point. It feels like it would be good to at least avoid displaying the error stack for those errors that we know of.

I'm fine with this change as-is though - it's up to you if you think it's worth changing anything here. I'd add a code comment about the catch-all rationale here though

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It feels like it would be good to at least avoid displaying the error stack for those errors that we know of.

That sounds like a good idea to me. I think I'll follow-up using custom errors to achieve that and still leave the catch-all logging for errors we don't expect.

Will add a comment for the catch-all 👍

bluwy and others added 2 commits November 12, 2024 17:07
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
@Andarist
Andarist merged commit baf5644 into main Nov 12, 2024
@Andarist
Andarist deleted the ignore-base-branch-invalid branch November 12, 2024 11:42
@github-actions github-actions Bot mentioned this pull request Nov 12, 2024
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.

2 participants