]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Simplify GitHub Action entrypoint (#2119)
authorShota Ray Imaki <shota.imaki.0801@gmail.com>
Thu, 6 May 2021 02:25:43 +0000 (11:25 +0900)
committerGitHub <noreply@github.com>
Thu, 6 May 2021 02:25:43 +0000 (22:25 -0400)
This commit simplifies entrypoint.sh for GitHub Actions by removing
duplication of args and black_args (cf. #1909).

The reason why #1909 uses the input id black_args is to avoid an overlap
with args, but this naming seems redundant. So let me suggest option
and src, which are consistent with CLI. Backward compatibility is
guaranteed; Users can still use black_args as well.

Commit history pre-merge:
* Simplify GitHub Action entrypoint (#1909)
* Fix prettier
* Emit a warning message when `black_args` is used

  This deprecation should be visible in GitHub Action's UI now.

Co-authored-by: Shota Ray Imaki <shota.imaki.0801@gmail.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
README.md
action.yml
action/entrypoint.sh

index 696bfa7e0640cd2629e04f6be76e035711417b3d..6443569d0d08b2726ae36ebc174aac68364004a2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -425,15 +425,17 @@ jobs:
       - uses: actions/checkout@v2
       - uses: actions/setup-python@v2
       - uses: psf/black@stable
-        with:
-          args: ". --check"
 ```
 
-### Inputs
+You may use `options` (Default is `'--check --diff'`) and `src` (Default is `'.'`) as
+follows:
 
-#### `black_args`
-
-**optional**: Black input arguments. Defaults to `. --check --diff`.
+```yaml
+- uses: psf/black@stable
+  with:
+    options: "--check --verbose"
+    src: "./src"
+```
 
 ## Ignoring unmodified files
 
index 59b16a9fb6cc6916c9f4df58d03d79de17084dcd..827e971801bc2c225486126f02e74c3899602b15 100644 (file)
@@ -2,8 +2,18 @@ name: "Black"
 description: "The uncompromising Python code formatter."
 author: "Łukasz Langa and contributors to Black"
 inputs:
+  options:
+    description:
+      "Options passed to black. Use `black --help` to see available options. Default:
+      '--check'"
+    required: false
+    default: "--check --diff"
+  src:
+    description: "Source to run black. Default: '.'"
+    required: false
+    default: "."
   black_args:
-    description: "Black input arguments."
+    description: "[DEPRECATED] Black input arguments."
     required: false
     default: ""
 branding:
index 50f9472cc5f97ff1a44192d478ecde4e07ff03ed..fc66e24f53a52fd4e2f004912f99c717745c2b59 100755 (executable)
@@ -1,17 +1,8 @@
-#!/bin/bash
-set -e
+#!/bin/bash -e
 
-# If no arguments are given use current working directory
-black_args=(".")
-if [ "$#" -eq 0 ] && [ "${INPUT_BLACK_ARGS}" != "" ]; then
-  black_args+=(${INPUT_BLACK_ARGS})
-elif [ "$#" -ne 0 ] && [ "${INPUT_BLACK_ARGS}" != "" ]; then
-  black_args+=($* ${INPUT_BLACK_ARGS})
-elif [ "$#" -ne 0 ] && [ "${INPUT_BLACK_ARGS}" == "" ]; then
-  black_args+=($*)
-else
-  # Default (if no args provided).
-  black_args+=("--check" "--diff")
-fi
+if [ -n $INPUT_BLACK_ARGS ]; then
+  echo '::warning::Input `with.black_args` is deprecated. Use `with.options` and `with.src` instead.'
+  black $INPUT_BLACK_ARGS
+  exit $?
 
-sh -c "black . ${black_args[*]}"
+black $INPUT_OPTIONS $INPUT_SRC