rpatch 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +16 -7
- data/lib/rpatch/entry.rb +18 -12
- data/lib/rpatch/hunk.rb +181 -119
- data/lib/rpatch/patch.rb +29 -20
- data/lib/rpatch/runner.rb +5 -2
- data/lib/rpatch/utils.rb +121 -0
- data/lib/rpatch/version.rb +1 -1
- data/spec/patch_file_regexp_spec.rb +6 -8
- data/spec/patch_file_spec.rb +10 -3
- data/spec/patch_hunk_with_location_spec.rb +149 -0
- data/spec/patch_hunk_with_qmark_exp_spec.rb +152 -0
- data/spec/patch_hunk_with_regex_spec.rb +72 -0
- data/t/t0000-patch-file.sh +27 -28
- data/t/t0010-patch-special-direction.sh +336 -0
- data/t/t0100-patch-directory.sh +89 -42
- metadata +59 -73
data/t/t0100-patch-directory.sh
CHANGED
@@ -10,15 +10,15 @@ test_description='patch file test'
|
|
10
10
|
############################################################
|
11
11
|
|
12
12
|
cat > diff <<EOF
|
13
|
-
diff -u
|
14
|
-
---
|
13
|
+
diff -u /dev/null b/foo
|
14
|
+
--- /dev/null 2013-11-04 16:01:56.000000000 +0800
|
15
15
|
+++ b/foo 2013-11-04 16:01:59.000000000 +0800
|
16
16
|
@@ add two lines
|
17
17
|
+baz
|
18
18
|
+foo
|
19
|
-
diff -u
|
20
|
-
---
|
21
|
-
+++ b/bar 2013-11-04 16:01:59.000000000 +0800
|
19
|
+
diff -u /dev/null b/subdir/baz/bar
|
20
|
+
--- /dev/null 2013-11-04 16:01:56.000000000 +0800
|
21
|
+
+++ b/subdir/baz/bar 2013-11-04 16:01:59.000000000 +0800
|
22
22
|
@@ add two lines
|
23
23
|
+baz
|
24
24
|
+bar
|
@@ -28,14 +28,14 @@ cat > expect <<EOF
|
|
28
28
|
EOF
|
29
29
|
|
30
30
|
cat > expect_errlog <<EOF
|
31
|
-
|
32
|
-
|
31
|
+
ERROR: Multiple patch entries (2) have been found in patch <IO>
|
32
|
+
ERROR: Multiple patch entries (2) have been found in patch <IO>
|
33
33
|
EOF
|
34
34
|
|
35
35
|
test_expect_success 'cannot patch single file with multi patch entries' '
|
36
36
|
touch ! -f actual &&
|
37
37
|
touch actual &&
|
38
|
-
test_must_fail rpatch actual < diff 2>actual_errlog &&
|
38
|
+
test_must_fail rpatch -vv actual < diff 2>actual_errlog &&
|
39
39
|
test_cmp expect actual &&
|
40
40
|
test_cmp expect_errlog actual_errlog
|
41
41
|
'
|
@@ -44,7 +44,7 @@ test_expect_success 'cannot patch single file with multi patch entries' '
|
|
44
44
|
|
45
45
|
cat > expect_errlog <<EOF
|
46
46
|
Patched "output/foo".
|
47
|
-
Patched "output/bar".
|
47
|
+
Patched "output/subdir/baz/bar".
|
48
48
|
EOF
|
49
49
|
|
50
50
|
cat > expect_foo <<EOF
|
@@ -57,13 +57,42 @@ baz
|
|
57
57
|
bar
|
58
58
|
EOF
|
59
59
|
|
60
|
-
test_expect_success 'Patch
|
60
|
+
test_expect_success 'Patch to create newfiles' '
|
61
61
|
mkdir output &&
|
62
|
-
|
62
|
+
test ! -d output/subdir/baz &&
|
63
|
+
rpatch -vv output < diff 2>actual_errlog &&
|
63
64
|
test -f output/foo &&
|
64
|
-
test -f output/bar &&
|
65
|
+
test -f output/subdir/baz/bar &&
|
65
66
|
test_cmp expect_foo output/foo &&
|
66
|
-
test_cmp expect_bar output/bar &&
|
67
|
+
test_cmp expect_bar output/subdir/baz/bar &&
|
68
|
+
test_cmp expect_errlog actual_errlog
|
69
|
+
'
|
70
|
+
|
71
|
+
############################################################
|
72
|
+
|
73
|
+
cat > expect_errlog <<EOF
|
74
|
+
INFO: output/foo: Hunk 1 (add two lines) is already patched.
|
75
|
+
output/foo: nothing changed
|
76
|
+
INFO: output/subdir/baz/bar: Hunk 1 (add two lines) is already patched.
|
77
|
+
output/subdir/baz/bar: nothing changed
|
78
|
+
EOF
|
79
|
+
|
80
|
+
cat > expect_foo <<EOF
|
81
|
+
baz
|
82
|
+
foo
|
83
|
+
EOF
|
84
|
+
|
85
|
+
cat > expect_bar <<EOF
|
86
|
+
baz
|
87
|
+
bar
|
88
|
+
EOF
|
89
|
+
|
90
|
+
test_expect_success 'Patch to create newfiles (2): already patched warning' '
|
91
|
+
test_cmp expect_foo output/foo &&
|
92
|
+
test_cmp expect_bar output/subdir/baz/bar &&
|
93
|
+
rpatch -vv output < diff 2>actual_errlog &&
|
94
|
+
test_cmp expect_foo output/foo &&
|
95
|
+
test_cmp expect_bar output/subdir/baz/bar &&
|
67
96
|
test_cmp expect_errlog actual_errlog
|
68
97
|
'
|
69
98
|
|
@@ -79,9 +108,9 @@ diff -u a/foo b/foo
|
|
79
108
|
@@ tail
|
80
109
|
foo
|
81
110
|
+tail of foo ...
|
82
|
-
diff -u a/bar b/bar
|
83
|
-
--- a/bar 2013-11-04 16:01:56.000000000 +0800
|
84
|
-
+++ b/bar 2013-11-04 16:01:59.000000000 +0800
|
111
|
+
diff -u a/subdir/baz/bar b/subdir/baz/bar
|
112
|
+
--- a/subdir/baz/bar 2013-11-04 16:01:56.000000000 +0800
|
113
|
+
+++ b/subdir/baz/bar 2013-11-04 16:01:59.000000000 +0800
|
85
114
|
@@ heading
|
86
115
|
+heading of bar...
|
87
116
|
-baz
|
@@ -92,7 +121,7 @@ EOF
|
|
92
121
|
|
93
122
|
cat > expect_errlog <<EOF
|
94
123
|
Patched "output/foo".
|
95
|
-
Patched "output/bar".
|
124
|
+
Patched "output/subdir/baz/bar".
|
96
125
|
EOF
|
97
126
|
|
98
127
|
cat > expect_foo <<EOF
|
@@ -107,12 +136,12 @@ bar
|
|
107
136
|
tail of bar ...
|
108
137
|
EOF
|
109
138
|
|
110
|
-
test_expect_success 'Patch
|
111
|
-
rpatch output < diff 2>actual_errlog &&
|
139
|
+
test_expect_success 'Patch exist files' '
|
140
|
+
rpatch -vv output < diff 2>actual_errlog &&
|
112
141
|
test -f output/foo &&
|
113
|
-
test -f output/bar &&
|
142
|
+
test -f output/subdir/baz/bar &&
|
114
143
|
test_cmp expect_foo output/foo &&
|
115
|
-
test_cmp expect_bar output/bar &&
|
144
|
+
test_cmp expect_bar output/subdir/baz/bar &&
|
116
145
|
test_cmp expect_errlog actual_errlog
|
117
146
|
'
|
118
147
|
|
@@ -126,9 +155,9 @@ diff -u a/foo b/foo
|
|
126
155
|
heading of foo...
|
127
156
|
foobar
|
128
157
|
-tail of foo ...
|
129
|
-
diff -u a/bar b/bar
|
130
|
-
--- a/bar 2013-11-04 16:01:56.000000000 +0800
|
131
|
-
+++ b/bar 2013-11-04 16:01:59.000000000 +0800
|
158
|
+
diff -u a/subdir/baz/bar b/subdir/baz/bar
|
159
|
+
--- a/subdir/baz/bar 2013-11-04 16:01:56.000000000 +0800
|
160
|
+
+++ b/subdir/baz/bar 2013-11-04 16:01:59.000000000 +0800
|
132
161
|
@@ remove tail
|
133
162
|
heading of bar...
|
134
163
|
bar
|
@@ -138,7 +167,7 @@ EOF
|
|
138
167
|
cat > expect_errlog <<EOF
|
139
168
|
ERROR: output/foo: Hunk 1 (can not match) FAILED to apply. Match failed.
|
140
169
|
output/foo: nothing changed
|
141
|
-
Patched "output/bar".
|
170
|
+
Patched "output/subdir/baz/bar".
|
142
171
|
EOF
|
143
172
|
|
144
173
|
cat > expect_foo <<EOF
|
@@ -152,12 +181,12 @@ heading of bar...
|
|
152
181
|
bar
|
153
182
|
EOF
|
154
183
|
|
155
|
-
test_expect_success 'Patch
|
156
|
-
test_must_fail rpatch output < diff 2>actual_errlog &&
|
184
|
+
test_expect_success 'Patch one file fail, another success' '
|
185
|
+
test_must_fail rpatch -vv output < diff 2>actual_errlog &&
|
157
186
|
test -f output/foo &&
|
158
|
-
test -f output/bar &&
|
187
|
+
test -f output/subdir/baz/bar &&
|
159
188
|
test_cmp expect_foo output/foo &&
|
160
|
-
test_cmp expect_bar output/bar &&
|
189
|
+
test_cmp expect_bar output/subdir/baz/bar &&
|
161
190
|
test_cmp expect_errlog actual_errlog
|
162
191
|
'
|
163
192
|
|
@@ -167,21 +196,21 @@ cat > diff <<EOF
|
|
167
196
|
diff -u a/foo b/foo
|
168
197
|
--- a/foo 2013-11-04 16:01:56.000000000 +0800
|
169
198
|
+++ b/foo 2013-11-04 16:01:59.000000000 +0800
|
170
|
-
@@
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
diff -u a/bar b/bar
|
175
|
-
--- a/bar 2013-11-04 16:01:56.000000000 +0800
|
176
|
-
+++ b/bar 2013-11-04 16:01:59.000000000 +0800
|
199
|
+
@@ remove all
|
200
|
+
/-heading
|
201
|
+
/-foo
|
202
|
+
/-tail.*
|
203
|
+
diff -u a/subdir/baz/bar b/subdir/baz/bar
|
204
|
+
--- a/subdir/baz/bar 2013-11-04 16:01:56.000000000 +0800
|
205
|
+
+++ b/subdir/baz/bar 2013-11-04 16:01:59.000000000 +0800
|
177
206
|
@@ add tail
|
178
|
-
|
207
|
+
/ ^[bB][aA][rR]$
|
179
208
|
+tail of bar...
|
180
209
|
EOF
|
181
210
|
|
182
211
|
cat > expect_errlog <<EOF
|
183
212
|
Remove "output/foo".
|
184
|
-
Patched "output/bar".
|
213
|
+
Patched "output/subdir/baz/bar".
|
185
214
|
EOF
|
186
215
|
|
187
216
|
cat > expect_bar <<EOF
|
@@ -190,11 +219,29 @@ bar
|
|
190
219
|
tail of bar...
|
191
220
|
EOF
|
192
221
|
|
193
|
-
test_expect_success 'Patch
|
194
|
-
rpatch -p1 output < diff 2>actual_errlog &&
|
222
|
+
test_expect_success 'Patch to remove file' '
|
223
|
+
rpatch -vv -p1 output < diff 2>actual_errlog &&
|
224
|
+
test ! -f output/foo &&
|
225
|
+
test -f output/subdir/baz/bar &&
|
226
|
+
test_cmp expect_bar output/subdir/baz/bar &&
|
227
|
+
test_cmp expect_errlog actual_errlog
|
228
|
+
'
|
229
|
+
|
230
|
+
############################################################
|
231
|
+
|
232
|
+
cat > expect_errlog <<EOF
|
233
|
+
INFO: output/foo: Hunk 1 (remove all) is already patched.
|
234
|
+
output/foo: nothing changed
|
235
|
+
INFO: output/subdir/baz/bar: Hunk 1 (add tail) is already patched.
|
236
|
+
output/subdir/baz/bar: nothing changed
|
237
|
+
EOF
|
238
|
+
|
239
|
+
test_expect_success 'Patch to remove file (2)' '
|
240
|
+
test ! -f output/foo &&
|
241
|
+
rpatch -vv -p1 output < diff 2>actual_errlog &&
|
195
242
|
test ! -f output/foo &&
|
196
|
-
test -f output/bar &&
|
197
|
-
test_cmp expect_bar output/bar &&
|
243
|
+
test -f output/subdir/baz/bar &&
|
244
|
+
test_cmp expect_bar output/subdir/baz/bar &&
|
198
245
|
test_cmp expect_errlog actual_errlog
|
199
246
|
'
|
200
247
|
|
metadata
CHANGED
@@ -1,77 +1,59 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpatch
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- Jiang Xin
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
|
12
|
+
date: 2013-11-08 00:00:00 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '1.3'
|
22
|
-
type: :development
|
23
16
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rake
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- &id002
|
20
|
+
- ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
38
23
|
type: :development
|
24
|
+
version_requirements: *id001
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
39
27
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '2.6'
|
28
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- *id002
|
54
31
|
type: :development
|
32
|
+
version_requirements: *id003
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
55
35
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
version: '2.6'
|
36
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- *id002
|
39
|
+
type: :development
|
40
|
+
version_requirements: *id004
|
62
41
|
description: A patch utility support regexp in patchfile.
|
63
|
-
email:
|
42
|
+
email:
|
64
43
|
- worldhello.net@gmail.com
|
65
|
-
executables:
|
44
|
+
executables:
|
66
45
|
- rpatch
|
67
46
|
extensions: []
|
47
|
+
|
68
48
|
extra_rdoc_files: []
|
69
|
-
|
49
|
+
|
50
|
+
files:
|
70
51
|
- lib/rpatch/entry.rb
|
71
52
|
- lib/rpatch/error.rb
|
72
53
|
- lib/rpatch/hunk.rb
|
73
54
|
- lib/rpatch/patch.rb
|
74
55
|
- lib/rpatch/runner.rb
|
56
|
+
- lib/rpatch/utils.rb
|
75
57
|
- lib/rpatch/version.rb
|
76
58
|
- README.md
|
77
59
|
- LICENSE.txt
|
@@ -79,54 +61,58 @@ files:
|
|
79
61
|
- spec/patch_file_regexp_spec.rb
|
80
62
|
- spec/patch_file_spec.rb
|
81
63
|
- spec/patch_hunk_spec.rb
|
64
|
+
- spec/patch_hunk_with_location_spec.rb
|
65
|
+
- spec/patch_hunk_with_qmark_exp_spec.rb
|
66
|
+
- spec/patch_hunk_with_regex_spec.rb
|
82
67
|
- spec/spec_helper.rb
|
83
68
|
- t/Makefile
|
84
69
|
- t/README
|
85
70
|
- t/aggregate-results.sh
|
86
71
|
- t/t0000-patch-file.sh
|
72
|
+
- t/t0010-patch-special-direction.sh
|
87
73
|
- t/t0100-patch-directory.sh
|
88
74
|
- t/test-lib-functions.sh
|
89
75
|
- t/test-lib.sh
|
90
76
|
- bin/rpatch
|
91
77
|
homepage: http://github.com/jiangxin/rpatch
|
92
|
-
licenses:
|
78
|
+
licenses:
|
93
79
|
- MIT
|
80
|
+
metadata: {}
|
81
|
+
|
94
82
|
post_install_message:
|
95
|
-
rdoc_options:
|
83
|
+
rdoc_options:
|
96
84
|
- --charset=UTF-8
|
97
|
-
require_paths:
|
85
|
+
require_paths:
|
98
86
|
- - lib
|
99
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
- !ruby/object:Gem::Version
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
104
91
|
version: 1.8.7
|
105
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
-
|
107
|
-
|
108
|
-
- - ! '>='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
segments:
|
112
|
-
- 0
|
113
|
-
hash: 2306715700148282844
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- *id002
|
114
95
|
requirements: []
|
96
|
+
|
115
97
|
rubyforge_project:
|
116
|
-
rubygems_version:
|
98
|
+
rubygems_version: 2.0.13
|
117
99
|
signing_key:
|
118
|
-
specification_version:
|
119
|
-
summary: rpatch-0.0.
|
120
|
-
test_files:
|
100
|
+
specification_version: 4
|
101
|
+
summary: rpatch-0.0.2
|
102
|
+
test_files:
|
121
103
|
- spec/patch_entry_spec.rb
|
122
104
|
- spec/patch_file_regexp_spec.rb
|
123
105
|
- spec/patch_file_spec.rb
|
124
106
|
- spec/patch_hunk_spec.rb
|
107
|
+
- spec/patch_hunk_with_location_spec.rb
|
108
|
+
- spec/patch_hunk_with_qmark_exp_spec.rb
|
109
|
+
- spec/patch_hunk_with_regex_spec.rb
|
125
110
|
- spec/spec_helper.rb
|
126
111
|
- t/Makefile
|
127
112
|
- t/README
|
128
113
|
- t/aggregate-results.sh
|
129
114
|
- t/t0000-patch-file.sh
|
115
|
+
- t/t0010-patch-special-direction.sh
|
130
116
|
- t/t0100-patch-directory.sh
|
131
117
|
- t/test-lib-functions.sh
|
132
118
|
- t/test-lib.sh
|