Han-Wen Nienhuys | bf1a11f | 2018-08-07 14:51:08 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='remote messages are colorized on the client' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'setup' ' |
| 8 | mkdir .git/hooks && |
| 9 | write_script .git/hooks/update <<-\EOF && |
| 10 | echo error: error |
| 11 | echo ERROR: also highlighted |
| 12 | echo hint: hint |
| 13 | echo hinting: not highlighted |
| 14 | echo success: success |
| 15 | echo warning: warning |
| 16 | echo prefixerror: error |
| 17 | echo " " "error: leading space" |
Junio C Hamano | 59a255a | 2018-08-18 09:16:28 -0700 | [diff] [blame] | 18 | echo " " |
| 19 | echo Err |
Stefan Beller | 1f67290 | 2018-12-03 14:37:13 -0800 | [diff] [blame] | 20 | echo SUCCESS |
Han-Wen Nienhuys | bf1a11f | 2018-08-07 14:51:08 +0200 | [diff] [blame] | 21 | exit 0 |
| 22 | EOF |
| 23 | echo 1 >file && |
| 24 | git add file && |
| 25 | git commit -m 1 && |
| 26 | git clone . child && |
| 27 | ( |
| 28 | cd child && |
| 29 | test_commit message2 file content2 |
| 30 | ) |
| 31 | ' |
| 32 | |
| 33 | test_expect_success 'keywords' ' |
| 34 | git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/keywords 2>output && |
| 35 | test_decode_color <output >decoded && |
| 36 | grep "<BOLD;RED>error<RESET>: error" decoded && |
| 37 | grep "<YELLOW>hint<RESET>:" decoded && |
| 38 | grep "<BOLD;GREEN>success<RESET>:" decoded && |
Stefan Beller | 1f67290 | 2018-12-03 14:37:13 -0800 | [diff] [blame] | 39 | grep "<BOLD;GREEN>SUCCESS<RESET>" decoded && |
Han-Wen Nienhuys | bf1a11f | 2018-08-07 14:51:08 +0200 | [diff] [blame] | 40 | grep "<BOLD;YELLOW>warning<RESET>:" decoded |
| 41 | ' |
| 42 | |
| 43 | test_expect_success 'whole words at line start' ' |
| 44 | git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/whole-words 2>output && |
| 45 | test_decode_color <output >decoded && |
| 46 | grep "<YELLOW>hint<RESET>:" decoded && |
| 47 | grep "hinting: not highlighted" decoded && |
| 48 | grep "prefixerror: error" decoded |
| 49 | ' |
| 50 | |
Junio C Hamano | 59a255a | 2018-08-18 09:16:28 -0700 | [diff] [blame] | 51 | test_expect_success 'short line' ' |
| 52 | git -C child -c color.remote=always push -f origin HEAD:short-line 2>output && |
| 53 | test_decode_color <output >decoded && |
| 54 | grep "remote: Err" decoded |
| 55 | ' |
| 56 | |
Han-Wen Nienhuys | bf1a11f | 2018-08-07 14:51:08 +0200 | [diff] [blame] | 57 | test_expect_success 'case-insensitive' ' |
| 58 | git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/case-insensitive 2>output && |
| 59 | cat output && |
| 60 | test_decode_color <output >decoded && |
| 61 | grep "<BOLD;RED>error<RESET>: error" decoded && |
| 62 | grep "<BOLD;RED>ERROR<RESET>: also highlighted" decoded |
| 63 | ' |
| 64 | |
| 65 | test_expect_success 'leading space' ' |
| 66 | git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/leading-space 2>output && cat output && |
| 67 | test_decode_color <output >decoded && |
| 68 | grep " <BOLD;RED>error<RESET>: leading space" decoded |
| 69 | ' |
| 70 | |
Junio C Hamano | 59a255a | 2018-08-18 09:16:28 -0700 | [diff] [blame] | 71 | test_expect_success 'spaces only' ' |
| 72 | git -C child -c color.remote=always push -f origin HEAD:only-space 2>output && |
| 73 | test_decode_color <output >decoded && |
| 74 | grep "remote: " decoded |
| 75 | ' |
| 76 | |
Han-Wen Nienhuys | bf1a11f | 2018-08-07 14:51:08 +0200 | [diff] [blame] | 77 | test_expect_success 'no coloring for redirected output' ' |
| 78 | git --git-dir child/.git push -f origin HEAD:refs/heads/redirected-output 2>output && |
| 79 | test_decode_color <output >decoded && |
| 80 | grep "error: error" decoded |
| 81 | ' |
| 82 | |
| 83 | test_expect_success 'push with customized color' ' |
| 84 | git --git-dir child/.git -c color.remote=always -c color.remote.error=blue push -f origin HEAD:refs/heads/customized-color 2>output && |
| 85 | test_decode_color <output >decoded && |
| 86 | grep "<BLUE>error<RESET>:" decoded && |
| 87 | grep "<BOLD;GREEN>success<RESET>:" decoded |
| 88 | ' |
| 89 | |
| 90 | |
| 91 | test_expect_success 'error in customized color' ' |
| 92 | git --git-dir child/.git -c color.remote=always -c color.remote.error=i-am-not-a-color push -f origin HEAD:refs/heads/error-customized-color 2>output && |
| 93 | test_decode_color <output >decoded && |
| 94 | grep "<BOLD;GREEN>success<RESET>:" decoded |
| 95 | ' |
| 96 | |
| 97 | test_expect_success 'fallback to color.ui' ' |
| 98 | git --git-dir child/.git -c color.ui=always push -f origin HEAD:refs/heads/fallback-color-ui 2>output && |
| 99 | test_decode_color <output >decoded && |
| 100 | grep "<BOLD;RED>error<RESET>: error" decoded |
| 101 | ' |
| 102 | |
| 103 | test_done |