Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a script to make it easier to add changelog entries. #2166

Merged
merged 7 commits into from
Oct 4, 2024

Conversation

SpicyLemon
Copy link
Contributor

@SpicyLemon SpicyLemon commented Oct 4, 2024

Description

This PR creates the .changelog/add-change.sh that's hopefully easier to use than unclog.

Usage: add-change.sh [<num>] [<id>] [<section>] [<message>]

Each argument can alternatively be provided using flags:
    [-n|--issue|--issue-no|-p|--pr|--pull-request] <num>
    [-i|--id] <id>
    [-s|--section] <section>
    [-m|--message] <message>

See .changelog/add-change.sh --help for full usage details.

  • The <num> can be omitted if your branch name has the format <username>/<issue number>-<id>.
  • If the <id> is omitted, then it'll be derived from your branch name.
  • If you have fzf installed on your system, you can omit the <section> and you'll be prompted to select one. Having fzf also allows you to use partial section names and it'll either auto-select the one it matches or prompt you to select from the multiple that match. E.g. if you provide a <section> of bug, it'll automatically get changed to bug-fixes. But if you provide it as dep, you'll be prompted because that matches both dependencies and deprecated.
  • If you don't have fzf then you'll need to provide the full, valid section name, but if you get it wrong, the error output will at least include the list of possibilities.
  • If the <message> is omitted, behavior depends on the <section>. If it's dependencies, then the get-dep-changes.sh script is used to generate the message content. If it's any other section, then the message will just be TODO.
  • For the most part, the arguments can be provided in any order, but the flags are available if that pattern's easier for you.

For this PR, I used this command:

$ .changelog/add-change.sh --pr 2166 imp 'Create the `add-change.sh` script to make it easier to add changelog entries.'

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Added relevant changelog entries under .changelog/unreleased (see Adding Changes).
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

Summary by CodeRabbit

  • New Features

    • Introduced a new script, add-change.sh, to simplify adding entries to the changelog.
    • Expanded documentation for the changelog process, including detailed instructions for using the new script.
  • Documentation

    • Enhanced the .changelog/README.md with clear guidelines on using the add-change.sh script and preparing for releases.

@SpicyLemon SpicyLemon requested a review from a team as a code owner October 4, 2024 01:37
Copy link
Contributor

coderabbitai bot commented Oct 4, 2024

Warning

Rate limit exceeded

@SpicyLemon has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 56 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between ae4958d and b679fc3.

Walkthrough

The changes involve enhancements to the documentation and the introduction of a new script, add-change.sh, aimed at improving the process of adding changelog entries. The .changelog/README.md file was updated to provide detailed instructions for using the new script, including command structure and examples. The script itself allows users to add entries to the changelog with various parameters and includes validation and error handling features. Additionally, the documentation on release preparation was clarified.

Changes

File Change Summary
.changelog/README.md Expanded documentation on using add-change.sh, including command structure, examples, and output format. Updated "Releases" section for clarity. Minor formatting adjustments made.
.changelog/add-change.sh New script added to facilitate adding changelog entries with command-line interface, validation, and error handling.
.changelog/unreleased/improvements/2166-add-changelog-helper.md New script add-change.sh introduced to streamline changelog entry documentation.

Poem

In the land of code, where changes bloom,
A script was born to dispel the gloom.
With flags and commands, it dances with grace,
Changelog entries find their rightful place.
Hooray for the helpers, so clever and bright,
Documenting changes, oh what a delight! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (4)
.changelog/README.md (2)

33-97: LGTM! Clear and comprehensive instructions for add-change.sh.

The new content provides excellent documentation for using the add-change.sh script. The usage examples and explanations are clear and cover various scenarios, which will be very helpful for users.

Consider adding a brief note about where users can find the add-change.sh script (e.g., in the root of the repository or in the .changelog directory). This would make it even easier for new contributors to get started.

🧰 Tools
🪛 LanguageTool

[style] ~56-~56: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...d, behavior depends on the <section>. If the section is "dependencies", then the...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...executed to create the message content. If it's any other section, the file will b...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🪛 Markdownlint

64-64: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)


70-70: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)


76-76: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)


82-82: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)


56-57: Consider addressing minor style suggestions.

The static analysis tools have flagged a few minor style issues:

  1. In lines 56-57, consider rewording to avoid starting three successive sentences with "If".
  2. In the command examples (lines 64, 70, 76, 82), consider either removing the dollar signs or showing the command output to comply with Markdown best practices.

