diff --git a/.editorconfig b/.editorconfig index 478b03e9..892334f8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 \ No newline at end of file +indent_style = space +insert_final_newline = true + +[*.sh] +indent_size = 4 +indent_style = space + +[*.patch] +insert_final_newline = false diff --git a/.github/workflows/update-patches-doc.yaml b/.github/workflows/update-patches-doc.yaml index f3f7275a..c3b7f889 100644 --- a/.github/workflows/update-patches-doc.yaml +++ b/.github/workflows/update-patches-doc.yaml @@ -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 diff --git a/tools/extract-all-patch-data.sh b/tools/extract-all-patch-data.sh index 2a43f4aa..82b52acd 100644 --- a/tools/extract-all-patch-data.sh +++ b/tools/extract-all-patch-data.sh @@ -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" diff --git a/tools/extract-patch-data.sh b/tools/extract-patch-data.sh index 4823313d..d14eb118 100644 --- a/tools/extract-patch-data.sh +++ b/tools/extract-patch-data.sh @@ -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+="
" 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**" \ - "
"$DATE"" \ - "
File: [$(basename $PATCH)](/build/patches/$(basename $PATCH))" \ - "
Author: "$FROM"" \ - "
Context: "$CONTEXT"" \ - "
License: "$LICENSE"" \ - "|"$MESSAGE"|" -) + "
$DATE" \ + "
File: [$FILENAME](/build/patches/$FILENAME)" \ + "
Author: $FROM" \ + "
License: $LICENSE" \ + "|$MESSAGE|"