@@ -108,19 +108,19 @@ def self.option_globally_or_per_branch_string(opts)
108
108
from_option = "from_#{ option_name } " . to_sym
109
109
to_option = "to_#{ option_name } " . to_sym
110
110
parser . on ( "--#{ flag } " , "#{ desc } globally" ) do |x |
111
- validate_option ( opts [ :validator ] , x ) if opts [ :validator ]
111
+ validate_option ( opts [ :validator ] , x )
112
112
translated = translate_option ( opts [ :translator ] , x )
113
113
options [ to_option ] ||= translated
114
114
options [ from_option ] ||= translated
115
115
post_process ( opts [ :post_process ] , options )
116
116
end
117
117
parser . on ( "--to-#{ flag } " , "#{ desc } for the to branch" ) do |x |
118
- validate_option ( opts [ :validator ] , x ) if opts [ :validator ]
118
+ validate_option ( opts [ :validator ] , x )
119
119
options [ to_option ] = translate_option ( opts [ :translator ] , x )
120
120
post_process ( opts [ :post_process ] , options )
121
121
end
122
122
parser . on ( "--from-#{ flag } " , "#{ desc } for the from branch" ) do |x |
123
- validate_option ( opts [ :validator ] , x ) if opts [ :validator ]
123
+ validate_option ( opts [ :validator ] , x )
124
124
options [ from_option ] = translate_option ( opts [ :translator ] , x )
125
125
post_process ( opts [ :post_process ] , options )
126
126
end
@@ -143,20 +143,20 @@ def self.option_globally_or_per_branch_array(opts = {})
143
143
from_option = "from_#{ option_name } " . to_sym
144
144
to_option = "to_#{ option_name } " . to_sym
145
145
parser . on ( "--#{ flag } " , Array , "#{ desc } globally" ) do |x |
146
- validate_option ( opts [ :validator ] , x ) if opts [ :validator ]
146
+ validate_option ( opts [ :validator ] , x )
147
147
translated = translate_option ( opts [ :translator ] , x )
148
148
options [ to_option ] ||= [ ]
149
149
options [ to_option ] . concat translated
150
150
options [ from_option ] ||= [ ]
151
151
options [ from_option ] . concat translated
152
152
end
153
153
parser . on ( "--to-#{ flag } " , Array , "#{ desc } for the to branch" ) do |x |
154
- validate_option ( opts [ :validator ] , x ) if opts [ :validator ]
154
+ validate_option ( opts [ :validator ] , x )
155
155
options [ to_option ] ||= [ ]
156
156
options [ to_option ] . concat translate_option ( opts [ :translator ] , x )
157
157
end
158
158
parser . on ( "--from-#{ flag } " , Array , "#{ desc } for the from branch" ) do |x |
159
- validate_option ( opts [ :validator ] , x ) if opts [ :validator ]
159
+ validate_option ( opts [ :validator ] , x )
160
160
options [ from_option ] ||= [ ]
161
161
options [ from_option ] . concat translate_option ( opts [ :translator ] , x )
162
162
end
@@ -168,6 +168,7 @@ def self.option_globally_or_per_branch_array(opts = {})
168
168
# @param validator [Code] Validation function
169
169
# @param value [?] Value to validate (typically a String but can really be anything)
170
170
def self . validate_option ( validator , value )
171
+ return true unless validator
171
172
validator . call ( value )
172
173
end
173
174
0 commit comments