Skip to content

Commit

Permalink
Fix set-version script corrupting files when new version is shorter t…
Browse files Browse the repository at this point in the history
…han old one

Summary: We were leaving the last bits of the previous string around if writing a new file which is shorter. See 30b697d for an example.

Reviewed By: cortinico

Differential Revision: D47824696

fbshipit-source-id: 82ebafd9cd1720752cbc62ea93c5b9362395d5c8
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Jul 28, 2023
1 parent 44507ec commit c18e256
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions set-version.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@
with open("gradle.properties", "r+") as f:
new_contents = re.sub(r"VERSION_NAME=.*", f"VERSION_NAME={version}", f.read())
f.seek(0)
f.truncate()
f.write(new_contents)


with open("javascript/package.json", "r+") as f:
new_contents = re.sub(r'"version": ".*",', f'"version": "{version}",', f.read())
print(new_contents)
f.seek(0)
f.truncate()
f.write(new_contents)

with open("Yoga.podspec", "r+") as f:
new_contents = re.sub(
r"spec\.version = '.*'", f"spec.version = '{version}'", f.read()
)
f.seek(0)
f.truncate()
f.write(new_contents)

0 comments on commit c18e256

Please sign in to comment.