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

dev-cmd/unbottled: add --lost option #16115

Merged

Conversation

apainintheneck
Copy link
Contributor

@apainintheneck apainintheneck commented Oct 15, 2023

  • 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?

Closes #16016

This option tries to find bottles where the bottle was removed from the formula in the past week and not added back in.

It checks the output of git log to see if there are any bottles that fit this criteria.

Note: This implementation does not handle renamed formula well but I assume that doesn't happen that often so having the occasional false positive is not a big deal here.

The git log output looks something like this for each commit.

commit 2db9033f717486f7f0c9b815165f8e75c106f4f2
Author: BrewTestBot <[email protected]>
Date:   Mon Oct 9 01:57:41 2023 +0000

    chezmoi: update 2.40.1 bottle.

diff --git a/Formula/c/chezmoi.rb b/Formula/c/chezmoi.rb
index 6630a3a49f1..0e0b44ceb1e 100644
--- a/Formula/c/chezmoi.rb
+++ b/Formula/c/chezmoi.rb
@@ -16,15 +16,13 @@ class Chezmoi < Formula
   end

   bottle do
-    sha256 cellar: :any_skip_relocation, arm64_sonoma:   "5e8b651e295cf9aa2e729eb20a95369f40776c417967dfd548a8d099814555e1"
-    sha256 cellar: :any_skip_relocation, arm64_ventura:  "3110d532bce9e4b491947ed573cb8791b2e9686e8bc48ac3c9254c7821191f64"
-    sha256 cellar: :any_skip_relocation, arm64_monterey: "8d4f12c92e13b30f16f8590d3baf2f5023411487618fe95d56a97498719d2ca8"
-    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "16b9f5098a7341449a6117b33f1d7f3c81e2bbe7931483542c61318f5dabfb95"
-    sha256 cellar: :any_skip_relocation, sonoma:         "b8fea089285495c752425255a1f7991a38db1e7dccbfbfda1d80d292f1eb1375"
-    sha256 cellar: :any_skip_relocation, ventura:        "317ae3c957e7e47c9da148810cf6552806ada43bd64e06717a8d9d4ad29d34a0"
-    sha256 cellar: :any_skip_relocation, monterey:       "fbc1730aa793c0cc4eba55de4ba917da49ab0a5bdec7f5fc6dd2dbf1a11cd74e"
-    sha256 cellar: :any_skip_relocation, big_sur:        "b103680ce7be96687331e6e4bd67179c36c029396e445ed4da28db0e3af99a34"
-    sha256 cellar: :any_skip_relocation, x86_64_linux:   "4033bf4f74a71d34ab9cae2a42572182c8e2f54c9c3cc8e959da6b41482b825f"
+    sha256 cellar: :any_skip_relocation, arm64_sonoma:   "6306f3c075e815900601a445f3f7abf2442796b37ac413cbeb2728b1a9875dec"
+    sha256 cellar: :any_skip_relocation, arm64_ventura:  "e222a15cd8c207e4a86c00c11ae52839d469c9bc4263196e46a890865d486b37"
+    sha256 cellar: :any_skip_relocation, arm64_monterey: "fd0ece6bdbac1c673a0a76cbe18d64cc6590b9c25a42e47ed528ff81515c670b"
+    sha256 cellar: :any_skip_relocation, sonoma:         "5dd6c897ed71aa81cc3c4a60b57c667707178f8fe083d0481da7bd3ad276855f"
+    sha256 cellar: :any_skip_relocation, ventura:        "d6631beca0be1dcee098840b185afd0d84003fbcfb07284037df8f1aea2e1595"
+    sha256 cellar: :any_skip_relocation, monterey:       "7a0c3e1df3ea5fc7c801758d1450b4217463e1c5f8b67be6e01a3b3a7fcbd7ea"
+    sha256 cellar: :any_skip_relocation, x86_64_linux:   "eb65b49dc68b391c44a1878e26d7416b57f4685f45337c8ca6b720b3ace1dcc7"
   end

   depends_on "go" => :build

We parse the commit, formula name and bottle changes from this and then print that the bottle is lost if the bottle was removed and not replaced.

Examples:

