mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 20:55:44 +00:00
Run scalafmt hook through Bazel (#6753)
This commit is contained in:
@@ -34,8 +34,8 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: scalafmt
|
- id: scalafmt
|
||||||
name: scalafmt
|
name: scalafmt
|
||||||
language: system
|
language: system
|
||||||
entry: scalafmt -i -f
|
entry: ./scripts/pre-commit-scalafmt.sh
|
||||||
types_or: ["scala"]
|
types_or: ["scala"]
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
|
|||||||
@@ -295,6 +295,9 @@ maven.install(
|
|||||||
# Testing
|
# Testing
|
||||||
"org.scalamock:scalamock_3:7.4.1",
|
"org.scalamock:scalamock_3:7.4.1",
|
||||||
|
|
||||||
|
# Developer tools
|
||||||
|
"org.scalameta:scalafmt-cli_2.13:3.9.9",
|
||||||
|
|
||||||
# AWS SDK
|
# AWS SDK
|
||||||
"software.amazon.awssdk:s3-transfer-manager:%s" % AWS_SDK_VERSION,
|
"software.amazon.awssdk:s3-transfer-manager:%s" % AWS_SDK_VERSION,
|
||||||
"software.amazon.awssdk:s3:%s" % AWS_SDK_VERSION,
|
"software.amazon.awssdk:s3:%s" % AWS_SDK_VERSION,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -4,8 +4,10 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
|
||||||
|
|
||||||
# Run gazelle
|
# Run gazelle
|
||||||
bazel run //:gazelle 2>/dev/null
|
bazel run //:gazelle
|
||||||
|
|
||||||
# Check if any BUILD files were modified
|
# Check if any BUILD files were modified
|
||||||
if ! git diff --quiet -- '*.bazel' '**/BUILD' 'WORKSPACE*'; then
|
if ! git diff --quiet -- '*.bazel' '**/BUILD' 'WORKSPACE*'; then
|
||||||
|
|||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Pre-commit hook wrapper for scalafmt.
|
||||||
|
# Runs the repository-pinned scalafmt CLI through Bazel.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
|
||||||
|
|
||||||
|
if [ "$#" -eq 0 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
repo_root="$(git rev-parse --show-toplevel)"
|
||||||
|
files=()
|
||||||
|
for file in "$@"; do
|
||||||
|
case "$file" in
|
||||||
|
/*) files+=("$file") ;;
|
||||||
|
*) files+=("$repo_root/$file") ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
bazel run //tools:scalafmt -- --config "$repo_root/.scalafmt.conf" -i "${files[@]}"
|
||||||
@@ -72,6 +72,15 @@ declare_deps_provider(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
java_binary(
|
||||||
|
name = "scalafmt",
|
||||||
|
main_class = "org.scalafmt.cli.Cli",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
runtime_deps = [
|
||||||
|
"@maven//:org_scalameta_scalafmt_cli_2_13",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
declare_deps_provider(
|
declare_deps_provider(
|
||||||
name = "custom_compile_deps",
|
name = "custom_compile_deps",
|
||||||
deps_id = "scalapb_compile_deps",
|
deps_id = "scalapb_compile_deps",
|
||||||
|
|||||||
Reference in New Issue
Block a user