Skip to content

Commit

Permalink
Makefile: ensure redact_safe.md generation is stable
Browse files Browse the repository at this point in the history
On some platforms, the default behavior of `git grep` is to number
the lines (i.e. `-n` is implicitly added).

This patch makes the `-n` explicit and tweaks the sed patterns to
ensure that the behavior is stable.

Release note: None
  • Loading branch information
knz committed Jun 15, 2020
1 parent 9a38931 commit 8f65201
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1532,13 +1532,13 @@ bin/.docgen_functions: bin/docgen

docs/generated/redact_safe.md:
@(echo "The following types are considered always safe for reporting:"; echo; \
echo "File | Type"; echo "--|--") >$@.tmp
@git grep '^func \(.*\) SafeValue\(\)' | \
echo "File | Type"; echo "--|--") >$@.tmp || { rm -f $@.tmp; exit 1; }
@git grep -n '^func \(.*\) SafeValue\(\)' | \
grep -v '^pkg/util/redact' | \
sed -E -e 's/^([^:]*):func \(([^ ]* )?(.*)\) SafeValue.*$$/\1 | \`\3\`/g' >>$@.tmp || rm -f $@.tmp
@git grep 'redact\.RegisterSafeType' | \
sed -E -e 's/^([^:]*):[0-9]+:func \(([^ ]* )?(.*)\) SafeValue.*$$/\1 | \`\3\`/g' >>$@.tmp || { rm -f $@.tmp; exit 1; }
@git grep -n 'redact\.RegisterSafeType' | \
grep -v '^pkg/util/redact' | \
sed -E -e 's/^([^:]*):.*redact\.RegisterSafeType\((.*)\).*/\1 | \`\2\`/g' >>$@.tmp || rm -f $@.tmp
sed -E -e 's/^([^:]*):[0-9]+:.*redact\.RegisterSafeType\((.*)\).*/\1 | \`\2\`/g' >>$@.tmp || { rm -f $@.tmp; exit 1; }
@mv -f $@.tmp $@

settings-doc-gen := $(if $(filter buildshort,$(MAKECMDGOALS)),$(COCKROACHSHORT),$(COCKROACH))
Expand Down

0 comments on commit 8f65201

Please sign in to comment.