mirror of
https://github.com/git/git.git
synced 2024-11-27 20:14:30 +08:00
b3b18d1621
Currently it's very easy for the advice library's callers to miss checking the visibility step before printing an advice. Also, it makes more sense for this step to be handled by the advice library. Add a new advise_if_enabled function that checks the visibility of advice messages before printing. Add a new helper advise_enabled to check the visibility of the advice if the caller needs to carry out complicated processing based on that value. A list of advice_settings is added to cache the config variables names and values, it's intended to replace advice_config[] and the global variables once we migrate all the callers to use the new APIs. Signed-off-by: Heba Waly <heba.waly@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
33 lines
954 B
Bash
Executable File
33 lines
954 B
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='Test advise_if_enabled functionality'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'advice should be printed when config variable is unset' '
|
|
cat >expect <<-\EOF &&
|
|
hint: This is a piece of advice
|
|
hint: Disable this message with "git config advice.nestedTag false"
|
|
EOF
|
|
test-tool advise "This is a piece of advice" 2>actual &&
|
|
test_i18ncmp expect actual
|
|
'
|
|
|
|
test_expect_success 'advice should be printed when config variable is set to true' '
|
|
cat >expect <<-\EOF &&
|
|
hint: This is a piece of advice
|
|
hint: Disable this message with "git config advice.nestedTag false"
|
|
EOF
|
|
test_config advice.nestedTag true &&
|
|
test-tool advise "This is a piece of advice" 2>actual &&
|
|
test_i18ncmp expect actual
|
|
'
|
|
|
|
test_expect_success 'advice should not be printed when config variable is set to false' '
|
|
test_config advice.nestedTag false &&
|
|
test-tool advise "This is a piece of advice" 2>actual &&
|
|
test_must_be_empty actual
|
|
'
|
|
|
|
test_done
|