Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions scripts/check-for-epoch-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,30 @@ 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 ""
continue
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 ""
Expand All @@ -36,4 +47,4 @@ for yaml_file in "$@"; do
echo "⚠️ Epoch HAS NOT been increased compared to main: $epoch_local <= $epoch_main"
fi

done
done
Loading