Skip to content

Commit 6461040

Browse files
committed
do not rely on default maxdepth in mdtoc
1 parent b80885b commit 6461040

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

hack/diff-toc-vs-template.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,29 @@ base="$(git rev-parse --verify "${base}")"
8181

8282
echo "base: $base target: $target"
8383

84+
readonly template_readme='keps/NNNN-kep-template/README.md'
85+
8486
# get TOC for template
85-
template_toc=$(mdtoc 'keps/NNNN-kep-template/README.md')
87+
readonly mdtoc_options=(
88+
# make sure to include all headings for this purpose even if we
89+
# wouldn't surface them in the checked-in toc in update-toc.sh
90+
'--max-depth' '100'
91+
)
92+
template_toc=$(mdtoc "${mdtoc_options[@]}" "${template_readme}")
8693

8794
result=0
8895
# get KEP README files changed in the diff
8996
kep_readmes=()
9097
while IFS= read -r changed_file
9198
do
9299
# make sure to ignore the template kep itself, we don't want to self-diff
93-
if [[ "$changed_file" == "keps"*"README.md" ]] && [[ "$changed_file" != "keps/NNNN-kep-template/README.md" ]]; then
94-
kep_readmes+=("$changed_file")
100+
if [[ "${changed_file}" == "keps"*"README.md" ]] && [[ "${changed_file}" != "${template_readme}" ]]; then
101+
kep_readmes+=("${changed_file}")
95102
fi
96103
done < <(git diff-tree --no-commit-id --name-only -r "${base}".."${target}")
97104

98105
for kep_readme in "${kep_readmes[@]}"; do
99-
kep_toc=$(mdtoc "${kep_readme}")
106+
kep_toc=$(mdtoc "${mdtoc_options[@]}" "${kep_readme}")
100107
echo >&2 "Diffing table of contents for $kep_readme:"
101108
# diff only removals versus the template
102109
# we don't care about _additional_ headings in the KEP

0 commit comments

Comments
 (0)