@@ -316,14 +316,16 @@ def get_pod_files(dirs_and_files):
316
316
RE_PODFILE_VERSION = re .compile (
317
317
r"\s+pod '(?P<pod_name>.+)', '(?P<version>.+)'\n" )
318
318
319
- def modify_pod_file (pod_file , pod_version_map , dryrun = True ):
319
+ def modify_pod_file (pod_file , pod_version_map , dryrun = True , ignore_ios_versions = [] ):
320
320
"""Update pod versions in specified podfile.
321
321
322
322
Args:
323
323
pod_file (str): Absolute path to a podfile.
324
324
pod_version_map (dict): Map of podnames to their respective version.
325
325
dryrun (bool, optional): Just print the substitutions.
326
326
Do not write to file. Defaults to True.
327
+ ignore_ios_versions (set): If the old version number for a pod
328
+ matches one of these, don't update it.
327
329
"""
328
330
global logfile_lines
329
331
to_update = False
@@ -341,9 +343,14 @@ def modify_pod_file(pod_file, pod_version_map, dryrun=True):
341
343
match = re .match (RE_PODFILE_VERSION , line )
342
344
if match :
343
345
pod_name = match ['pod_name' ]
346
+ skip_line = False
347
+ # Check if the old version matches anything in ignore_ios_versions
348
+ for ignore_version in ignore_ios_versions :
349
+ if ignore_version in match ['version' ]:
350
+ skip_line = True
344
351
# Firebase/Auth -> Firestore (due to being a subspec)
345
352
pod_name_key = re .sub (r'/.*$' , '' , pod_name )
346
- if pod_name_key in pod_version_map :
353
+ if pod_name_key in pod_version_map and not skip_line :
347
354
latest_version = pod_version_map [pod_name_key ]
348
355
substituted_line = line .replace (match ['version' ], latest_version )
349
356
if substituted_line != line :
@@ -690,10 +697,12 @@ def parse_cmdline_args():
690
697
parser .add_argument ('--skip_ios' , action = 'store_true' ,
691
698
help = 'Skip iOS pod version update completely.' )
692
699
# TODO: remove default values when Ads SDK does not need to be pinned.
693
- parser .add_argument ('--ignore_ios_pods' , nargs = '+' ,
694
- default = ('Google-Mobile-Ads-SDK' ,),
700
+ parser .add_argument ('--ignore_ios_pods' , nargs = '+' , default = (),
695
701
help = 'Ignore iOS pods which have any of the items specified in '
696
702
'this list as substrings.' )
703
+ parser .add_argument ('--ignore_ios_versions' , nargs = '+' , default = ('cppsdk' ,),
704
+ help = 'Do not update any iOS pods when the old version contains '
705
+ 'any of the items specified in this list as substrings.' )
697
706
parser .add_argument ('--podfiles' , nargs = '+' , default = (os .getcwd (),),
698
707
help = 'List of pod files or directories containing podfiles' )
699
708
parser .add_argument ('--specs_repo' ,
@@ -755,7 +764,8 @@ def main():
755
764
pod_files = get_files (args .podfiles , file_extension = '' , file_name = 'Podfile' ,
756
765
ignore_directories = set (args .ignore_directories ))
757
766
for pod_file in pod_files :
758
- modify_pod_file (pod_file , latest_pod_versions_map , args .dryrun )
767
+ modify_pod_file (pod_file , latest_pod_versions_map , args .dryrun ,
768
+ args .ignore_ios_versions )
759
769
for readme_file in readme_files :
760
770
modify_readme_file_pods (readme_file , latest_pod_versions_map , args .dryrun )
761
771
0 commit comments