@@ -54,25 +54,24 @@ def self.merge_string_node(main_strings_xml, library, lib_string_node)
54
54
# Search for the string in the main file
55
55
result = :added
56
56
main_strings_xml . xpath ( '//string' ) . each do |main_string_node |
57
- if main_string_node . attr ( 'name' ) == string_name
58
- # Skip if the string has the content_override tag
59
- return :skipped if skip_string_by_tag? ( main_string_node )
60
-
61
- # If nodes are equivalent, skip
62
- return :found if lib_string_node =~ main_string_node
63
-
64
- # The string needs an update
65
- if main_string_node . attr ( 'tools:ignore' ) . nil?
66
- # No `tools:ignore` attribute; completely replace existing main string node with lib's one
67
- add_xml_attributes! ( lib_string_node , library )
68
- main_string_node . replace lib_string_node
69
- else
70
- # Has the `tools:ignore` flag; update the content without touching the other existing attributes
71
- add_xml_attributes! ( main_string_node , library )
72
- main_string_node . content = string_content
73
- end
74
- return :updated
57
+ next unless main_string_node . attr ( 'name' ) == string_name
58
+ # Skip if the string has the content_override tag
59
+ return :skipped if skip_string_by_tag? ( main_string_node )
60
+
61
+ # If nodes are equivalent, skip
62
+ return :found if lib_string_node =~ main_string_node
63
+
64
+ # The string needs an update
65
+ if main_string_node . attr ( 'tools:ignore' ) . nil?
66
+ # No `tools:ignore` attribute; completely replace existing main string node with lib's one
67
+ add_xml_attributes! ( lib_string_node , library )
68
+ main_string_node . replace lib_string_node
69
+ else
70
+ # Has the `tools:ignore` flag; update the content without touching the other existing attributes
71
+ add_xml_attributes! ( main_string_node , library )
72
+ main_string_node . content = string_content
75
73
end
74
+ return :updated
76
75
end
77
76
78
77
# String not found, or removed because needing update and not in the exclusion list: add to the main file
@@ -91,14 +90,13 @@ def self.verify_string(main_strings_xml, library, lib_string_node)
91
90
92
91
# Search for the string in the main file
93
92
main_strings_xml . xpath ( '//string' ) . each do |main_string_node |
94
- if main_string_node . attr ( 'name' ) == string_name
95
- # Skip if the string has the content_override tag
96
- return if skip_string_by_tag? ( main_string_node )
93
+ next unless main_string_node . attr ( 'name' ) == string_name
94
+ # Skip if the string has the content_override tag
95
+ return if skip_string_by_tag? ( main_string_node )
97
96
98
- # Check if up-to-date
99
- UI . user_error! ( "String #{ string_name } [#{ string_content } ] has been updated in the main file but not in the library #{ library [ :library ] } ." ) if main_string_node . content != string_content
100
- return
101
- end
97
+ # Check if up-to-date
98
+ UI . user_error! ( "String #{ string_name } [#{ string_content } ] has been updated in the main file but not in the library #{ library [ :library ] } ." ) if main_string_node . content != string_content
99
+ return
102
100
end
103
101
104
102
# String not found and not in the exclusion list
@@ -180,22 +178,22 @@ def self.verify_lib(main, library, source_diff)
180
178
181
179
def self . verify_local_diff ( main , library , main_strings , lib_strings )
182
180
`git diff #{ main } ` . each_line do |line |
183
- if line . start_with? ( '+ ' ) || line . start_with? ( '- ' )
184
- diffs = line . gsub ( / \s +/m , ' ' ) . strip . split
185
- diffs . each do | diff |
186
- verify_diff ( diff , main_strings , lib_strings , library )
187
- end
181
+ next unless line . start_with? ( '+ ' ) || line . start_with? ( '- ' )
182
+
183
+ diffs = line . gsub ( / \s +/m , ' ' ) . strip . split
184
+ diffs . each do | diff |
185
+ verify_diff ( diff , main_strings , lib_strings , library )
188
186
end
189
187
end
190
188
end
191
189
192
190
def self . verify_pr_diff ( main , library , main_strings , lib_strings , source_diff )
193
191
source_diff . each_line do |line |
194
- if line . start_with? ( '+ ' ) || line . start_with? ( '- ' )
195
- diffs = line . gsub ( / \s +/m , ' ' ) . strip . split
196
- diffs . each do | diff |
197
- verify_diff ( diff , main_strings , lib_strings , library )
198
- end
192
+ next unless line . start_with? ( '+ ' ) || line . start_with? ( '- ' )
193
+
194
+ diffs = line . gsub ( / \s +/m , ' ' ) . strip . split
195
+ diffs . each do | diff |
196
+ verify_diff ( diff , main_strings , lib_strings , library )
199
197
end
200
198
end
201
199
end
0 commit comments