File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -76,8 +76,14 @@ lint() {
76
76
77
77
# Appends a report generated during the pre-commit hook.
78
78
append_pre_commit_report () {
79
- echo ' ' >> " ${commit_message} "
80
- cat " ${pre_commit_report} " >> " ${commit_message} "
79
+ # Check whether the commit message already contains a report (e.g., as may be the case when amending a commit message; git commit --amend):
80
+ grep -q ' type: pre_commit_static_analysis_report' " ${commit_message} "
81
+
82
+ # Only append a report if the message doesn't contain an existing report...
83
+ if [[ " $? " -ne 0 ]]; then
84
+ echo ' ' >> " ${commit_message} "
85
+ cat " ${pre_commit_report} " >> " ${commit_message} "
86
+ fi
81
87
return 0
82
88
}
83
89
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ write_to_cache() {
124
124
init_cache_file () {
125
125
touch " ${cache_file} "
126
126
write_to_cache ' ---'
127
- write_to_cache ' type: git_hook_static_analysis_report '
127
+ write_to_cache ' type: pre_commit_static_analysis_report '
128
128
write_to_cache ' description: Results of running static analysis checks when committing changes.'
129
129
write_to_cache ' report:'
130
130
}
You can’t perform that action at this time.
0 commit comments