File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,7 @@ if (git rev-parse --verify HEAD 2>$null) {
1717 $against = " HEAD"
1818}
1919else {
20- # Initial commit: diff against an empty tree object
21- Write-Host " Using empty tree object as the previous commit"
20+ Write-Host " Using an empty tree object as the previous commit"
2221 $against = $ (git hash- object - t tree / dev/ null)
2322}
2423
@@ -29,7 +28,10 @@ foreach ($file in $files) {
2928 # Check if the file contains secrets
3029 $detected = $ (azdev scan -f $file | ConvertFrom-Json ).secrets_detected
3130 if ($detected -eq " True" ) {
32- Write-Host " Detected secrets from $file . You can run 'azdev mask' to remove secrets before commit." - ForegroundColor Red
31+ Write-Host " Detected secrets from $file . Please run the following command to mask it:" - ForegroundColor Red
32+ Write-Host " +++++++++++++++++++++++++++++++++++++++++++++++++++++++" - ForegroundColor Red
33+ Write-Host " azdev mask -f $file " - ForegroundColor Red
34+ Write-Host " +++++++++++++++++++++++++++++++++++++++++++++++++++++++" - ForegroundColor Red
3335 $hasSecrets = 1
3436 }
3537}
Original file line number Diff line number Diff line change 1616 printf " Using HEAD as the previous commit\n"
1717 against=HEAD
1818else
19- printf " Using empty tree object as the previous commit\n"
19+ printf " Using an empty tree object as the previous commit\n"
2020 against=$( git hash-object -t tree /dev/null)
2121fi
2222has_secrets=0
23-
24- IFS_OLD=${IFS}
25- IFS=$' \n '
2623for FILE in ` git diff --cached --name-only --diff-filter=AM $against ` ; do
2724 # Check if the file contains secrets
2825 detected=$( azdev scan -f " $FILE " | python -c " import sys, json; print(json.load(sys.stdin)['secrets_detected'])" )
2926 if [ " $detected " = " True" ]; then
30- printf " \033[0;31mDetected secrets from %s, You can run 'azdev mask' to remove secrets before commit.\033[0m\n" " $FILE "
27+ printf " \033[0;31mDetected secrets from %s, Please run the following command to mask it:\033[0m\n" " $FILE "
28+ printf " \033[0;31m+++++++++++++++++++++++++++++++++++++++++++++++++++++++\033[0m\n"
29+ printf " \033[0;31mazdev mask -f %s\033[0m\n" " $FILE "
30+ printf " \033[0;31m+++++++++++++++++++++++++++++++++++++++++++++++++++++++\033[0m\n"
3131 has_secrets=1
3232 fi
3333done
34- IFS=${IFS_OLD}
3534
3635if [ $has_secrets -eq 1 ]; then
3736 printf " \033[0;31mSecret detected. If you want to skip that, run add '--no-verify' in the end of 'git commit' command.\033[0m\n"
You can’t perform that action at this time.
0 commit comments