-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Probably when you remove and reinstall node_modules but don't remove Pods, patches are applied multiple times.
Here is the fixed script that checks if patch was already applied:
require 'cocoapods'
module Pod
class Patch
def find_patches
return Dir["ios/patches/*.diff"]
end
def apply_patch(file)
repo_root = `git rev-parse --show-toplevel`.strip
directory_arg = Dir.glob(Pathname(repo_root).join("**/**/Pods")).first.sub("#{repo_root}/", "")
puts "HEY #{file}"
Dir.chdir(repo_root) {
check_reverse_cmd = "git apply --check --reverse '#{file}' --directory='#{directory_arg}' -p2 2> /dev/null"
can_reverse = system(check_reverse_cmd)
if can_reverse
Pod::UI.puts "Patch #{file} already applied, skipping"
else
check_cmd = check_reverse_cmd.gsub('--reverse ', '')
can_apply = system(check_cmd)
if can_apply
apply_cmd = check_cmd.gsub('--check ', '')
did_apply = system(apply_cmd)
if did_apply
Pod::UI.puts "Successfully applied #{file} π"
else
Pod::UI.warn "Error: failed to apply #{file}"
end
end
end
}
end
def apply
files = find_patches()
files.each do |f|
apply_patch("#{Dir.pwd}/#{f}")
end
end
end
end
p = Pod::Patch.new
p.applyReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels