Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Build/
Builds/
Logs/
Bin/
UserSettings/

# erroneous meta files
library.meta
Expand All @@ -32,6 +33,7 @@ Build.meta
Builds.meta
Logs.meta
Bin.meta
UserSettings.meta


# Never ignore Asset meta data
Expand All @@ -47,7 +49,7 @@ assets/Plugins/Editor/JetBrains/*
# comment these out if you wish to commit the asset store tools plugins
assets/AssetStoreTools*
Assets/AssetStoreTools*
AssetStoreTools.meta
AssetStoreTools*.meta

# Visual Studio cache directory
.vs/
Expand All @@ -58,14 +60,18 @@ AssetStoreTools.meta

#maya intermediate files
**/incrementalSave/
incrementalSave.meta

# wwise intermediate files
**/.cache/
.cache/
*.akd
*.akd.meta

# fmod autogen files
fmod.log
fmod.log.meta
fmod_editor.log
fmod_editor.log.meta
**/FMODStudioCache.asset
**/FMODStudioCache.asset.meta
**/FMODStudioSettings.asset
Expand All @@ -79,24 +85,41 @@ fmod_editor.log

# Autogenerated VS MD Consulo solution and project files
ExportedObj/
ExportedObj.meta
.consulo/
*.csproj
*.csproj.meta
*.unityproj
*.unityproj.meta
*.sln
*.sln.meta
*.suo
*.suo.meta
*.tmp
*.tmp.meta
*.user
*.user.meta
*.userprefs
*.userprefs.meta
*.pidb
*.pidb.meta
*.booproj
*.booproj.meta
*.svd
*.svd.meta
*.pdb
*.pdb.meta
*.mdb
*.mdb.meta
*.opendb
*.opendb.meta
*.VC.db
*.VC.db.meta
*Resharper*
*ReSharper*
*.orig
# Corner case on the .gitignore validation
*.orig.meta
*.orig.*

# Unity3D generated meta files
Expand Down Expand Up @@ -133,7 +156,11 @@ crashlytics-build.properties
.Spotlight-V100
.Trashes
Icon?
Icon?.meta
Thumbs.db
Thumbs.db.meta
Desktop.ini
Desktop.ini.meta
ehthumbs.db
ehthumbs.db.meta
Local/*
28 changes: 18 additions & 10 deletions pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -110,39 +110,47 @@ if [ "$ret" != 0 ]; then
exit "$ret"
fi

## Check if changes to .gitignore include corresponding meta files.
# check if staged files contain .gitignore
if [ ! `git diff --name-only --cached | grep -- "\.gitignore"` ]; then
# avoid expensive diff actions if there is no change in .gitignore
exit 0
fi

# new lines have the format {+xxxxx+}
raw_diff_output=`git diff --cached --word-diff=plain .gitignore | egrep "\{\+.*\+\}"`
# new lines have the format {+xxxxx+}. Ignore comments
raw_diff_output=`git diff --cached --word-diff=plain .gitignore | egrep -x "\{\+[^#.].*[^*]\+\}"`

# prepare two strings: on for directories and one for meta files
# prepare two strings: one for directories and one for meta files
IFS=$'\n'
declare -a diff_output_dirs
declare -a diff_output_metas
for raw_entry in $raw_diff_output; do
# strip leading and trailing separator "{+" and "+}"
if ((${#raw_entry} <= 4)); then
continue
else
e=${raw_entry:2:$((${#raw_entry}-4))}
e="${raw_entry:2:$((${#raw_entry}-4))}"
is_meta=$((`echo $e | egrep ".*meta" | wc -l`))
if [ $is_meta -eq 0 ]; then
diff_output_dirs="${diff_output_dirs} ${e}"
diff_output_dirs+=("${e}")
else
diff_output_metas="${diff_output_metas} ${e}"
diff_output_metas+=("${e}")
fi
fi
done

# iterate over directories and check if there is an entry for the appropriate meta file
for i in $diff_output_dirs; do
# meta file entries are often without directory, so strip the path
dir_name=`echo $i | egrep -o "/[^/]+$" | cut -d / -f 2`
echo $dir_name
has_meta_ignore=$((`echo $diff_output_metas | grep -- "$dir_name.meta" | wc -l`))
base_name=`basename $i`
echo "$i"
has_meta_ignore=$((`echo $diff_output_metas | grep -F -- "$base_name.meta" | wc -l`))
if [ ${has_meta_ignore} -eq 0 ]; then
echo "$dir_name found in .gitignore but not the corresponding meta file! Please add ${dir_name}.meta to .gitignore"
# Check if the full path name meta is included.
has_meta_ignore=$((`echo $diff_output_metas | grep -F -- "${i%/}.meta" | wc -l`))
fi
if [ ${has_meta_ignore} -eq 0 ]; then
echo "${i} found in .gitignore but not the corresponding meta file! Please add ${i%/}.meta or ${base_name}.meta to .gitignore"
exit 1
fi
done