[TOOLS] rework the patch-doc script and workflow (#1186)

[TOOLS] rework the patch-doc script and workflow
This commit is contained in:
uazo
2024-06-15 05:59:38 -01:00
committed by GitHub
4 changed files with 42 additions and 56 deletions
+14 -4
View File
@@ -1,5 +1,15 @@
[*.{yaml,sh,gn_args}]
tab_width = 2
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
end_of_line = crlf
indent_style = space
indent_style = space
insert_final_newline = true
[*.sh]
indent_size = 4
indent_style = space
[*.patch]
insert_final_newline = false
+1 -15
View File
@@ -32,33 +32,19 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: "Get value from dispatch"
run: |
if [ -z "${RTAG}" ]; then
echo "RTAG=$GITHUB_SHA" >> $GITHUB_ENV
echo "RTAG=$RTAG"
fi
- name: Checkout 'uazo/cromite' ${{ env.BRANCH }}
uses: actions/checkout@v2
with:
repository: 'uazo/cromite'
ref: ${{ github.event.inputs.rtag }}
path: 'cromite'
fetch-depth: 1
- name: Generate patches doc
run: |
export HOME=$GITHUB_WORKSPACE
bash ~/cromite/tools/extract-all-patch-data.sh ~/cromite/build/patches
bash ./tools/extract-all-patch-data.sh ./build/patches
- name: Check differences CHANGES=${{ env.CHANGES }}
run: |
export HOME=$GITHUB_WORKSPACE
cd ~/cromite
CHANGES=0 && git diff --quiet || CHANGES=1
echo "CHANGES=$CHANGES" >> $GITHUB_ENV
+12 -10
View File
@@ -1,16 +1,18 @@
#!/bin/bash
FOLDER=$1
SCRIPT_FOLDER="$(dirname "$0")"
set -euo pipefail
OUTPUT="$SCRIPT_FOLDER"/../docs/PATCHES.md
test -f $OUTPUT && rm $OUTPUT
SCRIPT_FOLDER="$(realpath "$(dirname "$0")")"
SCRIPT="$SCRIPT_FOLDER/extract-patch-data.sh"
for filename in "$FOLDER"/*.patch; do
bash $SCRIPT_FOLDER/extract-patch-data.sh $filename >>$OUTPUT
done
OUTPUT="$SCRIPT_FOLDER/../docs/PATCHES.md"
rm -f "$OUTPUT"
sort -k1 -t"|" -o $OUTPUT $OUTPUT
pushd "$1" >/dev/null
sed -i '1s/^/| Patch | Message |\n/' $OUTPUT
sed -i '2s/^/|--------|--------|\n/' $OUTPUT
for filename in *.patch; do
(echo "Filename: $filename"; cat "$filename") | bash "$SCRIPT"
done | sort -k1 -t"|" -o "$OUTPUT"
sed -i '1s/^/| Patch | Message |\n/' "$OUTPUT"
sed -i '2s/^/|--------|--------|\n/' "$OUTPUT"
+15 -27
View File
@@ -1,37 +1,31 @@
#!/bin/bash
PATCH=$1
CR=$(printf "\r")
set -euo pipefail
cat $PATCH | (
while read current_line
do
if [[ $current_line =~ ^Subject:* ]]; then
while read -r current_line; do
if [[ $current_line =~ ^Filename:* ]]; then
FILENAME=${current_line:9}
elif [[ $current_line =~ ^Subject:* ]]; then
SUBJECT=${current_line:8}
elif [[ $current_line =~ ^Date:* ]]; then
DATE=${current_line:5}
elif [[ $current_line =~ ^License:* ]]; then
LICENSE=`echo ${current_line:9} | cut -d ' ' -f1`
elif [[ $current_line =~ ^Category:* ]]; then
CATEGORY=`echo ${current_line:9} | cut -d ' ' -f1`
LICENSE=$(echo "${current_line:9}" | cut -d ' ' -f1)
elif [[ $current_line =~ ^"Original License:"* ]]; then
continue
elif [[ $current_line =~ ^From:* ]]; then
FROM=`echo ${current_line:5} | cut -d ' ' -f1`
elif [[ $current_line =~ ^Context:* ]]; then
CONTEXT=${current_line:8}
FROM=$(echo "${current_line:5}" | cut -d ' ' -f1)
elif [[ $current_line =~ ^---* ]]; then
break
elif [ ! -z "$current_line" ]; then
if [ ! -z "$MESSAGE" ]; then
elif [ -n "$current_line" ]; then
if [ -n "$MESSAGE" ]; then
MESSAGE+="<br>"
fi
MESSAGE+=$current_line
@@ -43,17 +37,11 @@ done
# echo SUBJECT: $SUBJECT
# echo DATE: $DATE
# echo LICENSE: $LICENSE
# echo CONTEXT: $CONTEXT
# echo CATEGORY: $CATEGORY
# echo -e MESSAGE: $MESSAGE
SUBJECT=`echo $SUBJECT | xargs`
echo "|**$SUBJECT**" \
"<br><sub><nobr>"$DATE"</nobr>" \
"<br>File: [$(basename $PATCH)](/build/patches/$(basename $PATCH))" \
"<br><nobr>Author: "$FROM"</nobr>" \
"<br><nobr>Context: "$CONTEXT"</nobr>" \
"<br><nobr>License: "$LICENSE"</nobr>" \
"|"$MESSAGE"|"
)
"<br><sub><nobr>$DATE</nobr>" \
"<br>File: [$FILENAME](/build/patches/$FILENAME)" \
"<br><nobr>Author: $FROM</nobr>" \
"<br><nobr>License: $LICENSE</nobr>" \
"|$MESSAGE|"