From 9834e1f20fe7d0e4cdf5440a188b6e4fb6e9787e Mon Sep 17 00:00:00 2001 From: dann frazier Date: Mon, 4 Aug 2025 12:08:16 -0600 Subject: [PATCH 1/2] scripts: check-for-epoch-bump.sh: Add newline at end of file my editor wants this. Signed-off-by: dann frazier --- scripts/check-for-epoch-bump.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-for-epoch-bump.sh b/scripts/check-for-epoch-bump.sh index ccb0269..f62f4ba 100755 --- a/scripts/check-for-epoch-bump.sh +++ b/scripts/check-for-epoch-bump.sh @@ -36,4 +36,4 @@ for yaml_file in "$@"; do echo "⚠️ Epoch HAS NOT been increased compared to main: $epoch_local <= $epoch_main" fi -done \ No newline at end of file +done From cc211ba4187bf2b06f198073bd01db58733d4685 Mon Sep 17 00:00:00 2001 From: dann frazier Date: Mon, 4 Aug 2025 12:08:52 -0600 Subject: [PATCH 2/2] scripts: check-for-epoch-bump.sh: Improve epoch parsing It was failing for me when I had a comment after the epoch. Signed-off-by: dann frazier --- scripts/check-for-epoch-bump.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/check-for-epoch-bump.sh b/scripts/check-for-epoch-bump.sh index f62f4ba..13101c1 100755 --- a/scripts/check-for-epoch-bump.sh +++ b/scripts/check-for-epoch-bump.sh @@ -10,11 +10,21 @@ if [ "$#" -lt 1 ]; then exit 1 fi +epoch_grep() { + grep -E '^[[:space:]]+epoch:' +} + +epoch_sed() { + sed -r 's/^[[:space:]]+epoch:[[:space:]]+([0-9])+/\1/' +} + for yaml_file in "$@"; do echo "Checking $yaml_file:" # Extract the epoch from the current file using grep and sed - epoch_local=$(grep -E '^[[:space:]]*epoch:' "$yaml_file" | sed 's/.*epoch:[[:space:]]*//') + # (not assuming `yq` is available) + epoch_line="$(epoch_grep < "$yaml_file")" + epoch_local="$(echo "$epoch_line" | epoch_sed)" if [ -z "$epoch_local" ]; then echo "Warning: 'epoch' field not found in $yaml_file" echo "" @@ -22,7 +32,8 @@ for yaml_file in "$@"; do fi # Extract the epoch from the file on the main branch using git show - epoch_main=$(git show main:"$yaml_file" 2>/dev/null | grep -E '^[[:space:]]*epoch:' | sed 's/.*epoch:[[:space:]]*//') + epoch_main_line="$(git show main:"$yaml_file" 2>/dev/null | epoch_grep)" + epoch_main="$(echo "$epoch_main_line" | epoch_sed)" if [ -z "$epoch_main" ]; then echo "Warning: 'epoch' field not found in $yaml_file on branch 'main'" echo ""