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

feat(brew): adds "greedy-latest" option to Brew #636

Merged
merged 2 commits into from
Feb 17, 2024

Conversation

luciodaou
Copy link
Contributor

@luciodaou luciodaou commented Jan 6, 2024

Standards checklist:

  • The PR title is descriptive.
  • I have read CONTRIBUTING.md
  • The code compiles (cargo build)
  • The code passes rustfmt (cargo fmt)
  • The code passes clippy (cargo clippy)
  • The code passes tests (cargo test)
  • Optional: I have tested the code myself

Adds a new boolean option greedy_latest in the config file for Brew/Homebrew, equivalent to the command line option --greedy-latest to brew upgrade, based on greedy_cask itself.

image

This is because greedy_cask invokes brew's --greddy, that updates "casks with auto_updates or version :latest". As I've been having some issues in apps with auto update, I decided to add this new option to allow for the git casks to be updated without touching the auto update ones.
image

Here is the result of the first test run:

Code test result

Output

topgrade/target/debug on  main [!] 
🍎 ❯ ./topgrade --only brew_cask brew_formula

── 21:19:04 - Topgrade 13.0.0 Breaking Changes ─────────────────────────────────
No Breaking changes

Confirmed? (y)es/(N)o
── 21:19:12 - Brew ─────────────────────────────────────────────────────────────
Updated 1 tap (homebrew/cask-fonts).
No changes to formulae or casks.

── 21:19:17 - Brew - Cask ──────────────────────────────────────────────────────
==> Casks with 'auto_updates true' will not be upgraded; pass `--greedy-auto-updates` to upgrade them.
==> Upgrading 5 outdated packages:
homebrew/cask-fonts/font-montserrat latest -> latest
homebrew/cask-fonts/font-red-hat-display latest -> latest
homebrew/cask-fonts/font-red-hat-mono latest -> latest
homebrew/cask-fonts/font-red-hat-text latest -> latest
homebrew/cask-fonts/font-source-code-pro latest -> latest
==> Upgrading font-montserrat
==> Cloning https://github.com/google/fonts.git
Updating /Users/lucio/Library/Caches/Homebrew/Cask/font-montserrat--git-sparse
From https://github.com/google/fonts
 b8198929..837b031e  main       -> origin/main
==> Checking out branch main
Already on 'main'
Your branch is behind 'origin/main' by 221 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
HEAD is now at 837b031e Merge pull request #7146 from google/lang-v0515
Warning: No checksum defined for cask 'font-montserrat', skipping verification.
==> Backing Font 'Montserrat-Italic[wght].ttf' up to '/opt/homebrew/Caskroom/font-montserrat/latest/ofl/montse
==> Removing Font '/Users/lucio/Library/Fonts/Montserrat-Italic[wght].ttf'
==> Backing Font 'Montserrat[wght].ttf' up to '/opt/homebrew/Caskroom/font-montserrat/latest/ofl/montserrat/Mo
==> Removing Font '/Users/lucio/Library/Fonts/Montserrat[wght].ttf'
==> Moving Font 'Montserrat-Italic[wght].ttf' to '/Users/lucio/Library/Fonts/Montserrat-Italic[wght].ttf'
==> Moving Font 'Montserrat[wght].ttf' to '/Users/lucio/Library/Fonts/Montserrat[wght].ttf'
==> Purging files for version latest of Cask font-montserrat
🍺  font-montserrat was successfully upgraded!
==> Upgrading font-red-hat-display
==> Cloning https://github.com/google/fonts.git
Updating /Users/lucio/Library/Caches/Homebrew/Cask/font-red-hat-display--git-sparse
From https://github.com/google/fonts
 b8198929..837b031e  main       -> origin/main
==> Checking out branch main
Already on 'main'
Your branch is behind 'origin/main' by 221 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
HEAD is now at 837b031e Merge pull request #7146 from google/lang-v0515
Warning: No checksum defined for cask 'font-red-hat-display', skipping verification.
==> Backing Font 'RedHatDisplay-Italic[wght].ttf' up to '/opt/homebrew/Caskroom/font-red-hat-display/latest/of
==> Removing Font '/Users/lucio/Library/Fonts/RedHatDisplay-Italic[wght].ttf'
==> Backing Font 'RedHatDisplay[wght].ttf' up to '/opt/homebrew/Caskroom/font-red-hat-display/latest/ofl/redha
==> Removing Font '/Users/lucio/Library/Fonts/RedHatDisplay[wght].ttf'
==> Moving Font 'RedHatDisplay-Italic[wght].ttf' to '/Users/lucio/Library/Fonts/RedHatDisplay-Italic[wght]
==> Moving Font 'RedHatDisplay[wght].ttf' to '/Users/lucio/Library/Fonts/RedHatDisplay[wght].ttf'
==> Purging files for version latest of Cask font-red-hat-display
🍺  font-red-hat-display was successfully upgraded!
==> Upgrading font-red-hat-mono
==> Cloning https://github.com/google/fonts.git
Updating /Users/lucio/Library/Caches/Homebrew/Cask/font-red-hat-mono--git-sparse
From https://github.com/google/fonts
 b8198929..837b031e  main       -> origin/main
