From d04162ee72db6a44a94d32dfe75bc89161e78b83 Mon Sep 17 00:00:00 2001 From: Conrad Date: Wed, 24 May 2023 11:01:47 +0200 Subject: [PATCH 01/19] Added default for prettier_version --- README.md | 4 ++-- action.yml | 2 +- entrypoint.sh | 15 ++------------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 9699de1..e3fedb5 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ A GitHub action for styling files with [prettier](https://prettier.io). | Parameter | Required | Default | Description | | - | :-: | :-: | - | | dry | :x: | `false` | Runs the action in dry mode. Files wont get changed and the action fails if there are unprettified files. Recommended to use with prettier_options --check | -| prettier_version | :x: | `false` | Specific prettier version (by default use latest) | -| working_directory | :x: | `false` | Specify a directory to cd into before installing prettier and running it, use relative file path to the repository root for example `app/` | +| prettier_version | :x: | `latest` | Specific prettier version (by default use latest) | +| working_directory | :x: | - | Specify a directory to cd into before installing prettier and running it, use relative file path to the repository root for example `app/` | | prettier_options | :x: | `"--write **/*.js"` | Prettier options (by default it applies to the whole repository) | | commit_options | :x: | - | Custom git commit options | | push_options | :x: | - | Custom git push options | diff --git a/action.yml b/action.yml index dbc06e0..78c267f 100644 --- a/action.yml +++ b/action.yml @@ -37,7 +37,7 @@ inputs: prettier_version: description: Specific version of prettier (by default just use the latest version) required: false - default: false + default: "latest" working_directory: description: Specify a directory to cd into before installing prettier and running it required: false diff --git a/entrypoint.sh b/entrypoint.sh index 28affa1..1f95c4d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -26,10 +26,6 @@ _git_changed() { [[ -n "$(git status -s)" ]] } -_git_changes() { - git diff -} - ( # PROGRAM # Changing to the directory @@ -45,14 +41,7 @@ case $INPUT_WORKING_DIRECTORY in ;; esac -case $INPUT_PRETTIER_VERSION in - false) - npm install --silent prettier - ;; - *) - npm install --silent prettier@$INPUT_PRETTIER_VERSION - ;; -esac +npm install --silent prettier@$INPUT_PRETTIER_VERSION # Install plugins if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then @@ -97,7 +86,7 @@ if _git_changed; then # case when --write is used with dry-run so if something is unpretty there will always have _git_changed if $INPUT_DRY; then echo "Unpretty Files Changes:" - _git_changes + git diff echo "Finishing dry-run. Exiting before committing." exit 1 else From 473978add96e87010e65ca5897a8d16d18df9ce8 Mon Sep 17 00:00:00 2001 From: Conrad Date: Wed, 24 May 2023 11:05:21 +0200 Subject: [PATCH 02/19] Added default for working_directory --- README.md | 2 +- action.yml | 2 +- entrypoint.sh | 10 +--------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e3fedb5..1fa212a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A GitHub action for styling files with [prettier](https://prettier.io). | - | :-: | :-: | - | | dry | :x: | `false` | Runs the action in dry mode. Files wont get changed and the action fails if there are unprettified files. Recommended to use with prettier_options --check | | prettier_version | :x: | `latest` | Specific prettier version (by default use latest) | -| working_directory | :x: | - | Specify a directory to cd into before installing prettier and running it, use relative file path to the repository root for example `app/` | +| working_directory | :x: | `${{ github.action_path }}` | Specify a directory to cd into before installing prettier and running it, use relative file path to the repository root for example `app/` | | prettier_options | :x: | `"--write **/*.js"` | Prettier options (by default it applies to the whole repository) | | commit_options | :x: | - | Custom git commit options | | push_options | :x: | - | Custom git push options | diff --git a/action.yml b/action.yml index 78c267f..c274230 100644 --- a/action.yml +++ b/action.yml @@ -41,7 +41,7 @@ inputs: working_directory: description: Specify a directory to cd into before installing prettier and running it required: false - default: false + default: ${{ github.action_path }} only_changed: description: Only prettify files changed in the last commit, can't be used with file_pattern! required: false diff --git a/entrypoint.sh b/entrypoint.sh index 1f95c4d..3e440bf 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -29,18 +29,10 @@ _git_changed() { ( # PROGRAM # Changing to the directory -cd "$GITHUB_ACTION_PATH" +cd "$INPUT_WORKING_DIRECTORY" echo "Installing prettier..." -case $INPUT_WORKING_DIRECTORY in - false) - ;; - *) - cd $INPUT_WORKING_DIRECTORY - ;; -esac - npm install --silent prettier@$INPUT_PRETTIER_VERSION # Install plugins From a1c90f8992af4874bbd26c496d558cae41e6527d Mon Sep 17 00:00:00 2001 From: "Federico M. Facca" Date: Fri, 30 Jun 2023 17:23:25 +0200 Subject: [PATCH 03/19] export push_options as env variable (#121) Co-authored-by: Conrad --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index c274230..06b48d4 100644 --- a/action.yml +++ b/action.yml @@ -72,6 +72,7 @@ runs: INPUT_COMMIT_DESCRIPTION: ${{ inputs.commit_description }} INPUT_SAME_COMMIT: ${{ inputs.same_commit }} INPUT_COMMIT_OPTIONS: ${{ inputs.commit_options }} + INPUT_PUSH_OPTIONS: ${{ inputs.push_options }} INPUT_FILE_PATTERN: ${{ inputs.file_pattern }} INPUT_PRETTIER_OPTIONS: ${{ inputs.prettier_options }} INPUT_DRY: ${{ inputs.dry }} From 9aba96f268d1cd21517b123bc217c024042f03e3 Mon Sep 17 00:00:00 2001 From: Blake Dunson <61631900+blakedunson@users.noreply.github.com> Date: Fri, 30 Jun 2023 11:40:51 -0400 Subject: [PATCH 04/19] Allow amended commits to be empty (#119) Co-authored-by: Conrad --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 3e440bf..d32a8d5 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -103,7 +103,7 @@ if _git_changed; then if $INPUT_SAME_COMMIT; then echo "Amending the current commit..." git pull - git commit --amend --no-edit + git commit --amend --no-edit --allow-empty git push origin -f else if [ "$INPUT_COMMIT_DESCRIPTION" != "" ]; then From 4bd40fc4866727c9ec66984c21c230c4082d3c0b Mon Sep 17 00:00:00 2001 From: "Federico M. Facca" Date: Thu, 20 Jul 2023 16:39:13 +0200 Subject: [PATCH 05/19] Support not exiting the process in case of changes in dry mode (#122) Co-authored-by: Conrad --- README.md | 1 + action.yml | 5 +++++ entrypoint.sh | 13 +++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1fa212a..0df6c6f 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ A GitHub action for styling files with [prettier](https://prettier.io). | Parameter | Required | Default | Description | | - | :-: | :-: | - | | dry | :x: | `false` | Runs the action in dry mode. Files wont get changed and the action fails if there are unprettified files. Recommended to use with prettier_options --check | +| no_commit | :x: | `false` | Can be used to avoid committing the changes (useful when another workflow step commits after this one anyways; can be combined with dry mode) | | prettier_version | :x: | `latest` | Specific prettier version (by default use latest) | | working_directory | :x: | `${{ github.action_path }}` | Specify a directory to cd into before installing prettier and running it, use relative file path to the repository root for example `app/` | | prettier_options | :x: | `"--write **/*.js"` | Prettier options (by default it applies to the whole repository) | diff --git a/action.yml b/action.yml index 06b48d4..c8232ef 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,10 @@ inputs: description: Running the script in dry mode just shows whether there are files that should be prettified or not required: false default: false + no_commit: + description: Can be used to avoid committing the changes (can be combined with dry mode, useful when another workflow steps commits after this commit anyways) + required: false + default: false prettier_version: description: Specific version of prettier (by default just use the latest version) required: false @@ -76,6 +80,7 @@ runs: INPUT_FILE_PATTERN: ${{ inputs.file_pattern }} INPUT_PRETTIER_OPTIONS: ${{ inputs.prettier_options }} INPUT_DRY: ${{ inputs.dry }} + INPUT_DRY_NO_COMMIT: ${{ inputs.no_commit }} INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }} INPUT_ONLY_CHANGED: ${{ inputs.only_changed }} INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }} diff --git a/entrypoint.sh b/entrypoint.sh index d32a8d5..c7e4588 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -79,8 +79,12 @@ if _git_changed; then if $INPUT_DRY; then echo "Unpretty Files Changes:" git diff - echo "Finishing dry-run. Exiting before committing." - exit 1 + if $INPUT_NO_COMMIT; then + echo "There are changes that won't be commited, you can use an external job to do so." + else + echo "Finishing dry-run. Exiting before committing." + exit 1 + fi else # Calling method to configure the git environemnt _git_setup @@ -99,6 +103,11 @@ if _git_changed; then git add "${INPUT_FILE_PATTERN}" || echo "Problem adding your files with pattern ${INPUT_FILE_PATTERN}" fi + if $INPUT_NO_COMMIT; then + echo "There are changes that won't be commited, you can use an external job to do so." + exit 0 + fi + # Commit and push changes back if $INPUT_SAME_COMMIT; then echo "Amending the current commit..." From 5b5cb513f14888edf9ff23a6a6eab10d7d63f70b Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 20 Jul 2023 20:55:18 +0200 Subject: [PATCH 06/19] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index c8232ef..da1e664 100644 --- a/action.yml +++ b/action.yml @@ -80,7 +80,7 @@ runs: INPUT_FILE_PATTERN: ${{ inputs.file_pattern }} INPUT_PRETTIER_OPTIONS: ${{ inputs.prettier_options }} INPUT_DRY: ${{ inputs.dry }} - INPUT_DRY_NO_COMMIT: ${{ inputs.no_commit }} + INPUT_NO_COMMIT: ${{ inputs.no_commit }} INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }} INPUT_ONLY_CHANGED: ${{ inputs.only_changed }} INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }} From 0fc0cf472314a711adbefdbf2ca5bc1b79f59e42 Mon Sep 17 00:00:00 2001 From: Derek Brown Date: Mon, 21 Aug 2023 12:05:34 -0700 Subject: [PATCH 07/19] feat: Allow overriding actor (#126) Co-authored-by: Conrad --- README.md | 1 + action.yml | 5 +++++ entrypoint.sh | 13 +++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0df6c6f..f1f0455 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ A GitHub action for styling files with [prettier](https://prettier.io). | clean_node_folder | :x: | `true` | Delete the node_modules folder before committing | | only_changed | :x: | `false` | Only prettify changed files, can't be used with file_pattern! This command works only with the checkout action set to fetch depth '0' (see example 2)| | github_token | :x: | `${{ github.token }}` | The default [GITHUB_TOKEN](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret) or a [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) +| git_identity | :x: | `actions` | Set to `author` to use author's user as committer. This allows triggering [further workflow runs](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs) > Note: using the same_commit option may lead to problems if other actions are relying on the commit being the same before and after the prettier action has ran. Keep this in mind. diff --git a/action.yml b/action.yml index da1e664..de7f649 100644 --- a/action.yml +++ b/action.yml @@ -62,6 +62,10 @@ inputs: description: Remove the node_modules folder before committing changes required: false default: true + git_identity: + description: Which identity is used for git name/email + required: false + default: "actions" runs: using: "composite" @@ -87,6 +91,7 @@ runs: INPUT_WORKING_DIRECTORY: ${{ inputs.working_directory }} INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} INPUT_CLEAN_NODE_FOLDER: ${{ inputs.clean_node_folder }} + INPUT_GIT_IDENTITY: ${{ inputs.git_identity }} branding: icon: "award" diff --git a/entrypoint.sh b/entrypoint.sh index c7e4588..aece03b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -17,8 +17,17 @@ _git_setup ( ) { EOF chmod 600 $HOME/.netrc - git config --global user.email "actions@github.com" - git config --global user.name "GitHub Action" + # If GIT_IDENTITY="actor" + if [ "$INPUT_GIT_IDENTITY" = "author" ]; then + git config --global user.name "$GITHUB_ACTOR" + git config --global user.email "$GITHUB_ACTOR@@users.noreply.github.com" + elif [ "$INPUT_GIT_IDENTITY" = "actions" ]; then + git config --global user.email "actions@github.com" + git config --global user.name "GitHub Action" + else + echo "GIT_IDENTITY must be either 'actor' or 'actions'"; + exit 1; + fi; } # Checks if any files are changed From 57dc57f2369998031c3c7362400fbd7d2a253d62 Mon Sep 17 00:00:00 2001 From: Conrad Date: Tue, 3 Oct 2023 17:12:40 +0200 Subject: [PATCH 08/19] Added star history --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index f1f0455..30e0ce4 100644 --- a/README.md +++ b/README.md @@ -172,3 +172,7 @@ This issue was discussed in https://github.com/creyD/prettier_action/issues/113. - name: Install npm v8 run: npm i -g npm@8 ``` + +## Star History + +[![Star History Chart](https://api.star-history.com/svg?repos=creyD/prettier_action&type=Date)](https://star-history.com/#creyD/prettier_action&Date) From 5d0450c2bc9b47a8421c33ee95ce87b231828f6e Mon Sep 17 00:00:00 2001 From: Conrad Date: Tue, 3 Oct 2023 20:37:27 +0200 Subject: [PATCH 09/19] Addede step summary in GitHub --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index aece03b..4acd5e8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -62,7 +62,7 @@ PRETTIER_RESULT=0 echo "Prettifying files..." echo "Files:" prettier $INPUT_PRETTIER_OPTIONS \ - || { PRETTIER_RESULT=$?; echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS"; exit 1; } + || { PRETTIER_RESULT=$?; echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS"; exit 1; } >> $GITHUB_STEP_SUMMARY echo "Prettier result: $PRETTIER_RESULT" From 117a7a5b3701a6cf2babb4f0baf1204dee106c0f Mon Sep 17 00:00:00 2001 From: Conrad Date: Wed, 10 Jan 2024 12:26:30 +0100 Subject: [PATCH 10/19] Updated Readme according to #132 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 30e0ce4..fc2cd1b 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # Make sure the actual branch is checked out when running on pull requests ref: ${{ github.head_ref }} @@ -83,7 +83,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # Make sure the actual branch is checked out when running on pull requests ref: ${{ github.head_ref }} @@ -113,7 +113,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ github.head_ref }} @@ -144,7 +144,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ github.head_ref }} From f32e6a975aa23da7cedd262bd79d00f8cda0af7e Mon Sep 17 00:00:00 2001 From: Conrad Date: Wed, 10 Jan 2024 12:43:00 +0100 Subject: [PATCH 11/19] Fixing bug #128 --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4acd5e8..572de87 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -77,7 +77,7 @@ if $INPUT_CLEAN_NODE_FOLDER; then fi if [ -f 'package-lock.json' ]; then - git checkout -- package-lock.json + git checkout -- package-lock.json || echo "No package-lock.json file tracked by git." else echo "No package-lock.json file." fi From a3561a8976a4de11499fad13861d424a0604ebfc Mon Sep 17 00:00:00 2001 From: John Jetmore Date: Sat, 27 Jan 2024 09:52:56 -0500 Subject: [PATCH 12/19] set INPUT_WORKING_DIRECTORY if not already set --- entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 572de87..b59ef7b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -38,6 +38,9 @@ _git_changed() { ( # PROGRAM # Changing to the directory +if [ -z "$INPUT_WORKING_DIRECTORY" ] ; then + INPUT_WORKING_DIRECTORY=$GITHUB_ACTION_PATH +fi cd "$INPUT_WORKING_DIRECTORY" echo "Installing prettier..." From d5e6c388c31d68f53cba6bce42bd663a991d57d8 Mon Sep 17 00:00:00 2001 From: Conrad Date: Sun, 24 Nov 2024 17:19:57 +0100 Subject: [PATCH 13/19] added codacy badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fc2cd1b..499d7a1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # GitHub Prettier Action [![CodeFactor](https://www.codefactor.io/repository/github/creyd/prettier_action/badge/master)](https://www.codefactor.io/repository/github/creyd/prettier_action/overview/master) -[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ba5fa97677ee47e48efdc2e6f7493c49)](https://app.codacy.com/gh/creyD/prettier_action/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [![License MIT](https://img.shields.io/github/license/creyD/prettier_action)](https://github.com/creyD/prettier_action/blob/master/LICENSE) [![Latest Release](https://img.shields.io/github/v/release/creyD/prettier_action)](https://github.com/creyD/prettier_action/releases) [![Contributors](https://img.shields.io/github/contributors-anon/creyD/prettier_action)](https://github.com/creyD/prettier_action/graphs/contributors) From e53f331f484fec65d41030a92cf3b868d7bc63ec Mon Sep 17 00:00:00 2001 From: John Jetmore Date: Thu, 8 May 2025 04:18:46 -0400 Subject: [PATCH 14/19] Add only_changed_pr (#135) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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. --- action.yml | 7 ++++++- entrypoint.sh | 40 +++++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/action.yml b/action.yml index de7f649..a48ceb3 100644 --- a/action.yml +++ b/action.yml @@ -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 }} diff --git a/entrypoint.sh b/entrypoint.sh index b59ef7b..619b1d9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -85,6 +85,31 @@ else echo "No package-lock.json file." fi +# If running under only_changed, reset every modified file that wasn't also modified in the last commit +# This allows only_changed and dry to work together, and simplified the non-dry logic below +if [ $INPUT_ONLY_CHANGED = true -o $INPUT_ONLY_CHANGED_PR = true ] ; then + BASE_BRANCH=origin/$GITHUB_BASE_REF + if $INPUT_ONLY_CHANGED; then + BASE_BRANCH=HEAD~1 + fi + + echo "Resetting changes, removing changes to files not changed since $BASE_BRANCH" + # list of all files changed in the previous commit + git diff --name-only HEAD $BASE_BRANCH > /tmp/prev.txt + # list of all files with outstanding changes + git diff --name-only HEAD > /tmp/cur.txt + + OLDIFS="$IFS" + IFS=$'\n' + # get all files that are in prev.txt that aren't also in cur.txt + for file in $(comm -1 -3 /tmp/prev.txt /tmp/cur.txt) + do + echo "resetting: $file" + git restore -- "$file" + done + IFS="$OLDIFS" +fi + # To keep runtime good, just continue if something was changed if _git_changed; then # case when --write is used with dry-run so if something is unpretty there will always have _git_changed @@ -101,19 +126,8 @@ if _git_changed; then # Calling method to configure the git environemnt _git_setup - if $INPUT_ONLY_CHANGED; then - # --diff-filter=d excludes deleted files - OLDIFS="$IFS" - IFS=$'\n' - for file in $(git diff --name-only --diff-filter=d HEAD^..HEAD) - do - git add "$file" - done - IFS="$OLDIFS" - else - # Add changes to git - git add "${INPUT_FILE_PATTERN}" || echo "Problem adding your files with pattern ${INPUT_FILE_PATTERN}" - fi + # Add changes to git + git add "${INPUT_FILE_PATTERN}" || echo "Problem adding your files with pattern ${INPUT_FILE_PATTERN}" if $INPUT_NO_COMMIT; then echo "There are changes that won't be commited, you can use an external job to do so." From 12efc36860873fe1c09efc3ce00c60420cef8413 Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 8 May 2025 10:23:14 +0200 Subject: [PATCH 15/19] fix: codacy warning --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 619b1d9..8b177aa 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -87,7 +87,7 @@ fi # If running under only_changed, reset every modified file that wasn't also modified in the last commit # This allows only_changed and dry to work together, and simplified the non-dry logic below -if [ $INPUT_ONLY_CHANGED = true -o $INPUT_ONLY_CHANGED_PR = true ] ; then +if [ $INPUT_ONLY_CHANGED = true] || [$INPUT_ONLY_CHANGED_PR = true ] ; then BASE_BRANCH=origin/$GITHUB_BASE_REF if $INPUT_ONLY_CHANGED; then BASE_BRANCH=HEAD~1 From eeb940db6da2c1895c33bc536310e521b417d19f Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 8 May 2025 10:24:50 +0200 Subject: [PATCH 16/19] fix: fixed codacy error --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8b177aa..dccdc65 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -87,7 +87,7 @@ fi # If running under only_changed, reset every modified file that wasn't also modified in the last commit # This allows only_changed and dry to work together, and simplified the non-dry logic below -if [ $INPUT_ONLY_CHANGED = true] || [$INPUT_ONLY_CHANGED_PR = true ] ; then +if [ $INPUT_ONLY_CHANGED = true ] || [$INPUT_ONLY_CHANGED_PR = true ] ; then BASE_BRANCH=origin/$GITHUB_BASE_REF if $INPUT_ONLY_CHANGED; then BASE_BRANCH=HEAD~1 From 9f54668ece5b368fcd0e4cf7eb215156dd0885f4 Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 8 May 2025 10:32:44 +0200 Subject: [PATCH 17/19] fix: minor documentation cleanups --- action.yml | 2 +- entrypoint.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index a48ceb3..54dbc65 100644 --- a/action.yml +++ b/action.yml @@ -67,7 +67,7 @@ inputs: required: false default: true git_identity: - description: Which identity is used for git name/email + description: Which identity is used for git name/email when committing changes. Needs to be one of "actions" or "author". required: false default: "actions" diff --git a/entrypoint.sh b/entrypoint.sh index dccdc65..7ba5200 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -20,12 +20,12 @@ EOF # If GIT_IDENTITY="actor" if [ "$INPUT_GIT_IDENTITY" = "author" ]; then git config --global user.name "$GITHUB_ACTOR" - git config --global user.email "$GITHUB_ACTOR@@users.noreply.github.com" + git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" elif [ "$INPUT_GIT_IDENTITY" = "actions" ]; then git config --global user.email "actions@github.com" git config --global user.name "GitHub Action" else - echo "GIT_IDENTITY must be either 'actor' or 'actions'"; + echo "GIT_IDENTITY must be either 'author' or 'actions'"; exit 1; fi; } From f24ab29247d9b5da1e93ff79b6c4aa4f3c5602d4 Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 8 May 2025 11:04:01 +0200 Subject: [PATCH 18/19] fix: version bump for examples --- README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 499d7a1..77f4899 100644 --- a/README.md +++ b/README.md @@ -57,12 +57,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - # Make sure the actual branch is checked out when running on pull requests - ref: ${{ github.head_ref }} - name: Prettify code - uses: creyD/prettier_action@v4.3 + uses: creyD/prettier_action@v4.4 with: # This part is also where you can pass other options, for example: prettier_options: --write **/*.{js,md} @@ -91,7 +88,7 @@ jobs: fetch-depth: 0 - name: Prettify code - uses: creyD/prettier_action@v4.3 + uses: creyD/prettier_action@v4.4 with: # This part is also where you can pass other options, for example: prettier_options: --write **/*.{js,md} @@ -121,7 +118,7 @@ jobs: persist-credentials: false - name: Prettify code - uses: creyD/prettier_action@v4.3 + uses: creyD/prettier_action@v4.4 with: prettier_options: --write **/*.{js,md} only_changed: True @@ -152,7 +149,7 @@ jobs: persist-credentials: false - name: Prettify code - uses: creyD/prettier_action@v4.3 + uses: creyD/prettier_action@v4.4 with: dry: True github_token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} From b73c2bf29c92ed27eefd271ffc645eee229e5331 Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 8 May 2025 11:14:35 +0200 Subject: [PATCH 19/19] fix: updated link --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 77f4899..0b1032a 100644 --- a/README.md +++ b/README.md @@ -172,4 +172,10 @@ This issue was discussed in https://github.com/creyD/prettier_action/issues/113. ## Star History -[![Star History Chart](https://api.star-history.com/svg?repos=creyD/prettier_action&type=Date)](https://star-history.com/#creyD/prettier_action&Date) + + + + + Star History Chart + +