Commit 34faae46 authored by Yann E. MORIN's avatar Yann E. MORIN
Browse files

feat(black): display diff of reformatted files



When black decides to reformat one or many files, fixing those would
require the user to locally install black, with the exact same version
that was used in the pipeline, and run black locally.

This can be tedious when the diff is very minor and just need a simple
local edit to fix.

Instruct black to display the diff so that it is visible in the job's
build log. The user will then be able to decide whether they can just
manually tweak their source code for small diffs, or if they need to
go all the way to install and run black locally for bigger diffs.

Signed-off-by: default avatarYann E. MORIN <yann.morin@orange.com>
parent a6edcd22
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -345,6 +345,8 @@ This job **disabled by default** and runs [black](https://black.readthedocs.io)
| ---------------- | ----------------------------------------------------------------------- | ----------------- |
| `black-enabled` / `PYTHON_BLACK_ENABLED` | Set to `true` to enable black job               | _none_ (disabled) |

When `black` detects malformed code, the result is displayed in the job's output log (as a diff).

### `py-isort` job

This job **disabled by default** and runs [isort](https://pycqa.github.io/isort/) on the repo. It is bound to the build stage.
+1 −1
Original line number Diff line number Diff line
@@ -1296,7 +1296,7 @@ py-black:
  script:
    - install_requirements
    - _pip install black
    - _run black . --check --extend-exclude '(\/\.cache\/|\/\.venv\/)'
    - _run black . --check --diff --extend-exclude '(\/\.cache\/|\/\.venv\/)'
  rules:
    # exclude if $PYTHON_BLACK_ENABLED not set
    - if: '$PYTHON_BLACK_ENABLED != "true"'