| 1 |
#!/usr/bin/env bash |
| 2 |
# |
| 3 |
# Copyright 2025 The Fuchsia Authors |
| 4 |
# |
| 5 |
# Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| 6 |
# <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT |
| 7 |
# license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. |
| 8 |
# This file may not be copied, modified, or distributed except according to |
| 9 |
# those terms. |
| 10 |
|
| 11 |
set -euo pipefail |
| 12 |
|
| 13 |
# This allows us to leave XODO comments in this file and have them still be |
| 14 |
# picked up by this script without having the script itself trigger false |
| 15 |
# positives. The alternative would be to exclude this script entirely, which |
| 16 |
# would mean that we couldn't use XODO comments in this script. |
| 17 |
KEYWORD=$(echo XODO | sed -e 's/X/T/') |
| 18 |
|
| 19 |
# Make sure `rg` is installed (if this fails, `set -e` above will cause the |
| 20 |
# script to exit). |
| 21 |
rg --version >/dev/null |
| 22 |
|
| 23 |
# -H: Print filename (default for multiple files/recursive) |
| 24 |
# -n: Print line number |
| 25 |
# -w: Match whole words |
| 26 |
output=$(rg -H -n -w "$KEYWORD" || true) |
| 27 |
|
| 28 |
if [ -n "$output" ]; then |
| 29 |
echo "Found $KEYWORD markers in the codebase." >&2 |
| 30 |
echo "$KEYWORD is used for tasks that should be done before merging a PR; if you want to leave a message in the codebase, use FIXME." >&2 |
| 31 |
echo "" >&2 |
| 32 |
echo "$output" >&2 |
| 33 |
exit 1 |
| 34 |
fi |