Skip to content

Commit

Permalink
feat(governance-tools): Made the output from add-release-to-changelog…
Browse files Browse the repository at this point in the history
… a little better. (#3536)

The most important thing is that the name of the canister is now printed
where it says how long ago the proposal was executed.

Other than that removed some blank lines.
  • Loading branch information
daniel-wong-dfinity-org authored Jan 21, 2025
1 parent ad3140b commit d37cb7b
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions testnet/tools/nns-tools/add-release-to-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ if [[ "${EXECUTED_TIMESTAMP_SECONDS}" -eq 0 ]]; then
print_red "💀 Proposal ${PROPOSAL_ID} exists, but was not successfully executed." >&2
exit 1
fi
SECONDS_AGO=$(($(date +%s) - "${EXECUTED_TIMESTAMP_SECONDS}"))
EXECUTED_ON=$(
date --utc \
--date=@"${EXECUTED_TIMESTAMP_SECONDS}" \
--iso-8601
)
print_cyan "🗳️ Proposal ${PROPOSAL_ID} was executed ${SECONDS_AGO} seconds ago." >&2

# Extract which canister was upgraded, and to what commit.
TITLE=$(echo "${PROPOSAL_INFO}" | jq -r '.proposal[0].title[0]')
Expand All @@ -81,10 +74,16 @@ else
print_red "(In particular, unable to determine which canister and commit.)" >&2
exit 1
fi
SECONDS_AGO=$(($(date +%s) - "${EXECUTED_TIMESTAMP_SECONDS}"))
EXECUTED_ON=$(
date --utc \
--date=@"${EXECUTED_TIMESTAMP_SECONDS}" \
--iso-8601
)
print_cyan "🏃 ${GOVERNANCE_TYPE} ${CANISTER_NAME} proposal was executed ${SECONDS_AGO} seconds ago." >&2

# Fail if the proposal's commit is not checked out.
if [[ $(git rev-parse HEAD) != $DESTINATION_COMMIT_ID* ]]; then
echo >&2
print_red "💀 You currently have $(git rev-parse HEAD)" >&2
print_red "checked out, but this command only supports being run when" >&2
print_red "the proposal's commit (${DESTINATION_COMMIT_ID}) is checked out." >&2
Expand All @@ -102,8 +101,7 @@ cd "${CANISTER_CODE_PATH}"

# Assert that there is a CHANGELOG.md file.
if [[ ! -e CHANGELOG.md ]]; then
echo >&2
print_red "💀 ${CANISTER_NAME} has no CHANGELOG.md file." >&2
print_red "💀 ${GOVERNANCE_TYPE} ${CANISTER_NAME} has no CHANGELOG.md file." >&2
exit 1
fi
# TODO: Also verify that unreleased_changelog.md exists.
Expand All @@ -116,8 +114,7 @@ NEW_FEATURES_AND_FIXES=$(
| filter_out_empty_markdown_sections
)
if [[ -z "${NEW_FEATURES_AND_FIXES}" ]]; then
echo >&2
print_red "💀 The ${CANISTER_NAME} canister has no information in its unreleased_changelog.md." >&2
print_red "💀 ${GOVERNANCE_TYPE} ${CANISTER_NAME}'s unreleased_changelog.md is EMPTY." >&2
exit 1
fi
NEW_ENTRY="# ${EXECUTED_ON}: Proposal ${PROPOSAL_ID}
Expand Down Expand Up @@ -161,7 +158,6 @@ echo -n "${UNRELEASED_CHANGELOG_INTRODUCTION}
""" \
>unreleased_changelog.md

echo >&2
print_green '🎉 Success! Added new entry to CHANGELOG.md.' >&2
print_cyan '💡 Run `git diff` to see the changes. If you are pleased, commit,' >&2
print_cyan 'push, request review, and merge them into master, per usual.' >&2

0 comments on commit d37cb7b

Please sign in to comment.