Skip to content

Commit

Permalink
Update clamp-changelog-entry-date
Browse files Browse the repository at this point in the history
  • Loading branch information
egbedo authored Oct 21, 2024
1 parent 58dcd67 commit 0bd1bb9
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@

CHANGELOG_PATH="$1"

CHANGELOG_PATH="$1"

if [ ! -r "$CHANGELOG_PATH" ]; then
echo "Changelog file '$CHANGELOG_PATH' inaccessible!" >&2
exit 1
fi

# Get previous date from the changelog
#PREVIOUS_DATE=$(grep '^ --' "$CHANGELOG_PATH" | head -n 2 | tail -n 1 | grep -o ' .*')

# Use SOURCE_DATE_EPOCH if available; otherwise, use PREVIOUS_DATE
CURRENT_DATE=$(date -u -d "@${SOURCE_DATE_EPOCH:-$PREVIOUS_DATE}" +"%Y-%m-%d %H:%M:%S")
# If PREVIOUS_DATE is not needed, remove this line:
# PREVIOUS_DATE=$(grep '^ --' "$CHANGELOG_PATH" | head -n 2 | tail -n 1 | grep -o ' .*')

# Replace the topmost date with CURRENT_DATE
sed -e "0,/^ --/s/^\( --.*\)\( .*\)/\1$CURRENT_DATE/" -i "$CHANGELOG_PATH"
touch --date="$CURRENT_DATE" "$CHANGELOG_PATH"

0 comments on commit 0bd1bb9

Please sign in to comment.