From 915b115fbe19bc65766ee8b8a213e0e52f1479d1 Mon Sep 17 00:00:00 2001 From: uazo <29201891+uazo@users.noreply.github.com> Date: Sat, 15 Jun 2024 06:37:19 -0100 Subject: [PATCH] Revert "CI: rework the patch-doc script and workflow" --- .editorconfig | 18 +++------- .github/workflows/update-patches-doc.yaml | 16 ++++++++- tools/extract-all-patch-data.sh | 22 ++++++------ tools/extract-patch-data.sh | 42 +++++++++++++++-------- 4 files changed, 56 insertions(+), 42 deletions(-) diff --git a/.editorconfig b/.editorconfig index 892334f8..478b03e9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,15 +1,5 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf +[*.{yaml,sh,gn_args}] +tab_width = 2 indent_size = 2 -indent_style = space -insert_final_newline = true - -[*.sh] -indent_size = 4 -indent_style = space - -[*.patch] -insert_final_newline = false +end_of_line = crlf +indent_style = space \ No newline at end of file diff --git a/.github/workflows/update-patches-doc.yaml b/.github/workflows/update-patches-doc.yaml index c3b7f889..f3f7275a 100644 --- a/.github/workflows/update-patches-doc.yaml +++ b/.github/workflows/update-patches-doc.yaml @@ -32,19 +32,33 @@ 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: | - bash ./tools/extract-all-patch-data.sh ./build/patches + export HOME=$GITHUB_WORKSPACE + + bash ~/cromite/tools/extract-all-patch-data.sh ~/cromite/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 diff --git a/tools/extract-all-patch-data.sh b/tools/extract-all-patch-data.sh index 82b52acd..2a43f4aa 100644 --- a/tools/extract-all-patch-data.sh +++ b/tools/extract-all-patch-data.sh @@ -1,18 +1,16 @@ #!/bin/bash -set -euo pipefail +FOLDER=$1 +SCRIPT_FOLDER="$(dirname "$0")" -SCRIPT_FOLDER="$(realpath "$(dirname "$0")")" -SCRIPT="$SCRIPT_FOLDER/extract-patch-data.sh" +OUTPUT="$SCRIPT_FOLDER"/../docs/PATCHES.md +test -f $OUTPUT && rm $OUTPUT -OUTPUT="$SCRIPT_FOLDER/../docs/PATCHES.md" -rm -f "$OUTPUT" +for filename in "$FOLDER"/*.patch; do + bash $SCRIPT_FOLDER/extract-patch-data.sh $filename >>$OUTPUT +done -pushd "$1" >/dev/null +sort -k1 -t"|" -o $OUTPUT $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" +sed -i '1s/^/| Patch | Message |\n/' $OUTPUT +sed -i '2s/^/|--------|--------|\n/' $OUTPUT diff --git a/tools/extract-patch-data.sh b/tools/extract-patch-data.sh index d14eb118..4823313d 100644 --- a/tools/extract-patch-data.sh +++ b/tools/extract-patch-data.sh @@ -1,31 +1,37 @@ #!/bin/bash -set -euo pipefail +PATCH=$1 +CR=$(printf "\r") -while read -r current_line; do - if [[ $current_line =~ ^Filename:* ]]; then - FILENAME=${current_line:9} - - elif [[ $current_line =~ ^Subject:* ]]; then +cat $PATCH | ( +while read current_line +do + if [[ $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) + LICENSE=`echo ${current_line:9} | cut -d ' ' -f1` + + elif [[ $current_line =~ ^Category:* ]]; then + CATEGORY=`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) + FROM=`echo ${current_line:5} | cut -d ' ' -f1` + + elif [[ $current_line =~ ^Context:* ]]; then + CONTEXT=${current_line:8} elif [[ $current_line =~ ^---* ]]; then break - elif [ -n "$current_line" ]; then - if [ -n "$MESSAGE" ]; then + elif [ ! -z "$current_line" ]; then + if [ ! -z "$MESSAGE" ]; then MESSAGE+="
" fi MESSAGE+=$current_line @@ -37,11 +43,17 @@ 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**" \ - "
$DATE" \ - "
File: [$FILENAME](/build/patches/$FILENAME)" \ - "
Author: $FROM" \ - "
License: $LICENSE" \ - "|$MESSAGE|" + "
"$DATE"" \ + "
File: [$(basename $PATCH)](/build/patches/$(basename $PATCH))" \ + "
Author: "$FROM"" \ + "
Context: "$CONTEXT"" \ + "
License: "$LICENSE"" \ + "|"$MESSAGE"|" +)