mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-23 08:02:15 -05:00
Merge pull request #505 from epage/binary
fix(gh): Don't report bad annotations for binary files
This commit is contained in:
commit
5491b61803
3 changed files with 18 additions and 10 deletions
|
@ -6,5 +6,6 @@ RUN wget https://github.com/crate-ci/typos/releases/download/v${VERSION}/typos-v
|
|||
tar -xzvf typos-v${VERSION}-x86_64-unknown-linux-musl.tar.gz && \
|
||||
mv typos /usr/local/bin
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
COPY format_gh.sh /format_gh.sh
|
||||
WORKDIR /github/workspace
|
||||
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
set -eu
|
||||
|
||||
SOURCE_DIR="$(dirname -- ${BASH_SOURCE[0]:-$0})";
|
||||
|
||||
log() {
|
||||
echo -e "$1" >&2
|
||||
}
|
||||
|
@ -34,22 +36,18 @@ fi
|
|||
log "typos: $(typos --version)"
|
||||
log "jq: $(jq --version)"
|
||||
|
||||
COMMAND="${CMD_NAME} ${TARGET}"
|
||||
ARGS="${TARGET}"
|
||||
|
||||
# Ignore implicit configuration files
|
||||
if [ "${INPUT_ISOLATED:-false}" == "true" ]; then
|
||||
COMMAND+=" --isolated"
|
||||
ARGS+=" --isolated"
|
||||
fi
|
||||
|
||||
# Use a custom configuration file
|
||||
if [[ -n "${INPUT_CONFIG:-}" ]]; then
|
||||
COMMAND+=" --config ${INPUT_CONFIG}"
|
||||
ARGS+=" --config ${INPUT_CONFIG}"
|
||||
fi
|
||||
|
||||
log "$ ${COMMAND}"
|
||||
${COMMAND} --format json |
|
||||
jq --sort-keys --raw-output '"::warning file=\(.path),line=\(.line_num),col=\(.byte_offset)::\"\(.typo)\" should be \"" + (.corrections // [] | join("\" or \"") + "\".")' |
|
||||
while IFS= read -r line; do
|
||||
echo "$line"
|
||||
done || true
|
||||
${COMMAND}
|
||||
log "$ ${CMD_NAME} ${ARGS}"
|
||||
${CMD_NAME} ${ARGS} --format json | ${SOURCE_DIR}/format_gh.sh || true
|
||||
${CMD_NAME} ${ARGS}
|
||||
|
|
9
docker/format_gh.sh
Executable file
9
docker/format_gh.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
grep '"type":"typo"' |
|
||||
jq --sort-keys --raw-output '"::warning file=\(.path),line=\(.line_num),col=\(.byte_offset)::\"\(.typo)\" should be \"" + (.corrections // [] | join("\" or \"") + "\".")' |
|
||||
while IFS= read -r line; do
|
||||
echo "$line"
|
||||
done
|
Loading…
Reference in a new issue