Fixed case-insensitive matching... my last commit was pretty dumb

This commit is contained in:
Nathan Broadbent
2013-07-09 20:10:57 +12:00
parent 697a636e10
commit c575f171c2
2 changed files with 6 additions and 5 deletions

View File

@@ -97,9 +97,9 @@ function git_index() {
fi
# Try partial matches
# - string at beginning of project
if [ -z "$base_path" ]; then base_path=$(_git_index_dirs_without_home | \grep -m1 "/$project"); fi
if [ -z "$base_path" ]; then base_path=$(_git_index_dirs_without_home | \grep -m1 -i "/$project"); fi
# - string anywhere in project
if [ -z "$base_path" ]; then base_path=$(_git_index_dirs_without_home | \grep -m1 "$project"); fi
if [ -z "$base_path" ]; then base_path=$(_git_index_dirs_without_home | \grep -m1 -i "$project"); fi
# --------------------
# Go to our base path
if [ -n "$base_path" ]; then
@@ -149,7 +149,7 @@ function _rebuild_git_index() {
IFS=$'\n'
for repo in $(echo -e "$(_find_git_repos)\n$(echo $GIT_REPOS | sed "s/:/\\\\n/g")"); do
echo $(basename $repo | sed "s/ /_/g") $repo
done | sort | cut -d " " -f2- | tr '[A-Z]' '[a-z]' > "$GIT_REPO_DIR/.git_index"
done | sort | cut -d " " -f2- > "$GIT_REPO_DIR/.git_index"
IFS=$' \t\n'
if [ "$1" != "--silent" ]; then

View File

@@ -33,7 +33,7 @@ oneTimeSetUp() {
cd $GIT_REPO_DIR
# Setup test repos in temp repo dir
for repo in github bitbucket source_forge; do
for repo in github bitbucket source_forge TestCaps; do
mkdir $repo; cd $repo; git init; cd - > /dev/null
done
@@ -119,7 +119,7 @@ test_check_git_index() {
}
test_git_index_count() {
assertEquals "9" "$(_git_index_count)"
assertEquals "10" "$(_git_index_count)"
}
test_repo_list() {
@@ -136,6 +136,7 @@ test_git_index_changing_directory() {
git_index "github"; assertEquals "$GIT_REPO_DIR/github" "$PWD"
git_index "github/"; assertEquals "$GIT_REPO_DIR/github" "$PWD"
git_index "bucket"; assertEquals "$GIT_REPO_DIR/bitbucket" "$PWD"
git_index "testcaps"; assertEquals "$GIT_REPO_DIR/TestCaps" "$PWD"
git_index "green_sub"; assertEquals "$GIT_REPO_DIR/submodules_everywhere/very/nested/directory/green_submodule" "$PWD"
git_index "_submod"; assertEquals "$GIT_REPO_DIR/submodules_everywhere/very/nested/directory/blue_submodule" "$PWD"
git_index "test_repo_1"; assertEquals "/tmp/test_repo_1" "$PWD"