Skip to content

Commit

Permalink
Merge pull request #4769 from opsmill/pog-sort-hashes
Browse files Browse the repository at this point in the history
Sort hashes of signature fields and save branch hash back to DB if the DB hash is incorrect
  • Loading branch information
ogenstad authored Oct 30, 2024
2 parents 638df73 + 7125fdb commit 385513e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions backend/infrahub/core/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ async def initialization(db: InfrahubDatabase) -> None:
hash_new=default_branch.active_schema_hash.main,
branch=default_branch.name,
)
await default_branch.save(db=db)

for branch in list(registry.branch.values()):
if branch.name in [default_branch.name, GLOBAL_BRANCH_NAME]:
Expand All @@ -175,6 +176,7 @@ async def initialization(db: InfrahubDatabase) -> None:
f" {hash_in_db!r} >> {branch.active_schema_hash.main!r}",
branch=branch.name,
)
await branch.save(db=db)

# ---------------------------------------------------
# Load Default Namespace
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def _get_signature_field(cls, value: Any) -> list[bytes]:
else:
hashes.append(cls._get_hash_value(value))

return hashes
return sorted(hashes)

@property
def _sorting_id(self) -> tuple[Any]:
Expand Down

0 comments on commit 385513e

Please sign in to comment.