==> Checking out branch main
Already on 'main'
Your branch is behind 'origin/main' by 221 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
HEAD is now at 837b031e Merge pull request #7146 from google/lang-v0515
Warning: No checksum defined for cask 'font-red-hat-mono', skipping verification.
==> Backing Font 'RedHatMono-Italic[wght].ttf' up to '/opt/homebrew/Caskroom/font-red-hat-mono/latest/ofl/redh
==> Removing Font '/Users/lucio/Library/Fonts/RedHatMono-Italic[wght].ttf'
==> Backing Font 'RedHatMono[wght].ttf' up to '/opt/homebrew/Caskroom/font-red-hat-mono/latest/ofl/redhatmono/
==> Removing Font '/Users/lucio/Library/Fonts/RedHatMono[wght].ttf'
==> Moving Font 'RedHatMono-Italic[wght].ttf' to '/Users/lucio/Library/Fonts/RedHatMono-Italic[wght].ttf'
==> Moving Font 'RedHatMono[wght].ttf' to '/Users/lucio/Library/Fonts/RedHatMono[wght].ttf'
==> Purging files for version latest of Cask font-red-hat-mono
🍺  font-red-hat-mono was successfully upgraded!
==> Upgrading font-red-hat-text
==> Cloning https://github.com/google/fonts.git
Updating /Users/lucio/Library/Caches/Homebrew/Cask/font-red-hat-text--git-sparse
From https://github.com/google/fonts
 b8198929..837b031e  main       -> origin/main
==> Checking out branch main
Already on 'main'
Your branch is behind 'origin/main' by 221 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
HEAD is now at 837b031e Merge pull request #7146 from google/lang-v0515
Warning: No checksum defined for cask 'font-red-hat-text', skipping verification.
==> Backing Font 'RedHatText-Italic[wght].ttf' up to '/opt/homebrew/Caskroom/font-red-hat-text/latest/ofl/redh
==> Removing Font '/Users/lucio/Library/Fonts/RedHatText-Italic[wght].ttf'
==> Backing Font 'RedHatText[wght].ttf' up to '/opt/homebrew/Caskroom/font-red-hat-text/latest/ofl/redhattext/
==> Removing Font '/Users/lucio/Library/Fonts/RedHatText[wght].ttf'
==> Moving Font 'RedHatText-Italic[wght].ttf' to '/Users/lucio/Library/Fonts/RedHatText-Italic[wght].ttf'
==> Moving Font 'RedHatText[wght].ttf' to '/Users/lucio/Library/Fonts/RedHatText[wght].ttf'
==> Purging files for version latest of Cask font-red-hat-text
🍺  font-red-hat-text was successfully upgraded!
==> Upgrading font-source-code-pro
==> Cloning https://github.com/google/fonts.git
Updating /Users/lucio/Library/Caches/Homebrew/Cask/font-source-code-pro--git-sparse
From https://github.com/google/fonts
 b8198929..837b031e  main       -> origin/main
==> Checking out branch main
Already on 'main'
Your branch is behind 'origin/main' by 221 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
HEAD is now at 837b031e Merge pull request #7146 from google/lang-v0515
Warning: No checksum defined for cask 'font-source-code-pro', skipping verification.
==> Backing Font 'SourceCodePro-Italic[wght].ttf' up to '/opt/homebrew/Caskroom/font-source-code-pro/latest/of
==> Removing Font '/Users/lucio/Library/Fonts/SourceCodePro-Italic[wght].ttf'
==> Backing Font 'SourceCodePro[wght].ttf' up to '/opt/homebrew/Caskroom/font-source-code-pro/latest/ofl/sourc
==> Removing Font '/Users/lucio/Library/Fonts/SourceCodePro[wght].ttf'
==> Moving Font 'SourceCodePro-Italic[wght].ttf' to '/Users/lucio/Library/Fonts/SourceCodePro-Italic[wght]
==> Moving Font 'SourceCodePro[wght].ttf' to '/Users/lucio/Library/Fonts/SourceCodePro[wght].ttf'
==> Purging files for version latest of Cask font-source-code-pro
🍺  font-source-code-pro was successfully upgraded!

── 21:19:31 - Summary ──────────────────────────────────────────────────────────
Brew (ARM): OK
Brew Cask (ARM): OK

Copy link
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

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

So IIUC, --greedy contains --greedy-latest, can they be used together? i.e.:

$ brew upgrade --greedy --greedy-latest

@luciodaou
Copy link
Contributor Author

So IIUC, --greedy contains --greedy-latest, can they be used together? i.e.:

$ brew upgrade --greedy --greedy-latest

Good question. I just checked and yes, they can and brew doesn't complain about it:
image

image

It's not the most "elegant" way, as greedy_cask being enabled could omit greedy_latest. But, as shown above, it creates no conflicts with brew.

@SteveLauC
Copy link
Member

Can I trouble you to add some documents on these 2 configuration entries in the config.example.toml file, what they are and what will happen if they are enabled. And, maybe we should document that greedy_cask would contain greedy_latest so that users won't need to set greedy_latest if greedy_cask is set.

@luciodaou
Copy link
Contributor Author

Can I trouble you to add some documents on these 2 configuration entries in the config.example.toml file, what they are and what will happen if they are enabled. And, maybe we should document that greedy_cask would contain greedy_latest so that users won't need to set greedy_latest if greedy_cask is set.

Not a problem at all. I'll do it soon. 👍

@SteveLauC
Copy link
Member

It has been a while, let's merge this PR:)

@SteveLauC SteveLauC merged commit 8991bc9 into topgrade-rs:main Feb 17, 2024
7 checks passed
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.

2 participants