These are low-priority suggestions and don't affect the functionality or overall clarity of the documentation.

Also applies to: 64-64, 70-70, 76-76, 82-82

🧰 Tools
🪛 LanguageTool

[style] ~56-~56: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...d, behavior depends on the <section>. If the section is "dependencies", then the...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...executed to create the message content. If it's any other section, the file will b...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

.changelog/add-change.sh (2)

354-356: Check for errors when writing to the temporary file

When using awk to write to the temporary file, it's good practice to check if the write operation was successful. This ensures that any I/O errors are caught promptly.

Apply this diff to add error checking:

-awk -v link="$link" '{if(NR==1){sub(/^[[:space:]]*[-*]?[[:space:]]*/,"* "); sub(/[[:space:]]*(\.)?[[:space:]]*$/," " link "."); print;}else{print "  " $0;};}' <<< "$message" > "$temp_file"
+awk -v link="$link" '{if(NR==1){sub(/^[[:space:]]*[-*]?[[:space:]]*/,"* "); sub(/[[:space:]]*(\.)?[[:space:]]*$/," " link "."); print;}else{print "  " $0;};}' <<< "$message" > "$temp_file" || { printf 'Error: Failed to write to temporary file.\n'; clean_exit 1; }

349-349: Consider using return instead of exit in the clean_exit function

Using exit inside a function will terminate the entire script, which is appropriate here since clean_exit is meant to finalize and exit. However, if there's a possibility that this function might be reused or sourced in another script, using return could make it more flexible.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 13b0a5e and ae4958d.

📒 Files selected for processing (3)
  • .changelog/README.md (3 hunks)
  • .changelog/add-change.sh (1 hunks)
  • .changelog/unreleased/improvements/2166-add-changelog-helper.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changelog/unreleased/improvements/2166-add-changelog-helper.md
🧰 Additional context used
🪛 LanguageTool
.changelog/README.md

[style] ~56-~56: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...d, behavior depends on the <section>. If the section is "dependencies", then the...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...executed to create the message content. If it's any other section, the file will b...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🪛 Markdownlint
.changelog/README.md

64-64: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)


70-70: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)


76-76: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)


82-82: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)

🪛 Shellcheck
.changelog/add-change.sh

[warning] 148-148: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)


[warning] 162-162: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

(SC2207)

🔇 Additional comments (3)
.changelog/README.md (3)

108-108: LGTM! Improved readability.

The addition of a blank line before the "Using unclog" section enhances the document's readability by clearly separating it from the previous section.


274-275: LGTM! Completed instructions for post-release setup.

The added steps for creating a new .changelog/unreleased directory and .gitkeep file complete the process of setting up the changelog structure after a release. This ensures that the repository is ready for new unreleased changes.


Line range hint 1-275: Great job on updating the changelog documentation!

The changes to this file significantly improve the documentation for the changelog process, particularly with the introduction of the add-change.sh script. The new instructions are clear, comprehensive, and user-friendly, which should make it easier for contributors to add changelog entries correctly.

The minor formatting improvements and additional instructions for post-release setup further enhance the overall quality of the documentation.

These updates align well with the PR objectives of creating a script to simplify the process of adding changelog entries. Great work on improving the developer experience!

🧰 Tools
🪛 LanguageTool

[style] ~56-~56: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...d, behavior depends on the <section>. If the section is "dependencies", then the...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...executed to create the message content. If it's any other section, the file will b...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🪛 Markdownlint

64-64: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)


70-70: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)


76-76: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)


82-82: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)

.changelog/add-change.sh Show resolved Hide resolved
.changelog/add-change.sh Show resolved Hide resolved
.changelog/add-change.sh Outdated Show resolved Hide resolved
.changelog/add-change.sh Show resolved Hide resolved
.changelog/add-change.sh Outdated Show resolved Hide resolved
Copy link
Member

@iramiller iramiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t generally prefix my branch names with my username, I just use the issue number followed by a dash and a short set of words from the title. Still this form here seems fine.

@SpicyLemon
Copy link
Contributor Author

I don’t generally prefix my branch names with my username, I just use the issue number followed by a dash and a short set of words from the title. Still this form here seems fine.

You'll still be fine. It strips off everything before the last /. Then if what's left starts with <num>-, it'll pull that part out (and get the <num> from it if needed), and everything left is taken to be the <id>.

@SpicyLemon SpicyLemon merged commit 65a719d into main Oct 4, 2024
20 checks passed
@SpicyLemon SpicyLemon deleted the dwedul/add-changelog-helper branch October 4, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants