Skip to content

Commit 0a4018d

Browse files
authored
Merge pull request #10357 from naveenvenk17/fix-bazel-lint-without-git
Fix lint source discovery without git
2 parents e0ec44c + 2f7a45b commit 0a4018d

5 files changed

Lines changed: 17 additions & 8 deletions

File tree

BUILD.bazel

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,14 @@ sh_test(
584584
sh_binary(
585585
name = "tidy_tcl",
586586
srcs = ["//bazel:tcl_tidy.sh"],
587-
args = ["$(rootpath //bazel:tclfmt)"],
587+
args = [
588+
"$(rootpath //bazel:tclfmt)",
589+
"$(rootpath @git)",
590+
],
588591
data = [
589592
"tclint.toml",
590593
"//bazel:tclfmt",
594+
"@git",
591595
],
592596
)
593597

@@ -633,9 +637,13 @@ sh_test(
633637
sh_binary(
634638
name = "tidy_bzl",
635639
srcs = ["//bazel:bzl_tidy.sh"],
636-
args = ["$(rootpath @buildifier_prebuilt//:buildifier)"],
640+
args = [
641+
"$(rootpath @buildifier_prebuilt//:buildifier)",
642+
"$(rootpath @git)",
643+
],
637644
data = [
638645
"@buildifier_prebuilt//:buildifier",
646+
"@git",
639647
],
640648
)
641649

bazel/bzl_tidy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
# Auto-format all Bazel files in-place using buildifier.
66
set -euo pipefail
77
TOOL="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
8+
GIT="$(realpath "$2")"
89
cd "${BUILD_WORKSPACE_DIRECTORY:-$PWD}"
910
# `-c submodule.recurse=false` keeps git ls-files from descending into
1011
# submodules (src/sta, third-party/abc, third-party/slang-elab and the
1112
# fmt sub-submodule nested in it) — we never want to rewrite files
1213
# owned by another repo. The override is needed because CI sets
1314
# submodule.recurse=true globally.
14-
git -c submodule.recurse=false ls-files \
15+
"${GIT}" -c submodule.recurse=false ls-files \
1516
'*.bazel' '*.bzl' '**/BUILD' 'BUILD' '**/WORKSPACE' 'WORKSPACE' -z \
1617
| xargs -0 "$TOOL" -mode=fix -lint=fix

bazel/fix_lint.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ BZL_LINT_BUILDIFIER="$8"
1717
GIT="$9"
1818

1919
export BUILD_WORKSPACE_DIRECTORY="${BUILD_WORKSPACE_DIRECTORY:-$PWD}"
20-
2120
# TCL: auto-format then lint
22-
"${TCL_TIDY_SH}" "${TCLFMT}"
21+
"${TCL_TIDY_SH}" "${TCLFMT}" "${GIT}"
2322
"${TCL_LINT_SH}" "${TCLINT}" "${GIT}" || rc=$?
2423

2524
# Bazel: auto-format then lint
26-
"${BZL_TIDY_SH}" "${BZL_FMT_BUILDIFIER}"
25+
"${BZL_TIDY_SH}" "${BZL_FMT_BUILDIFIER}" "${GIT}"
2726
"${BZL_LINT_SH}" "${BZL_LINT_BUILDIFIER}" "${GIT}" || rc=$?
2827

2928
"${GIT}" -C "$BUILD_WORKSPACE_DIRECTORY" status

bazel/tcl_lint_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
set -euo pipefail
88

9-
TOOL="$(realpath "$1")"
9+
TOOL="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
1010
GIT="$(realpath "$2")"
1111

1212
WORKSPACE="$(dirname "$(readlink -f tclint.toml)")"

bazel/tcl_tidy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
# Auto-format all TCL files in-place.
66
set -euo pipefail
77
TOOL="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
8+
GIT="$(realpath "$2")"
89
cd "${BUILD_WORKSPACE_DIRECTORY:-$PWD}"
9-
git ls-files '*.tcl' -z | xargs -0 "$TOOL" --in-place
10+
"${GIT}" ls-files '*.tcl' -z | xargs -0 "$TOOL" --in-place

0 commit comments

Comments
 (0)