$ brew unbottled --lost --tag=catalina
0cd5b8ed5cece697c573b1aae68cb480ce1ed124: bottle lost for progress
d32cf49ac718953fd8a12d9e8beb22253e438459: bottle lost for glulxe
e91497afc7c48a7a541d01e71fd8dd85324cd0f5: bottle lost for bbtools
3b20c02cd83bea90e2110db94926054400779467: bottle lost for assimp
615db9c7aa328a90d96b1d4f92e8a112399e33cf: bottle lost for git-if
97ab0a4493a0cd3e9cb1381f1af1c61b39c0f3f5: bottle lost for mt32emu
fe17ca92c062f17f086d09f4f1bacc819c6e416d: bottle lost for ghr
27d4c7c7aaa354d9c91f29bded817711706eb30b: bottle lost for go-md2man
32482fe5a6771931198e22de0129535a6601fbfa: bottle lost for clingo
bd0758e78222eb4c1e78a81b9c91835f6b08c972: bottle lost for fail2ban
b8246c3284ce4f02a47fb13bdf43276d4581f02d: bottle lost for vpn-slice
0de3fbffd4d38ff6672916f4c446b1eb00fe0130: bottle lost for unoconv
80e82eed5d6abd75a300de4249f90e61565e3497: bottle lost for shared-mime-info
a3a46c4b194ab30d04081c85677c934c2a06da11: bottle lost for libcue
ffa61bd9956aeef4c1576fc25ca6ebb23462c958: bottle lost for zeromq
8366cf2fe290c26657ea14a087030b880ba60f1e: bottle lost for diceware
68c27a815aad10ea0aa9936f5362324f91fc3141: bottle lost for libnet
2c4c24508099548bc97a6df318e333e19874b0b4: bottle lost for honcho
8f6f93ee47e3cf1a570fb2c49dd380797972d6d2: bottle lost for choose
$ brew unbottled --lost --tag=arm64_ventura
$ brew unbottled --lost --tag=sonoma
94febc3a91a4e8d3443adec4192dc3153659aafb: bottle lost for victoriametrics

This option tries to find bottles where the bottle was removed
from the formula in the past week and not added back in.

It checks the output of `git log` to see if there are any
bottles that fit this criteria.
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks good to me so far! I'd be fine with merging once @Bo98 and/or @fxcoudert are 👍🏻 and you've considered my questions. Thanks again @apainintheneck!

Library/Homebrew/dev-cmd/unbottled.rb Outdated Show resolved Hide resolved
Library/Homebrew/dev-cmd/unbottled.rb Show resolved Hide resolved
Library/Homebrew/dev-cmd/unbottled.rb Outdated Show resolved Hide resolved
git_log << "-G^ +sha256.* #{@bottle_tag}:"
git_log << "--since=@{'1 week ago'}"

bottle_tag_sha_regex = /^[+-] +sha256.* #{@bottle_tag}: /
Copy link
Member

Choose a reason for hiding this comment

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

Might be good to not have a copy-paste of common part of the regex with the earlier regex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean by this. Are you suggesting adding another variable to hold shared parts of both regexes?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, handled in e48c155

Copy link
Member

@Bo98 Bo98 left a comment

Choose a reason for hiding this comment

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

Optional, but perhaps slightly safer code in case it picks up anything in documentation or whatever

Library/Homebrew/dev-cmd/unbottled.rb Outdated Show resolved Hide resolved
Library/Homebrew/dev-cmd/unbottled.rb Outdated Show resolved Hide resolved
Library/Homebrew/dev-cmd/unbottled.rb Show resolved Hide resolved
@fxcoudert
Copy link
Member

Seems very nice to me!

@apainintheneck
Copy link
Contributor Author

Optional, but perhaps slightly safer code in case it picks up anything in documentation or whatever

I like this idea too.

- Add heading message to indicate bottle tag used
- Use --no-ext-diff with git to avoid potential problems
- Resolve formula renames to avoid false positives
- Increase parsing stringency
@MikeMcQuaid MikeMcQuaid requested review from Bo98 and removed request for fxcoudert October 17, 2023 11:22
This makes it easier to see that the two regexes are related
and could make it easier to change them in the future if
need be.
@MikeMcQuaid MikeMcQuaid merged commit e7be31d into Homebrew:master Oct 18, 2023
28 checks passed
@MikeMcQuaid
Copy link
Member

Thanks again @apainintheneck!

@github-actions github-actions bot added the outdated PR was locked due to age label Nov 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to brew unbottled to track bottles removed
4 participants