Skip to content

Commit

Permalink
feat(dev): add rustfmt checks in linter (#4989)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcalandro committed Jul 20, 2021
1 parent 8a6e908 commit f21f37e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Expand Up @@ -86,4 +86,12 @@ repos:
language: script
entry: tools/git/test-affected-targets.sh
stages: [push]
- id: rustfmt
name: Format w/ rustfmt
description: Runs `rustfmt` on Rust files
language: system
entry: rustfmt
args: [--config-path, tools/rust/rustfmt.toml, --check]
types: [rust]
exclude: '^(kythe/proto/.*|third_party/.*)'
exclude: '(.*/testdata/.*)|(third_party/.*)|(tools/platforms/configs/(versions.bzl|default_toolchain_config_spec_name/.*)$)'
6 changes: 6 additions & 0 deletions kythe/release/cloudbuild/pre-commit/Dockerfile
Expand Up @@ -47,6 +47,12 @@ RUN curl -s https://api.github.com/repos/google/google-java-format/releases/late
&& /bin/echo -e '#!/bin/sh\nexec java -jar /usr/bin/google-java-format.jar "$@"' >/usr/bin/google-java-format \
&& chmod +x /usr/bin/google-java-format

# Fetch the rustup installer and install the nightly standard toolchain
RUN curl -o /tmp/rustup.sh --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs && \
/bin/bash /tmp/rustup.sh --default-toolchain nightly --profile default -y && \
/bin/bash -c "source $HOME/.cargo/env" && \
rm /tmp/rustup.sh

# Install go wrapper script
ADD go /usr/local/bin/go
ENV PATH=$PATH:/root/go/bin
Expand Down
2 changes: 1 addition & 1 deletion tools/rust/rustfmt.sh
Expand Up @@ -17,5 +17,5 @@
find kythe/rust/ tools/rust/ -name '*.rs' -not -wholename "*target/*" -not -wholename "*rust/*/testdata/*" -print0 | while read -r -d $'\0' f
do
echo "Formatting $f";
rustfmt --config-path "$(dirname "${BASH_SOURCE[0]}")" "$f";
rustfmt --config-path "$(dirname "${BASH_SOURCE[0]}")" "$@" "$f";
done

0 comments on commit f21f37e

Please sign in to comment.