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

macOS pkg installer: fix existing installation not being upgraded #19406

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

EricFromCanada
Copy link
Member

@EricFromCanada EricFromCanada commented Mar 2, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Currently when running the macOS installer atop an existing installation, at the point after the installation finishes but before postinstall is run, the master branch hasn't had its HEAD advanced to the latest tag yet so the working directory is in a "HEAD detached at {version number}" as though you had run git checkout {version number}. This is why git reset --hard resets it to the previous tagged version.

This change has git find the latest tag (git tag --list --sort="-version:refname" | head -n1) and then resets to that tag (git reset --hard <tag name>). This also adds a git clean -f -d to clear any stray untracked files from the working directory, and no longer purges all branches other than master.

Fixes #19287, alternate to #19354. Tested on both macOS ARM and Intel.

@EricFromCanada EricFromCanada force-pushed the installer-upgrade-fix branch from aab9d68 to 4f25e80 Compare March 5, 2025 04:35
@EricFromCanada EricFromCanada force-pushed the installer-upgrade-fix branch from 4f25e80 to 78a326d Compare March 5, 2025 04:42
Copy link
Member

@ZhongRuoyu ZhongRuoyu left a comment

Choose a reason for hiding this comment

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

Thanks!

@EricFromCanada EricFromCanada added this pull request to the merge queue Mar 5, 2025
Merged via the queue into master with commit f0b84c9 Mar 5, 2025
37 checks passed
@EricFromCanada EricFromCanada deleted the installer-upgrade-fix branch March 5, 2025 14:57
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.

Mac installer packages do not upgrade Homebrew from older versions
2 participants