mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
git-ignore template support. Templates are based in https://github.com/github/gitignore
This commit is contained in:
parent
fac85e1a76
commit
deadcd64a5
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "etc/gitignore"]
|
||||
path = etc/gitignore
|
||||
url = git://github.com/github/gitignore.git
|
||||
|
|
@ -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_.
|
||||
|
|
|
|||
|
|
@ -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
1
etc/gitignore
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 0a41318dba7094f7f97646280a0096e30b6cd596
|
||||
Loading…
Reference in a new issue