Skip to content

Instantly share code, notes, and snippets.

@mkatychev
Last active October 23, 2019 20:12
Show Gist options
  • Save mkatychev/8b81674ed5a92f3c00f2ded89e6fe434 to your computer and use it in GitHub Desktop.
Save mkatychev/8b81674ed5a92f3c00f2ded89e6fe434 to your computer and use it in GitHub Desktop.
Parse A .ignore file for diffing git
#!/usr/bin/env bash
# https://github.com/ggreer/the_silver_searcher/wiki/Advanced-Usage#ignore
# git diff master -- $(diffignore.sh)
DIFFI=''
test -f ".diffignore" || cp ./scripts/.diffignore.base ./.diffignore || exit 1
while read -r ignore;do
if [ -n "$ignore" ] && [[ "${ignore}" != \!* ]] && [[ "$ignore" != \#* ]] ;
then
DIFFI+=" :!${ignore}"
fi
done < .diffignore
echo "$DIFFI"
@mkatychev
Copy link
Author

mkatychev commented Oct 19, 2019

Test .ignore file:

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# any python wheel artifact dirs
**/dist/
**/__init__.py
**/__pycache__/
**/*.egg-info/
**/.pytest_cache/
**/build/

# grpc-web client node_modules
client/web/node_modules

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Pesky macos folder attributes
.DS_Store
# environment files
.env
# GoLand IDE files
.idea
# ctag files
.tags
# ignore binaries folder
bin/
# VS Code files
.vscode/

# vim . src: https://github.com/github/gitignore/commit/aeee031f9295c0ecd6ff285f2551dcb2a8eff8c5
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# emulator data files
.emulators/

vendor/

# don't ignore .kubernetes
!.kubernetes/


# ignore protoc files
*.pb*.go
*_pb2.py
*_pb2.pyi
*_pb2_grpc*.py
*_pb.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment