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

Output version upgrade info using puts #16959

Merged
merged 1 commit into from Mar 28, 2024

Conversation

nwhetsell
Copy link
Sponsor Contributor

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

This PR changes the two-line upgrade message to use puts for the second line (oh1 is still used for the first line). This prevents version numbers from being truncated when upgrading formulae, which can happen if a formula has a very long name or is in a non-core tap. More info is at #16942 and this comment on that issue.

I attempted to write a test for this, but I have not been successful. This is my attempted test (for inclusion in cmd/upgrade):

it "outputs complete version numbers", :integration_test do
  allow($stdout).to receive(:tty?).and_return(true)
  allow(Tty).to receive(:width).and_return(80)

  name = "testball-with-long-name-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  setup_test_formula name

  expect { brew "upgrade" }
    .to output(/^  -> 0.1\b/).to_stdout
    .and be_a_success
end

The problem I’m having is that $stdout.tty? doesn’t seem to return true, so no messages are truncated here (because $stdout.tty? is actually false):

title = Tty.truncate(title.to_s) if $stdout.tty? && !verbose && truncate == :auto

Consequently, this test is passing currently (that is, without the changes in this PR), so I left this test out.

Copy link
Contributor

@apainintheneck apainintheneck left a comment

Choose a reason for hiding this comment

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

Don't worry about the test. This should be good as is.

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.

Great work here, thanks again @nwhetsell!

@MikeMcQuaid MikeMcQuaid merged commit bb66f87 into Homebrew:master Mar 28, 2024
25 checks passed
@github-actions github-actions bot added the outdated PR was locked due to age label Apr 28, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 28, 2024
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.

None yet

3 participants