Skip to content

Fix update.sh Dockerfile status reporting#2308

Closed
PeterDaveHello wants to merge 1 commit intonodejs:mainfrom
PeterDaveHello:fix-update-sh-status
Closed

Fix update.sh Dockerfile status reporting#2308
PeterDaveHello wants to merge 1 commit intonodejs:mainfrom
PeterDaveHello:fix-update-sh-status

Conversation

@PeterDaveHello
Copy link
Copy Markdown
Member

Description

Clarify update.sh status messages by comparing each generated Dockerfile with the existing file before replacing it. Move the Yarn version update ahead of the comparison and emit either “updated” when the content changes or “already up to date.” when it does not.

GitHub Copilot Summary

This pull request refactors the logic for updating Dockerfiles in the update_node_version() function in update.sh. The main change is a switch from using diff to cmp for file comparison, and updating the messaging and cleanup flow for temporary files.

Improvements to update logic:

  • Replaced the use of diff -q with cmp -s to compare ${dockerfile}-tmp and ${dockerfile}, simplifying the check for file changes.
  • Updated messaging to use the info function for consistent output when a Dockerfile is already up to date or has been updated.
  • Improved cleanup by removing the temporary file ${dockerfile}-tmp if no changes are detected, and only moving it to ${dockerfile} when updates are made.

Motivation and Context

Previous runs could print “updated!” even when the final Dockerfile was unchanged, leading to confusing output after git status showed no diffs. This change makes the script’s messaging align with the actual state of the files.

Testing Details

  • ./update.sh 20 bookworm
  • ./update.sh 22

Example Output(if appropriate)

Updating version 20...
20/bookworm/Dockerfile already up to date.
Done!

Types of changes

  • Documentation
  • Version change (Update, remove or add more Node.js versions)
  • Variant change (Update, remove or add more variants, or versions of variants)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Other (none of the above)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING.md document.
  • All new and existing tests passed.

Compare each generated Dockerfile with its existing copy before
replacing it, so the script only announces an update when the content
actually changes. Otherwise keep the original file and print an
'already up to date' message to eliminate false positives.
@PeterDaveHello PeterDaveHello requested review from a team and Copilot November 6, 2025 19:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the Dockerfile update logic in update.sh to improve efficiency and consistency. The main goal is to avoid unnecessary file operations and use consistent output messaging.

  • Moved the YARN_VERSION sed operation to always execute before comparison (when SKIP is false)
  • Changed file comparison from diff -q to cmp -s and added conditional handling to avoid overwriting unchanged files
  • Standardized output messages to use the info function instead of echo

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fi

mv -f "${dockerfile}-tmp" "${dockerfile}"
if cmp -s "${dockerfile}-tmp" "${dockerfile}"; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not too important in terms of functionality but out of curiosity what made you choose cmp over the more common diff here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't have a preference actually 😅

@MikeMcC399
Copy link
Copy Markdown
Contributor

@PeterDaveHello

This PR may now be obsolete

Previous runs could print “updated!” even when the final Dockerfile was unchanged, leading to confusing output after git status showed no diffs. This change makes the script’s messaging align with the actual state of the files.

This issue was reported in #2413 and fixed in #2416

Also Yarn is now handled differently due to it being removed in the future.

@PeterDaveHello
Copy link
Copy Markdown
Member Author

@MikeMcC399 Thanks. I'll close this one now, although I'm not sure why we're creating new PRs instead of using existing ones. Maybe this is just the current state of the project.

@MikeMcC399
Copy link
Copy Markdown
Contributor

@PeterDaveHello

I'll close this one now

Thank you!

although I'm not sure why we're creating new PRs instead of using existing ones. Maybe this is just the current state of the project.

PR #2416 was to remove Yarn, and because there are no more Yarn releases expected, it also simplified the Yarn version handling. A by-product was to fix #2413 regarding reporting the update state (updated or not updated), so from my viewpoint it wasn't submitted to replace your PR, it just happened to fix the issue. @nschonni can comment additionally since he was the author of the PR.

I'm not a maintainer, just a contributor, so I can't really comment in general about the organization of the project. There is however now a Slack channel set up for those sorts of discussions.

@PeterDaveHello
Copy link
Copy Markdown
Member Author

The new PR isn't intended to replace this one, I believe that. My small concern is the earlier discussion about the maintenance status of this project. This PR was created months ago; some issues could have been fixed earlier. Maybe most of us don't have enough time to review PRs, so we create a new one when needed.

@PeterDaveHello PeterDaveHello deleted the fix-update-sh-status branch March 28, 2026 15:39
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.

4 participants