From b9faaa6872a7370591ca50456d7cd1f8008cfad6 Mon Sep 17 00:00:00 2001 From: Steve Phelps Date: Sat, 24 Sep 2022 09:26:56 +0100 Subject: [PATCH 1/3] resolves #6 --- README.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.adoc b/README.adoc index d4ee16d..96d2ba7 100644 --- a/README.adoc +++ b/README.adoc @@ -36,7 +36,7 @@ To add one or more of the hooks into your repo: ..pre-commit-config.yaml ---- repos: -- repo: https://github.com/pre-commit/pre-commit-hooks +- repo: https://github.com/softwaremill/scala-pre-commit-hooks rev: {currentVersion} default_phase: push #change to commit if desired hooks: #mix and match any of the following: @@ -73,7 +73,7 @@ To limit hook runs to e.g. `pre-push`, you need to add a `stages` argument with ..pre-commit-config.yaml ---- repos: -- repo: https://github.com/pre-commit/pre-commit-hooks +- repo: https://github.com/softwaremill/scala-pre-commit-hooks rev: {currentVersion} hooks: - id: sbt-fatal-warnings From f43cfbcf6a13a6e8fa611af100d5545876323f8c Mon Sep 17 00:00:00 2001 From: Steve Phelps Date: Sat, 24 Sep 2022 09:35:44 +0100 Subject: [PATCH 2/3] new hook for scalafix --- pre_commit_hooks/scalafix.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 pre_commit_hooks/scalafix.py diff --git a/pre_commit_hooks/scalafix.py b/pre_commit_hooks/scalafix.py new file mode 100644 index 0000000..6733206 --- /dev/null +++ b/pre_commit_hooks/scalafix.py @@ -0,0 +1,16 @@ +from pre_commit_hooks.runner import run_sbt_command +from colorama import init as colorama_init, Fore + +TASK_SCALAFIX = 'scalafixAll --check' +MISSING_PLUGIN_CHECK_STRING = 'Not a valid key: scalafixAll' +MISSING_PLUGIN_ERROR_MSG = f'{Fore.RED}ERROR: scalafix SBT plugin not present! See {Fore.BLUE}https://scalacenter.github.io/scalafix/docs/users/installation.html{Fore.RED} for installation instructions.' + + +def main(argv=None): + colorama_init() + + return run_sbt_command(f'; clean ; {TASK_SCALAFIX}', MISSING_PLUGIN_CHECK_STRING, MISSING_PLUGIN_ERROR_MSG) + + +if __name__ == '__main__': + exit(main()) From 9985ad1fda1ecae6af878f3aea2f0fda95699060 Mon Sep 17 00:00:00 2001 From: Steve Phelps Date: Sat, 24 Sep 2022 09:41:51 +0100 Subject: [PATCH 3/3] new hook for scalafix --- .pre-commit-hooks.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 76146e3..9297360 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -30,3 +30,11 @@ pass_filenames: false always_run: true minimum_pre_commit_version: '0.19.0' +- id: sbt-scalafix + name: scalafix linting check + stages: [commit,push] + language: python_venv + entry: scalafix + pass_filenames: false + always_run: true + minimum_pre_commit_version: '0.3.1'