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.
This commit is contained in:
parent
dd7121dd7c
commit
7d07d859ce
@ -525,12 +525,7 @@ class Reporter
|
|||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
Migrator.migrate_if_needed(f)
|
||||||
migrator = Migrator.new(f, force: true)
|
|
||||||
migrator.migrate
|
|
||||||
rescue Exception => e
|
|
||||||
onoe e
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -95,7 +95,7 @@ class Migrator
|
|||||||
def self.migrate_if_needed(formula)
|
def self.migrate_if_needed(formula)
|
||||||
return unless Migrator.needs_migration?(formula)
|
return unless Migrator.needs_migration?(formula)
|
||||||
begin
|
begin
|
||||||
migrator = Migrator.new(formula, force: true)
|
migrator = Migrator.new(formula)
|
||||||
migrator.migrate
|
migrator.migrate
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
onoe e
|
onoe e
|
||||||
@ -114,7 +114,7 @@ class Migrator
|
|||||||
@old_tabs = old_cellar.subdirs.map { |d| Tab.for_keg(Keg.new(d)) }
|
@old_tabs = old_cellar.subdirs.map { |d| Tab.for_keg(Keg.new(d)) }
|
||||||
@old_tap = old_tabs.first.tap
|
@old_tap = old_tabs.first.tap
|
||||||
|
|
||||||
if !force && !from_same_taps?
|
if !force && !from_same_tap_user?
|
||||||
raise MigratorDifferentTapsError.new(formula, old_tap)
|
raise MigratorDifferentTapsError.new(formula, old_tap)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -140,15 +140,19 @@ class Migrator
|
|||||||
end
|
end
|
||||||
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
|
new_tap = if old_tap
|
||||||
|
old_tap_user, = old_tap.user
|
||||||
if migrate_tap = old_tap.tap_migrations[formula.oldname]
|
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}"
|
"#{new_tap_user}/#{new_tap_repo}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if formula.tap == old_tap
|
if formula_tap_user == old_tap_user
|
||||||
true
|
true
|
||||||
# Homebrew didn't use to update tabs while performing tap-migrations,
|
# Homebrew didn't use to update tabs while performing tap-migrations,
|
||||||
# so there can be INSTALL_RECEIPT's containing wrong information about tap,
|
# so there can be INSTALL_RECEIPT's containing wrong information about tap,
|
||||||
@ -215,8 +219,7 @@ class Migrator
|
|||||||
end
|
end
|
||||||
|
|
||||||
if conflicted
|
if conflicted
|
||||||
onoe "Remove #{new_cellar} manually and run brew migrate #{oldname}."
|
odie "Remove #{new_cellar} manually and run brew migrate #{oldname}."
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user