Add only_changed_pr (#135)

* allow `only_changed` and `dry` to work together

Before this change, if you tried to use `dry` and `only_changed together, it acted as if `only_changed` was ignored.  There was no code specific to `only_changed` down the `dry` code path.

This commit’s solution is to run prettier on the entire code base (as was already being done) and then, before doing any comparisons, reset changes to files that were not modified in the last commit.

* add `only_changed_pr` option

This behaves similarly to only_changed, except instead of only considering files which were modified in the last commit, this option only considers files which were modified in any commit included in the current PR.
This commit is contained in:
John Jetmore
2025-05-08 04:18:46 -04:00
committed by GitHub
parent d5e6c388c3
commit e53f331f48
2 changed files with 33 additions and 14 deletions

View File

@@ -23,7 +23,7 @@ inputs:
description: Git push options
required: false
file_pattern:
description: File pattern used for `git add`, can't be used with only_changed!
description: File pattern used for `git add`, can't be used with only_changed or only_changed_pr!
required: false
default: "*"
prettier_options:
@@ -50,6 +50,10 @@ inputs:
description: Only prettify files changed in the last commit, can't be used with file_pattern!
required: false
default: false
only_changed_pr:
description: Only prettify files changed in the current PR. If specified with only_changed, only_changed will take precedent. Can't be used with file_pattern!
required: false
default: false
prettier_plugins:
description: Install Prettier plugins, i.e. `@prettier/plugin-php @prettier/plugin-other`
required: false
@@ -87,6 +91,7 @@ runs:
INPUT_NO_COMMIT: ${{ inputs.no_commit }}
INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }}
INPUT_ONLY_CHANGED: ${{ inputs.only_changed }}
INPUT_ONLY_CHANGED_PR: ${{ inputs.only_changed_pr }}
INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }}
INPUT_WORKING_DIRECTORY: ${{ inputs.working_directory }}
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}