Skip to content

Commit a74169f

Browse files
committed
feat: add support for appending a static analysis report to commit messages
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 84e20f8 commit a74169f

File tree

2 files changed

+214
-0
lines changed

2 files changed

+214
-0
lines changed

tools/git/hooks/commit-msg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ skip_lint="${SKIP_LINT_COMMIT}"
3333
# Get the path to a file containing the commit message:
3434
commit_message="$1"
3535

36+
# Determine root directory:
37+
root=$(git rev-parse --show-toplevel)
38+
39+
# Define the path to a report generated during the pre-commit hook:
40+
pre_commit_report="${root}/.git/hooks-cache/pre_commit_report.yml"
41+
3642

3743
# FUNCTIONS #
3844

@@ -68,6 +74,13 @@ lint() {
6874
return 0
6975
}
7076

77+
# Appends a report generated during the pre-commit hook.
78+
append_pre_commit_report() {
79+
echo '' >> "${commit_message}"
80+
cat "${pre_commit_report}" >> "${commit_message}"
81+
return 0
82+
}
83+
7184
# Main execution sequence.
7285
main() {
7386
init
@@ -78,6 +91,10 @@ main() {
7891
if [[ "$?" -ne 0 ]]; then
7992
on_error 1
8093
fi
94+
append_pre_commit_report
95+
if [[ "$?" -ne 0 ]]; then
96+
on_error 1
97+
fi
8198
cleanup
8299
exit 0
83100
}

0 commit comments

Comments
 (0)