Created
July 23, 2024 11:50
-
-
Save Zash/921ba94de15c7415c57242fb7db26460 to your computer and use it in GitHub Desktop.
git diff yaml with gron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.json diff=gron | |
*.yaml diff=ygron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[core] | |
attributesfile = ~/.gitattributes | |
[diff "gron"] | |
textconv=gron | |
[diff "ygron"] | |
textconv=ygron.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
# Ensure it's a valid yaml file and not a go template | |
if yq4 "$@" >/dev/null 2>/dev/null ; then | |
yq4 --output-format json "$@" | gron | |
else | |
cat "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment