-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: calculate changes hash in an integration test
Signed-off-by: Nick Gerace <nick@systeminit.com>
- Loading branch information
1 parent
83cee1c
commit e715c78
Showing
10 changed files
with
110 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use si_events::ChangesHash; | ||
|
||
use crate::{workspace_snapshot::graph::detector::Change, DalContext, WorkspaceSnapshot}; | ||
|
||
use super::ChangeSetApprovalError; | ||
|
||
type Result<T> = std::result::Result<T, ChangeSetApprovalError>; | ||
|
||
pub async fn changes_hash(ctx: &DalContext) -> Result<ChangesHash> { | ||
let changes = detect_changes_from_head(ctx).await?; | ||
let mut hasher = ChangesHash::hasher(); | ||
for change in changes { | ||
hasher.update(change.merkle_tree_hash.as_bytes()); | ||
} | ||
Ok(hasher.finalize()) | ||
} | ||
|
||
pub async fn detect_changes_from_head(ctx: &DalContext) -> Result<Vec<Change>> { | ||
let head_change_set_id = ctx.get_workspace_default_change_set_id().await?; | ||
let head_snapshot = WorkspaceSnapshot::find_for_change_set(&ctx, head_change_set_id).await?; | ||
let mut changes = head_snapshot | ||
.detect_changes(&ctx.workspace_snapshot()?.clone()) | ||
.await?; | ||
|
||
changes.sort_by_key(|c| c.id); | ||
Ok(changes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 5 additions & 10 deletions
15
lib/sdf-server/src/service/v2/change_set/approval_status.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters