Skip to content

Commit 7768dc6

Browse files
committed
Create diff-non-generated script.
1 parent 9f65751 commit 7768dc6

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
"build": "grunt build",
111111
"build:dev": "grunt build --dev",
112112
"dev": "grunt watch --dev",
113+
"diff:non-generated": "sh ./tools/diff-non-generated.sh",
113114
"test": "grunt test",
114115
"watch": "grunt watch",
115116
"grunt": "grunt",
@@ -139,4 +140,4 @@
139140
"sync-gutenberg-packages": "grunt sync-gutenberg-packages",
140141
"postsync-gutenberg-packages": "grunt wp-packages:sync-stable-blocks && grunt build --dev && grunt build"
141142
}
142-
}
143+
}

tools/diff-non-generated.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env sh
2+
3+
# Generate a list of all files not marked as auto-generated, and produce a
4+
# pathspec for the `git diff` command so it skips over them.
5+
#
6+
# Example:
7+
#
8+
# ":!/src/wp-includes/assets/script-loader-packages.min.php" ":!/src/..."
9+
GENERATED=$(cat .gitattributes | grep "diff=generated" | cut -w -f1 | sed 's/^\(.*\)$/":!\1"/g' | paste -sd ' ' -)
10+
11+
# This ENV cannot be passed directly afte the "--", so generate the command.
12+
CMD="git diff --exit-code -- $GENERATED"
13+
14+
eval $CMD

0 commit comments

Comments
 (0)