Skip to content

Commit 0034349

Browse files
committed
Updated script
1 parent 865a612 commit 0034349

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

scripts/bumpVersions.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ def locateFiles(cond: PathPredicate) -> PathList:
104104
'''
105105
found = []
106106
for dirname, dirnames, filenames in os.walk('.'):
107-
if 'DerivedData' in dirnames:
108-
dirnames.remove('DerivedData')
107+
for exclude in ['DerivedData', '.build']:
108+
if exclude in dirnames:
109+
dirnames.remove(exclude)
109110
for path in filenames:
110111
if cond(path):
111112
found.append(os.path.join(dirname, path))
@@ -167,14 +168,16 @@ def cond(path):
167168

168169

169170
def updateUIContents(contents: str, marketingVersion: MarketingVersion) -> str:
170-
return re.sub(r'(userLabel="APP_VERSION".*(text|title)=)"[^\"]*"',
171-
f'\\1"v{marketingVersion}"', contents)
171+
contents1 = re.sub(r'(text|title)="[^\"]*"(.*userLabel="APP_VERSION")', f'\\1="v{marketingVersion}"\\2', contents)
172+
contents2 = re.sub(r'(userLabel="APP_VERSION".*(text|title))="[^\"]*"', f'\\1="v{marketingVersion}"', contents1)
173+
return contents2
172174

173175

174176
def updateUIFiles(uiFiles: PathList, marketingVersion: MarketingVersion):
175177
for path in uiFiles:
176178
log(f"processing UI file '{path}'")
177179
contents = getAndBackupFile(path)
180+
contents = updateUIContents(contents, marketingVersion)
178181
saveFile(path, contents)
179182

180183

@@ -303,6 +306,12 @@ def test_updateUIContents(self):
303306
contents = 'foo userLabel="APP_VERSION" title="blah" blah'
304307
self.assertEqual(f'foo userLabel="APP_VERSION" title="v{marketingVersion}" blah',
305308
updateUIContents(contents, marketingVersion))
309+
contents = 'foo text="BLAH" between userLabel="APP_VERSION" silly'
310+
self.assertEqual(f'foo text="v{marketingVersion}" between userLabel="APP_VERSION" silly',
311+
updateUIContents(contents, marketingVersion))
312+
contents = '<textFieldCell key="cell" lineBreakMode="clipping" title="v3.0.0" id="p30-Bk-a8R" userLabel="APP_VERSION">'
313+
self.assertEqual(f'<textFieldCell key="cell" lineBreakMode="clipping" title="v{marketingVersion}" id="p30-Bk-a8R" userLabel="APP_VERSION">',
314+
updateUIContents(contents, marketingVersion))
306315

307316
def test_UpdateInfoFile(self):
308317
contents = '''

0 commit comments

Comments
 (0)