File tree Expand file tree Collapse file tree 1 file changed +19
-10
lines changed
lib/cocoapods-patch/command/patch Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -30,15 +30,24 @@ def run
3030
3131# also used from the post-install hook
3232def apply_patch ( patch_file )
33- check_cmd = "git apply --check #{ patch_file } --directory=Pods -p2 2> /dev/null"
34- can_apply = system ( check_cmd )
35- if can_apply
36- apply_cmd = check_cmd . gsub ( '--check ' , '' )
37- did_apply = system ( apply_cmd )
38- if did_apply
39- Pod ::UI . puts "Successfully applied #{ patch_file } "
40- else
41- Pod ::UI . warn "Failed to apply #{ patch_file } "
33+ working_dir = Dir . pwd
34+ repo_root = `git rev-parse --show-toplevel` . strip
35+ ios_project_path = Pathname . new ( working_dir ) . relative_path_from ( Pathname . new ( repo_root ) )
36+
37+ directory_arg = ( ios_project_path . to_s . eql? "." ) ? "Pods" : File . join ( ios_project_path , 'Pods' )
38+
39+ Dir . chdir ( repo_root ) {
40+ check_cmd = "git apply --check #{ patch_file } --directory=#{ directory_arg } -p2 2> /dev/null"
41+
42+ can_apply = system ( check_cmd )
43+ if can_apply
44+ apply_cmd = check_cmd . gsub ( '--check ' , '' )
45+ did_apply = system ( apply_cmd )
46+ if did_apply
47+ Pod ::UI . puts "Successfully applied #{ patch_file } "
48+ else
49+ Pod ::UI . warn "Failed to apply #{ patch_file } "
50+ end
4251 end
43- end
52+ }
4453end
You can’t perform that action at this time.
0 commit comments