From c575f171c2ba066c62f80ebd993ac9c5e4655215 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Tue, 9 Jul 2013 20:10:57 +1200 Subject: [PATCH] Fixed case-insensitive matching... my last commit was pretty dumb --- lib/git/repo_index.sh | 6 +++--- test/lib/git/repo_index_test.sh | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/git/repo_index.sh b/lib/git/repo_index.sh index 1a7bb62..ce5f37e 100644 --- a/lib/git/repo_index.sh +++ b/lib/git/repo_index.sh @@ -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 diff --git a/test/lib/git/repo_index_test.sh b/test/lib/git/repo_index_test.sh index c44f77c..d2afa8e 100755 --- a/test/lib/git/repo_index_test.sh +++ b/test/lib/git/repo_index_test.sh @@ -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"