Commit c0650e8c authored by Sören Tempel's avatar Sören Tempel

feat(apkbuild-lint): add check for presence of patch descriptions

Fixes #34
parent 1b13fcd6
Pipeline #19585 passed with stage
in 1 minute and 4 seconds
......@@ -472,3 +472,10 @@ The XSA identifier is not formatted correctly, please check the output string
for the reason why.
Severity: Minor, Certainty: Certain
## missing-patch-description [AL55]
A patch specified in `$sources` is missing a description. The
description should at the very least explain why the patch is necessary.
Severity: Minor, Certainty: Certain
......@@ -345,6 +345,39 @@ missing_default_prepare() {
fi
}
missing_patch_description() {
[ "$SKIP_MISSING_PATCH_DESCRIPTION" ] && return 0
[ "$SKIP_AL55" ] && return 0
ret=0
for i in $source; do
case ${i%::*} in
*.patch)
awk -vAPKBUILD="$apkbuild" '
function desc_check() {
if (NR == 1) {
printf("MP:[AL55]:%s:Patch file %s is missing a description\n",
APKBUILD,
FILENAME)
exit(1)
} else {
exit(0)
}
}
/^--- .*$/ { desc_check() }
/^diff .*$/ { desc_check() }
' "$(dirname "${apkbuild}")/$i"
[ $? -ne 0 ] && ret=1
;;
esac
done
return $ret
}
build_type_not_none() {
[ "$SKIP_BUILD_TYPE_NOT_NONE" ] && return 0
[ "$SKIP_AL56" ] && return 0
......@@ -403,6 +436,7 @@ for apkbuild; do
overwrite_xflags "LDFLAGS" &
overwrite_xflags "GOFLAGS" &
missing_default_prepare &
missing_patch_description &
build_type_not_none &
[ "$options" ] && invalid_option &
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment