mattermost / mattermost/react-native-network-client
Patches to the Pods can be sometimes applied multiple times
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 48
- Forks
- 26
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 2
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.apply
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the Pod::Patch implementation that finds ios/patches/*.diff and compare it with the supplied script. Reproduce the case where node_modules is reinstalled while Pods remain, then verify that an already-applied patch is skipped and an unapplied patch still applies successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, ruby
- Domain
- build-system, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100