Add new filter to smudge/clean usernames from info scripts
This commit is contained in:
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
cluster_info.json filter=username
|
5
dev/git-filter-clean-username.sh
Executable file
5
dev/git-filter-clean-username.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Git filter to replace $USER with USERNAME.
|
||||
# Assigned to cluster_info files in .gitattributes
|
||||
sed -e "s/$USER/USERNAME/g"
|
||||
|
4
dev/git-filter-smudge-username.sh
Executable file
4
dev/git-filter-smudge-username.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
# Git filter to replace USERNAME with $USER.
|
||||
# Assigned to cluster_info files in .gitattributes
|
||||
sed -e "s/USERNAME/$USER/g"
|
19
dev/install_filters.sh
Executable file
19
dev/install_filters.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# Installs filters for this repository
|
||||
|
||||
# Should be run from
|
||||
ROOT="$(git rev-parse --show-toplevel)"
|
||||
cd "$ROOT"
|
||||
|
||||
# username filter, for automaticly removing usernames from checkins
|
||||
git config filter.username.smudge dev/git-filter-smudge-username.sh
|
||||
git config filter.username.clean dev/git-filter-clean-username.sh
|
||||
|
||||
# pre-commit hook to varify usernames aren't committed
|
||||
if [ -f .git/hooks/pre-commit ]; then
|
||||
if ! cmp -s .git/hooks/pre-commit dev/pre-commit; then
|
||||
echo "ERROR: $ROOT/.git/hooks/pre-commit exists; skipping hook" >&2
|
||||
fi
|
||||
else
|
||||
ln -s ../../dev/pre-commit .git/hooks/pre-commit
|
||||
fi
|
18
dev/pre-commit
Executable file
18
dev/pre-commit
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# A hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
# Make sure I don't check in my username
|
||||
bad_files="$( git grep --cached -l $USER */cluster_info.json)"
|
||||
if [ -n "$bad_files" ]; then
|
||||
echo "Error: Committing your username in"
|
||||
echo "$bad_files"
|
||||
exit 1
|
||||
fi
|
||||
|
Reference in New Issue
Block a user