Skip to content

Commit 0443365

Browse files
Merge pull request #1116 from dhellmann/template-lint-new-files-only
lint: only apply template lint rules to new files
2 parents d91cb37 + de85a28 commit 0443365

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

hack/find_new.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# Find the enhancements files that are new in the current PR.
4+
5+
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
7+
set -o errexit
8+
set -o pipefail
9+
10+
FILELIST=/tmp/$$.filelist
11+
git ls-tree --name-only -r "${PULL_BASE_SHA:-origin/master}" enhancements > $FILELIST
12+
13+
for f in $(${SCRIPTDIR}/find_changed.sh); do
14+
if ! grep -q $f $FILELIST; then
15+
echo $f
16+
fi
17+
done

hack/metadata-lint.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22

3-
set -x
4-
53
# Ensure the enhancement metadata includes the required information
64

75
set -o errexit
@@ -15,8 +13,11 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1513
# incompatible with existing documents.
1614
CHANGED_FILES=$(${SCRIPTDIR}/find_changed.sh)
1715

18-
if [ -n "$CHANGED_FILES" ]; then
19-
(cd tools && go build -o ../enhancement-tool -mod=mod ./main.go)
20-
21-
./enhancement-tool metadata-lint ${CHANGED_FILES}
16+
if [ -z "$CHANGED_FILES" ]; then
17+
echo "OK, no changed enhancements found"
18+
exit 0
2219
fi
20+
21+
(cd tools && go build -o ../enhancement-tool -mod=mod ./main.go)
22+
23+
./enhancement-tool metadata-lint ${CHANGED_FILES}

hack/template-lint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ TEMPLATE=${SCRIPTDIR}/../guidelines/enhancement_template.md
1414
# We only look at the files that have changed in the current PR, to
1515
# avoid problems when the template is changed in a way that is
1616
# incompatible with existing documents.
17-
CHANGED_FILES=$(${SCRIPTDIR}/find_changed.sh)
17+
NEW_FILES=$(${SCRIPTDIR}/find_new.sh)
18+
19+
if [ -z "$NEW_FILES" ]; then
20+
echo "OK, no new enhancement files found"
21+
exit 0
22+
fi
1823

1924
RC=0
20-
for file in $CHANGED_FILES
25+
for file in $NEW_FILES
2126
do
2227
echo "Checking ${file}"
2328

0 commit comments

Comments
 (0)