cocoapods-patch 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/cocoapods-patch.rb +1 -0
- data/lib/cocoapods-patch/command.rb +3 -0
- data/lib/cocoapods-patch/command/patch.rb +12 -0
- data/lib/cocoapods-patch/command/patch/apply.rb +42 -0
- data/lib/cocoapods-patch/command/patch/create.rb +54 -0
- data/lib/cocoapods-patch/gem_version.rb +4 -0
- data/lib/cocoapods-patch/hook.rb +14 -0
- data/lib/cocoapods_plugin.rb +2 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1906c058ad8d231b40db3b069f987234f90d5e8fff70f61196ed785f18787c46
|
4
|
+
data.tar.gz: 1a59dd3429f39519559aa6d7807c3cc94db9178551e492422844bd86a7ebdaea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b20fefdce67bafc583858bce2a4f5fa8f6f8996b587ac27b359917422f5d7d8edb2cec2af0a5c16735777015a37c23380af3c78f4017e89ce2943d94f4c91ef
|
7
|
+
data.tar.gz: d578b7a256154fe8f0cafea6f4c9eb7845a8d8a98868f43e15448e025acb4b3836d5f3d47d94a3933d16bdf405601ed89b203fa7b81f514527b6789310c6bfad
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-patch/gem_version'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class Patch < Command
|
4
|
+
class Apply < Patch
|
5
|
+
self.summary = 'Applies a patch to an installed Pod'
|
6
|
+
|
7
|
+
self.arguments = [
|
8
|
+
CLAide::Argument.new('NAME', true)
|
9
|
+
]
|
10
|
+
|
11
|
+
def initialize(argv)
|
12
|
+
@name = argv.shift_argument
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def validate!
|
17
|
+
super
|
18
|
+
help! 'A Pod name is required.' unless @name
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
apply_patch patch_file
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# also used from the post-install hook
|
30
|
+
def apply_patch(patch_file)
|
31
|
+
check_cmd = "git apply --check #{patch_file} --directory=Pods -p2 2> /dev/null"
|
32
|
+
can_apply = system(check_cmd)
|
33
|
+
if can_apply
|
34
|
+
apply_cmd = check_cmd.gsub('--check ', '')
|
35
|
+
did_apply = system(apply_cmd)
|
36
|
+
if did_apply
|
37
|
+
UI.puts "Successfully applied #{patch_file}"
|
38
|
+
else
|
39
|
+
UI.warn "Failed to apply #{patch_file}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Patch < Command
|
6
|
+
class Create < Patch
|
7
|
+
self.description = <<-DESC
|
8
|
+
Creates a patch file comparing your local Pod changes to the upstream
|
9
|
+
version specified in your Podfile. The patch is saved into the `patches`
|
10
|
+
directory.
|
11
|
+
DESC
|
12
|
+
|
13
|
+
self.arguments = [
|
14
|
+
CLAide::Argument.new('NAME', true)
|
15
|
+
]
|
16
|
+
|
17
|
+
def initialize(argv)
|
18
|
+
@name = argv.shift_argument
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
def validate!
|
23
|
+
super
|
24
|
+
help! 'A Pod name is required.' unless @name
|
25
|
+
end
|
26
|
+
|
27
|
+
def run
|
28
|
+
Dir.mktmpdir('cocoapods-patch-', config.project_root) do |work_dir|
|
29
|
+
sandbox = Pod::Sandbox.new(work_dir)
|
30
|
+
installer = Pod::Installer.new(sandbox, config.podfile)
|
31
|
+
installer.clean_install = true
|
32
|
+
|
33
|
+
installer.prepare
|
34
|
+
installer.resolve_dependencies
|
35
|
+
|
36
|
+
pod_installer = installer.send :create_pod_installer, @name
|
37
|
+
pod_installer.install!
|
38
|
+
|
39
|
+
theirs = Pathname.new(work_dir).join(@name).relative_path_from(config.project_root)
|
40
|
+
ours = config.project_pods_root.join(@name).relative_path_from(config.project_root)
|
41
|
+
gen_diff_cmd = "git diff --no-index #{theirs} #{ours} > #{patch_file}"
|
42
|
+
|
43
|
+
did_succeed = system(gen_diff_cmd)
|
44
|
+
if not did_succeed.nil?
|
45
|
+
UI.puts "Created patch #{patch_file}"
|
46
|
+
else
|
47
|
+
UI.warn "Error creating patch for #{@name}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'pathname'
|
3
|
+
require_relative 'command/patch/apply'
|
4
|
+
|
5
|
+
module CocoapodsPatch
|
6
|
+
module Hooks
|
7
|
+
Pod::HooksManager.register('cocoapods-patch', :post_install) do |context|
|
8
|
+
Pod::UI.puts 'Applying patches if necessary'
|
9
|
+
patches_dir = Pathname.new(context.sandbox_root) + '..' + 'patches'
|
10
|
+
patches = patches_dir.each_child.select { |c| c.to_s.end_with?('.diff') }
|
11
|
+
patches.each { |p| apply_patch(p) }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-patch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Double Symmetry
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Create & apply patches to Pods
|
42
|
+
email:
|
43
|
+
- dev@doublesymmetry.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- lib/cocoapods-patch.rb
|
49
|
+
- lib/cocoapods-patch/command.rb
|
50
|
+
- lib/cocoapods-patch/command/patch.rb
|
51
|
+
- lib/cocoapods-patch/command/patch/apply.rb
|
52
|
+
- lib/cocoapods-patch/command/patch/create.rb
|
53
|
+
- lib/cocoapods-patch/gem_version.rb
|
54
|
+
- lib/cocoapods-patch/hook.rb
|
55
|
+
- lib/cocoapods_plugin.rb
|
56
|
+
homepage: https://github.com/DoubleSymmetry/cocoapods-patch
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubygems_version: 3.0.3
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Create & apply patches to Pods
|
79
|
+
test_files: []
|