git-ignore template support. Templates are based in https://github.com/github/gitignore

This commit is contained in:
Jonhnny Weslley 2010-11-09 12:03:31 -03:00
parent fac85e1a76
commit deadcd64a5
4 changed files with 26 additions and 1 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "etc/gitignore"]
path = etc/gitignore
url = git://github.com/github/gitignore.git

View file

@ -178,6 +178,9 @@ of commits included in the commitish:
*.o
*.log
Adding patterns from an existing template:
$ git ignore -t rails
## git-delete-branch <name>
Deletes local and remote branch _name_.

View file

@ -1,7 +1,25 @@
#!/bin/sh
template=""
while getopts "t:" opt; do
case "$opt" in
t) template=$OPTARG;shift;shift;;
esac
done
if [ ! -z "$template" ]; then
gitignoredir="`dirname $0`/../etc/gitignore"
selected_template=$(find $gitignoredir -type f -name *.gitignore | xargs -i basename {} .gitignore | grep -i $template)
count=$(echo $selected_template | wc -w)
case "$count" in
0) echo "The pattern '$template' does not match any available templates." && exit 1;;
1) find $gitignoredir -name $selected_template.gitignore -exec cat {} \; >> .gitignore && echo "... added patterns from template '$selected_template'";;
*) echo "Be more specific. $count macthes found:\n$selected_template" && exit 2;;
esac
fi
if test $# -eq 0; then
test -f .gitignore && cat .gitignore
test -z $template && test -f .gitignore && cat .gitignore
else
for pattern in $@; do
echo $pattern >> .gitignore

1
etc/gitignore Submodule

@ -0,0 +1 @@
Subproject commit 0a41318dba7094f7f97646280a0096e30b6cd596