Browse code

fix regression and improve .gitignore append routine

Nat! authored on 09-10-2016 16:08:24
Showing 3 changed files
... ...
@@ -1068,27 +1068,44 @@ append_dir_to_gitignore_if_needed()
1068 1068
 
1069 1069
    local directory
1070 1070
 
1071
-   # make it absolute dir for git
1071
+   # make it absolute dir for git -> '/' <subdir> '/'
1072 1072
 
1073 1073
    case "$1" in
1074 1074
       /*/)
1075 1075
          directory="$1"
1076 1076
       ;;
1077
+
1077 1078
       /*)
1078 1079
          directory="$1/"
1079 1080
       ;;
1081
+
1080 1082
       */)
1081 1083
          directory="/$1"
1082 1084
       ;;
1085
+
1083 1086
       *)
1084 1087
          directory="/$1/"
1085 1088
       ;;
1086 1089
    esac
1087 1090
 
1088
-   fgrep -s -x "${directory}" .gitignore > /dev/null 2>&1
1091
+   local pattern1
1092
+   local pattern2
1093
+   local pattern3
1094
+
1095
+   # also match without trailing slash
1096
+   pattern1="`echo "${directory}" | sed 's|\(.*\)/$|\1|'`"
1097
+
1098
+   # also match without leading slash
1099
+   pattern2="`echo "${directory}" | sed 's|^/\(.*\)|\1|'`"
1100
+
1101
+   # also match without leading or trailing slash
1102
+   pattern3="`echo "${pattern1}"  | sed 's|^/\(.*\)|\1|'`"
1103
+
1104
+   fgrep -s -x -e "${directory}" -e "${pattern1}" -e "${pattern2}" -e "${pattern3}" .gitignore > /dev/null 2>&1
1105
+
1089 1106
    if [ $? -ne 0 ]
1090 1107
    then
1091
-      redirect_exekutor .gitignore echo "${directory}"  || fail "Couldn\'t append to .gitignore"
1108
+      redirect_append_exekutor .gitignore echo "${directory}" || fail "Couldn\'t append to .gitignore"
1092 1109
       log_info "Added \"${directory}\" to \".gitignore\""
1093 1110
    fi
1094 1111
 }
... ...
@@ -263,7 +263,7 @@ git_main()
263 263
    then
264 264
       log_fluff "Will git $* clones " >&2
265 265
    else
266
-      log_info "There is nothing to run git over."
266
+      log_verbose "There is nothing to run git over."
267 267
       return 0
268 268
    fi
269 269
 
... ...
@@ -233,7 +233,7 @@ tag_main()
233 233
    then
234 234
       log_fluff "Will ${TAG_OPERATION} clones with ${TAG}"
235 235
    else
236
-      log_info "There is nothing to tag."
236
+      log_verbose "There is nothing to tag."
237 237
       return 0
238 238
    fi
239 239