Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Update the check_schema_delta script to account for when the schema…
Browse files Browse the repository at this point in the history
… version has been bumped locally (#15466)
  • Loading branch information
H-Shay authored Apr 25, 2023
1 parent 8e97394 commit 710502c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/15466.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update the check_schema_delta script to account for when the schema version has been bumped locally.
26 changes: 24 additions & 2 deletions scripts-dev/check_schema_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,32 @@ def main(force_colors: bool) -> None:
exec(r, locals)
current_schema_version = locals["SCHEMA_VERSION"]

click.secho(f"Current schema version: {current_schema_version}")

diffs: List[git.Diff] = repo.remote().refs.develop.commit.diff(None)

# Get the schema version of the local file to check against current schema on develop
with open("synapse/storage/schema/__init__.py", "r") as file:
local_schema = file.read()
new_locals: Dict[str, Any] = {}
exec(local_schema, new_locals)
local_schema_version = new_locals["SCHEMA_VERSION"]

if local_schema_version != current_schema_version:
# local schema version must be +/-1 the current schema version on develop
if abs(local_schema_version - current_schema_version) != 1:
click.secho(
"The proposed schema version has diverged more than one version from develop, please fix!",
fg="red",
bold=True,
color=force_colors,
)
click.get_current_context().exit(1)

# right, we've changed the schema version within the allowable tolerance so
# let's now use the local version as the canonical version
current_schema_version = local_schema_version

click.secho(f"Current schema version: {current_schema_version}")

seen_deltas = False
bad_files = []
for diff in diffs:
Expand Down

0 comments on commit 710502c

Please sign in to comment.