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

Alphabetize the brew outdated formula listing. #4178

Merged

Conversation

dougal
Copy link
Contributor

@dougal dougal commented May 16, 2018

Sorts the output of brew outdated by Formula#<=>.

For me this significantly speeds up scanning the list to look for formula I consider critical to my work.

Includes updated test example.

Have you written new tests for your changes?

Not strictly speaking. I modified an existing test.

  • 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 tests with your changes locally?

Sorts by `Formula#<=>`.

Includes updated test example.
outdated_formulae = formulae.select { |f| f.outdated?(fetch_head: fetch_head) }
outdated_formulae = formulae
.select { |f| f.outdated?(fetch_head: fetch_head) }
.sort
Copy link
Member

Choose a reason for hiding this comment

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

Leave the first line as it was, and align .sort with .select.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

expect { brew "outdated" }
.to output("testball\n").to_stdout
.to output("foo\ntestball\n").to_stdout
Copy link
Member

Choose a reason for hiding this comment

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

Did you check if this specific case actually fails without sort?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Commenting out the sort line results in the following failure:

1) brew outdated quiet output prints outdated Formulae
     Failure/Error:
       expect { brew "outdated" }
         .to output("foo\ntestball\n").to_stdout
         .and not_to_output.to_stderr
         .and be_a_success
     
       expected block to output "foo\ntestball\n" to stdout, but output "testball\nfoo\n"

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume that's locally but not on CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, locally.

CI should never fail as the tests were committed with the changes. I assume, unless I am misunderstanding something.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just mean that on CI, which is using HFS+, it probably always passes regardless of the sort, whereas locally it fails without the sort because you're using APFS. I'm not sure there's anything to be done about that really in terms of making the test actually test something on CI but I don't think we need to worry about sort not working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good insight on CI using HFS+, thanks.

I originally tried making the the test case more expansive, with different formulae inserted in different orders. I simplified it as I wasn't sure the expanded test case provided any value.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to worry about sort not working.

Well, the test is not for sort itself, but for the fact that the output has to be sorted. Anyways, as long as it fails locally on APFS, it is good enough.

@reitermarkus reitermarkus merged commit 73bffba into Homebrew:master May 16, 2018
@reitermarkus
Copy link
Member

Thank you for your first contribution to Homebrew, @dougal!

@lock lock bot added the outdated PR was locked due to age label Jun 15, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jun 15, 2018
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.

3 participants