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

Only format files changed in PR #290

Open
mdedetrich opened this issue Oct 5, 2022 · 1 comment
Open

Only format files changed in PR #290

mdedetrich opened this issue Oct 5, 2022 · 1 comment

Comments

@mdedetrich
Copy link

mdedetrich commented Oct 5, 2022

This is a nice to have feature, but basically the idea is that if you run this github action specifically on a PR it will only run scalafmt against the files that have been changed in the PR rather than the entire project

Scalafmt supports a -f flag which can be repeated with a list of files, i.e.

scalafmt -f file1 -f file2

There is a changed files action (see https://github.com/marketplace/actions/changed-files) which lets you get an output of all of the changed files which would then be fed into scalafmt. Then we can add a config for this, something like

formatOnlyChangedOnPullRequest: null // default behaviour
formatOnlyChangedOnPullRequest: file // most granular option, will strictly only format changed files
formatOnlyChangedOnPullRequest: dir // less granular, will format dirs that happen to have changed files
@mdedetrich
Copy link
Author

Note that I made an issue on scalafmt upstream to support this feature as it may make more sense to implement it upstream rather than specifically in this project, see scalameta/scalafmt#3344

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

No branches or pull requests

1 participant