Fix sorting order
This commit is contained in:
@@ -68,8 +68,8 @@ function git_index() {
|
||||
elif [ "$1" = "--list" ] || [ "$1" = "-l" ]; then
|
||||
echo -e "$_bld_col$(_git_index_count)$_txt_col Git repositories in $_bld_col$GIT_REPO_DIR$_txt_col:\n"
|
||||
for repo in $(_git_index_dirs_without_home); do
|
||||
echo $(basename $repo) : $repo
|
||||
done | sort | column -t -s ':'
|
||||
echo $(basename $repo | sed "s/ /_/g") : $repo
|
||||
done | sort -t ":" -k1,1 | column -t -s ':'
|
||||
elif [ "$1" = "--count-by-host" ]; then
|
||||
echo -e "=== Producing a report of the number of repos per host...\n"
|
||||
_git_index_batch_cmd git remote -v | \grep "origin.*(fetch)" |
|
||||
@@ -148,8 +148,8 @@ function _rebuild_git_index() {
|
||||
# Get repos from src dir and custom dirs, then sort by basename
|
||||
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- >| "$GIT_REPO_DIR/.git_index"
|
||||
echo $(basename $repo | sed "s/ /_/g"):$repo
|
||||
done | sort -t ":" -k1,1 | cut -d ":" -f2- >| "$GIT_REPO_DIR/.git_index"
|
||||
unset IFS
|
||||
|
||||
if [ "$1" != "--silent" ]; then
|
||||
|
||||
@@ -94,16 +94,19 @@ test_repo_index_command() {
|
||||
git_index --rebuild > /dev/null
|
||||
|
||||
# Test that all repos are detected, and sorted alphabetically
|
||||
assertIncludes "$(index_no_newlines)" "bitbucket.*\
|
||||
blue_submodule.*\
|
||||
github.*\
|
||||
green_submodule.*\
|
||||
red_submodule.*\
|
||||
source_forge.*\
|
||||
submodules_everywhere.*\
|
||||
test_repo_11.*\
|
||||
test_repo_1"
|
||||
|
||||
assertIncludes "$(index_no_newlines)" $(
|
||||
cat <<EXPECT | sort -t "." -k1,1 | tr --delete '\n' | awk '{print ".*"$1}'
|
||||
bitbucket.*
|
||||
blue_submodule.*
|
||||
github.*
|
||||
green_submodule.*
|
||||
red_submodule.*
|
||||
source_forge.*
|
||||
submodules_everywhere.*
|
||||
test_repo_11.*
|
||||
test_repo_1.*
|
||||
EXPECT
|
||||
)
|
||||
}
|
||||
|
||||
test_check_git_index() {
|
||||
@@ -141,7 +144,7 @@ test_git_index_changing_directory() {
|
||||
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"
|
||||
git_index "test_repo_11"; assertEquals "/tmp/test_repo_11" "$PWD"
|
||||
git_index "test_repo_"; assertEquals "/tmp/test_repo_11" "$PWD"
|
||||
git_index "test_repo_"; assertEquals "/tmp/test_repo_1" "$PWD"
|
||||
git_index "github/videos/octocat/live_action"; assertEquals "$GIT_REPO_DIR/github/videos/octocat/live_action" "$PWD"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user