From 5561735233fa6e4eb99068321bcddf1af8522444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 31 Jan 2024 09:54:11 -1000 Subject: [PATCH 1/2] Fix the upgrade GitHub action https://github.com/syslog-ng/syslog-ng/pull/4755 added a `name` keyword that cause confusion for our simle script. Ensure we are processing an actual `{"name": "string"}` and not somthing like `{"name": {...}}` to find keywords. --- generate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate b/generate index ddad3f4..4be73aa 100755 --- a/generate +++ b/generate @@ -16,7 +16,7 @@ db = JSON.parse(File.read(ARGV[0])) def find_keywords(hash) keywords = [] hash.each do |key, value| - if key == 'name' && value && !value.start_with?('<') + if key == 'name' && value && value.is_a?(String) && !value.start_with?('<') keywords << value keywords << value.gsub('-', '_') elsif value.is_a?(Hash) From ae1a6495a7dd4afd2cacb5fa4f99b8b175f01702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 31 Jan 2024 10:06:26 -1000 Subject: [PATCH 2/2] Add a more readable diff in the PR description The diff mainly consist in a single long line of keywords where new keywords are added and old keywords may be removed. Reviewing this is a pain. Generate a readable diff in the PR body for easily spotting issues. --- .github/workflows/upgrade.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upgrade.yml b/.github/workflows/upgrade.yml index 9ce0483..6527ccd 100644 --- a/.github/workflows/upgrade.yml +++ b/.github/workflows/upgrade.yml @@ -46,11 +46,20 @@ jobs: if [ $EXISTING_PR -eq 0 ] then TITLE="syslog-ng-cfg-helper: $VERSION" - BODY="Generate from https://pypi.org/project/syslog-ng-cfg-helper/$VERSION" + BODY=$(mktemp) + echo "Generated from https://pypi.org/project/syslog-ng-cfg-helper/$VERSION" > $BODY + echo >> $BODY + echo 'For your convenience, here is a human-readable diff of the change:' >> $BODY + echo '```diff' >> $BODY + set +e + diff -u --label a/syntax/syslog-ng.vim <(git diff syntax/syslog-ng.vim | grep '^-syn keyword' | tr ' ' '\n' | tail -n +3) \ + --label b/syntax/syslog-ng.vim <(git diff syntax/syslog-ng.vim | grep '^+syn keyword' | tr ' ' '\n' | tail -n +3) >> $BODY + set -e + echo '```' >> $BODY git switch -c "$BRANCH" git commit -a -s -m "$TITLE" git push --force origin "$BRANCH" - gh pr create --title "$TITLE" --body "$BODY" + gh pr create --title "$TITLE" --body-file "$BODY" else echo "Pull Request already exists" fi