diff --git a/.gitignore b/.gitignore index 46a9763..1aba7f4 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ Build/ Builds/ Logs/ Bin/ +UserSettings/ # erroneous meta files library.meta @@ -32,6 +33,7 @@ Build.meta Builds.meta Logs.meta Bin.meta +UserSettings.meta # Never ignore Asset meta data @@ -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/ @@ -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 @@ -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 @@ -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/* diff --git a/pre-commit b/pre-commit index f452a71..4fae50e 100755 --- a/pre-commit +++ b/pre-commit @@ -110,27 +110,31 @@ 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 @@ -138,11 +142,15 @@ 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