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

Fix check_coretap_git_origin #5607

Merged
merged 1 commit into from Jan 26, 2019

Conversation

sjackman
Copy link
Member

check_coretap_git_origin was not working as intended.
Permit Linuxbrew/homebrew-core as a valid origin.
Factor out check_coretap_git_branch.

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

@sjackman sjackman self-assigned this Jan 25, 2019
@sjackman sjackman added the bug Reproducible Homebrew/brew bug label Jan 25, 2019

if origin.nil?
<<~EOS
Missing #{CoreTap.instance} git origin remote.

Without a correctly configured origin, Homebrew won't update
properly. You can solve this by adding the Homebrew remote:
git -C "#{coretap_path}" remote add origin #{Formatter.url("https://github.com/Homebrew/homebrew-core.git")}
git -C "#{coretap_path}" remote add origin #{Formatter.url(default_remote)}
EOS
Copy link
Member Author

Choose a reason for hiding this comment

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

This string went nowhere.

@@ -595,12 +596,17 @@ def check_coretap_git_origin

Unless you have compelling reasons, consider setting the
origin remote to point at the main repository by running:
git -C "#{coretap_path}" remote set-url origin #{Formatter.url("https://github.com/Homebrew/homebrew-core.git")}
git -C "#{coretap_path}" remote set-url origin #{Formatter.url(default_remote)}
EOS
Copy link
Member Author

Choose a reason for hiding this comment

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

This string went nowhere.

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.

One change request then good to go 👍

EOS
elsif origin !~ %r{Homebrew/homebrew-core(\.git|/)?$}
elsif origin !~ %r{#{URI(default_remote).path}(\.git|/)?$}
Copy link
Member

Choose a reason for hiding this comment

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

Use CoreTap.instance.full_name instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

On Linux, CoreTap.instance.full_name returns Homebrew/homebrew-core rather than the desired Linuxbrew/homebrew-core.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to use…

        elsif origin != default_remote

It's stricter in three ways:

  1. Doesn't allow trailing .git
  2. Doesn't allow trailing /
  3. Doesn't allow ssh

I'm personally okay with that. Homogeneity is good.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that I think about it, it's simply a bug that CoreTap.instance.full_name returns Homebrew/homebrew-core on Linux. I'll fix it.

Copy link
Member

Choose a reason for hiding this comment

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

Now that I think about it, it's simply a bug that CoreTap.instance.full_name returns Homebrew/homebrew-core on Linux. I'll fix it.

👍

return if ENV["CI"]

coretap_path = CoreTap.instance.path
return if !Utils.git_available? || !(coretap_path/".git").exist?

branch = coretap_path.git_branch
return if branch.nil? || branch =~ /master/

Copy link
Member

Choose a reason for hiding this comment

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

Want to update the string two lines below, too?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean change Homebrew/homebrew-core is not on the master branch? Yep, can do.

Copy link
Member

Choose a reason for hiding this comment

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

@sjackman 👍

@sjackman
Copy link
Member Author

I'm not able to reproduce this error locally.

2019-01-25T18:41:19.7027843Z ‌Warning:‌ Suspicious homebrew/core git origin remote found.‌
2019-01-25T18:41:19.7028040Z 
2019-01-25T18:41:19.7028435Z With a non-standard origin, Homebrew won't pull updates from
2019-01-25T18:41:19.7028709Z the main repository. The current git origin is:
2019-01-25T18:41:19.7029140Z   https://github.com/Homebrew/homebrew-core
2019-01-25T18:41:19.7029321Z 
2019-01-25T18:41:19.7029497Z Unless you have compelling reasons, consider setting the
2019-01-25T18:41:19.7029723Z origin remote to point at the main repository by running:
2019-01-25T18:41:19.7030639Z   git -C "/home/linuxbrew/.linuxbrew/Library/Taps/homebrew/homebrew-core" remote set-url origin ‌https://github.com/Homebrew/homebrew-core‌
2019-01-25T18:41:19.7947556Z ==> ‌FAILED‌

The curent origin and suggested default_remote appear identical.

@MikeMcQuaid Any idea why the regex is not matching?

        elsif origin !~ %r{#{CoreTap.instance.full_name}(\.git|/)?$}

@sjackman
Copy link
Member Author

CI passed on macOS, and failed on Linux. HOMEBREW_FORCE_HOMEBREW_ON_LINUX=1 must be set because it's using and suggesting Homebrew/homebrew-core, though I don't see in azure-pipelines.yml where that's set. Perhaps it's set in brew test-bot.

@MikeMcQuaid
Copy link
Member

@sjackman Only for uploading bottles. It's doing brew readall on Linuxbrew.

@MikeMcQuaid
Copy link
Member

With a non-standard origin, Homebrew won't pull updates from the main repository. The current git origin is: https://github.com/Homebrew/homebrew-core

This failure is correct; that origin is wrong on Linux.

EOS
elsif origin !~ %r{Homebrew/homebrew-core(\.git|/)?$}
elsif origin !~ %r{#{CoreTap.instance.full_name}(\.git|/)?$}
return if ENV["CI"] && origin.include?("Homebrew/homebrew-test-bot")
Copy link
Member

Choose a reason for hiding this comment

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

This can be removed now by the way.

# @private
def initialize
super "Homebrew", "core"
@full_name = "Linuxbrew/homebrew-core" unless ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"]
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is properly overriding e.g.the path etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

The aim here is to override only full_name and default_remote on Linux. The other variables should be identical on Linux as on macOS. In particular, CoreTap.instance.path is $HOMEBREW_PREFIX/Homebrew/Library/Taps/homebrew/homebrew-core.

$ brew irb <<<'CoreTap.instance.path'

<Pathname:/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core>

check_coretap_git_origin was not working as intended.
Permit Linuxbrew/homebrew-core as a valid origin.
Factor out check_coretap_git_branch.
@sjackman
Copy link
Member Author

I found the problem. The generic CoreTap.default_remote was still defined, and shouldn't be.

@sjackman
Copy link
Member Author

💚 Ready for re-review.

@MikeMcQuaid MikeMcQuaid merged commit 7eb7ecf into Homebrew:master Jan 26, 2019
@MikeMcQuaid
Copy link
Member

Thanks @sjackman!

@sjackman sjackman deleted the check_coretap_git_origin branch January 28, 2019 07:09
@sjackman
Copy link
Member Author

Thanks for merging, Mike!

@lock lock bot added the outdated PR was locked due to age label Feb 27, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/brew bug outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants