Skip to content
Snippets Groups Projects
Commit 7d07d859 authored by Mike McQuaid's avatar Mike McQuaid
Browse files

migrator: check if taps are from same user instead

This avoids needing to use `force: true` and still let's Homebrew do
what we want with our own taps.
parent dd7121dd
No related branches found
No related tags found
No related merge requests found
......@@ -525,12 +525,7 @@ class Reporter
next
end
begin
migrator = Migrator.new(f, force: true)
migrator.migrate
rescue Exception => e
onoe e
end
Migrator.migrate_if_needed(f)
end
end
......
......@@ -95,7 +95,7 @@ class Migrator
def self.migrate_if_needed(formula)
return unless Migrator.needs_migration?(formula)
begin
migrator = Migrator.new(formula, force: true)
migrator = Migrator.new(formula)
migrator.migrate
rescue Exception => e
onoe e
......@@ -114,7 +114,7 @@ class Migrator
@old_tabs = old_cellar.subdirs.map { |d| Tab.for_keg(Keg.new(d)) }
@old_tap = old_tabs.first.tap
if !force && !from_same_taps?
if !force && !from_same_tap_user?
raise MigratorDifferentTapsError.new(formula, old_tap)
end
......@@ -140,15 +140,19 @@ class Migrator
end
end
def from_same_taps?
def from_same_tap_user?
formula_tap_user = formula.tap.user if formula.tap
old_tap_user = nil
new_tap = if old_tap
old_tap_user, = old_tap.user
if migrate_tap = old_tap.tap_migrations[formula.oldname]
new_tap_user, new_tap_repo, = migrate_tap.split("/")
new_tap_user, new_tap_repo = migrate_tap.split("/")
"#{new_tap_user}/#{new_tap_repo}"
end
end
if formula.tap == old_tap
if formula_tap_user == old_tap_user
true
# Homebrew didn't use to update tabs while performing tap-migrations,
# so there can be INSTALL_RECEIPT's containing wrong information about tap,
......@@ -215,8 +219,7 @@ class Migrator
end
if conflicted
onoe "Remove #{new_cellar} manually and run brew migrate #{oldname}."
return
odie "Remove #{new_cellar} manually and run brew migrate #{oldname}."
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment