-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
bump-cask-pr: handle nil cask version, add tests #19711
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @samford!
The `shortened_version` method in the `bump-cask-pr` command can produce an error if `cask.version` is `nil`. For example, this can happen on Linux when a cask only sets the `version` in macOS on_system blocks. This modifies the method to explicitly raise a `CaskInvalidError` when `cask.version` is `nil`, as we need to know the existing version to be able to determine how to handle the new `version`. [It's possible to fall back to the full version instead but that can allow certain types of duplicate PRs when `cask.version` is or isn't `nil` on a given host.] This also adds tests for the `shortened_version` method, bringing it to 100% coverage.
a4b5d62
to
ae86da4
Compare
Thinking about this some more, we shouldn't default to the full
I think With that in mind, I think a If we want to be able to bump these types of macOS-only casks on Linux, we'll have to simulate OS/arch earlier in |
Thanks @samford!
Personally, I'd rather that we actually saw the duplicate cask PRs before doing this. I think bumping on Linux is higher priority than fixing a bug that we haven't yet seen in the wild (although please correct me if wrong there). |
I may not have been clear in my previous comment but the current state of this PR simply maintains the status quo [in terms of Regarding the duplicate PR issue, it may not be something that would happen often (i.e., bumping this category of macOS-only cask on Linux hasn't been possible before, I don't imagine many Linux users would think to bump a macOS cask, etc.) but it's something that will predictably occur under those specific circumstances. We have some very enthusiastic contributors in homebrew/cask, so I wouldn't bet on this issue not appearing at some point. If we had a pressing need to enable bumping this category of macOS-only casks on Linux, then I could understand taking a calculated risk. Unless that's the case, I think we should just wait until we can ensure that this type of bump works the same on Linux as it does on macOS. Outside of duplicate PRs, there may be other Linux-specific issues that I haven't seen or thought of yet (off the top of my head, Having Long story short: defaulting to |
I think we have a more pressing need for this known shortcoming than avoiding duplicates which may be likely be is still an unknown.
Sounds good. I'm fine to merge as-is if desired. Thanks @samford! |
If it's not clear from the above, the duplicate PR issue is something that can be reliably replicated under the described conditions. The only mitigating factor is that it's not the most likely set of circumstances to occur right now (though that could change at any time). If you want to replicate the issue on Linux, you can recreate the conditions using a recent
The expected output is:
The existing
The current state of this PR maintains the existing logic but handles the error condition by raising a
Hopefully this clarifies the duplicate PR issue and why I backtracked from that initial idea.
Thanks! It looks like this PR has gotten into a bad state where it's not recognizing subsequent pushes to the branch but let me see if closing/reopening it will allow me to merge this (otherwise I'll have to recreate the PR). |
Ha yeah, the reopen button is disabled because "The bump-cask-pr-rework-shortened_version branch was force-pushed or recreated" (I rebased this an hour ago). Oh well, I can just bundle this fix into my type-related work on |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?The
shortened_version
method in thebump-cask-pr
command can produce an error ifcask.version
isnil
. For example, this can happen on Linux when a cask only sets theversion
in macOS on_system blocks. This modifies the method to explicitly raise aCaskInvalidError
whencask.version
isnil
, as we need to know the existing version to be able to determine how to handle the newversion
. [It's possible to fall back to the full version instead but that can allow certain types of duplicate PRs whencask.version
is or isn'tnil
on a given host.]This also adds tests for the
shortened_version
method, bringing it to 100% coverage.For what it's worth, to allow
bump-cask-pr
to bump casks where the version is only set in macOS on_system blocks, we would need to simulate macOS earlier inbump-cask-pr
(i.e., when definingcask
inrun
). Some casks loudly fail early as invalid, while others may only end up with invalid values like anil
version
. This is something for a follow-up PR but I'll tinker with this to see if we can implement it now or if we have to wait for more reliable indicators of OS requirements (something else that I'm working on).