forked from tilltheis/utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitignore
executable file
·49 lines (41 loc) · 1.2 KB
/
gitignore
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# Update the local .gitignore from a repository of predefined ignore lists.
# The repository is a clone of git://github.com/github/gitignore and
# the $GITIGNORE_REPO environment variable points to its directory.
if [ -z "$GITIGNORE_REPO" ] ; then
echo '$GITIGNORE_REPO not set'
exit 1
fi
if [ ! -d "$GITIGNORE_REPO" ] ; then
echo '$GITIGNORE_REPO is no directory'
exit 1
fi
if [ -z "$1" ] ; then
echo "description: Update the local .gitignore from a repository of predefined ignore lists."
echo "usage: $0 language"
echo "usage: $0 'list'"
echo "example: $0 Ruby"
echo "example: $0 Global/Eclipse"
echo "example: $0 list"
exit
fi
if [ "$1" = "list" ] ; then
clean_files=""
files="`find "$GITIGNORE_REPO" -name '*.gitignore'`"
for file in $files; do
without_ext=${file%.*}
basename=${without_ext#"$GITIGNORE_REPO/"}
clean_files="$clean_files\n$basename"
done
echo $clean_files | column
exit
fi
infile="$GITIGNORE_REPO/$1.gitignore"
if [ ! -f "$infile" ] ; then
echo "No .gitignore found for $1"
exit 1
fi
outfile='./.gitignore'
echo "# $1\n" >> "$outfile"
cat "$infile" >> "$outfile"
echo "\n" >> "$outfile"