Unverified Commit ba3648d9 authored by Rick Staa's avatar Rick Staa Committed by GitHub
Browse files

Release gh action (#1909)

* Gets gh-action ready for marketplace release

* Updates documentation and removes redundant gh-action input argument

* Fixes gh-action bug

This commit fixes a bug which caused not all input arguments were forwarder to the black formatter.

* Update README.md

Co-authored-by: default avatarCooper Lees <me@cooperlees.com>

Co-authored-by: default avatarCooper Lees <me@cooperlees.com>
parent 966baaac
Loading
Loading
Loading
Loading
+8 −0
Changes for README.md: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -411,8 +411,16 @@ jobs:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
      - uses: psf/black@stable
        with:
          black_args: ". --check"
```

### Inputs

#### `black_args`

**optional**: Black input arguments. Defaults to `. --check --diff`.

## Ignoring unmodified files

_Black_ remembers files it has already formatted, unless the `--diff` flag is used or
+5 −0
Changes for action.yml: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
name: "Black"
description: "The uncompromising Python code formatter."
author: "Łukasz Langa and contributors to Black"
inputs:
  black_args:
    description: "Black input arguments."
    required: false
    default: ""
branding:
  color: "black"
  icon: "check-circle"
+12 −5
Changes for action/entrypoint.sh: 12 added lines, 5 removed lines.
Original line number Diff line number Diff line
#!/bin/sh
set -e

if [ $# -eq 0 ]; then
    # Default (if no args provided).
    sh -c "black . --check --diff"
# 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
    # Custom args.
    sh -c "black $*"
  # Default (if no args provided).
  black_args+=("--check" "--diff")
fi

sh -c "black . ${black_args[*]}"