MCPcopy Create free account
hub / github.com/EpicGames/lore / commit_link_only

Function commit_link_only

lore-revision/src/commit.rs:739–929  ·  view source on GitHub ↗
(
    repository: Arc<RepositoryContext>,
    token: RepositoryWriteToken,
    message: String,
    link_path: String,
    keys: LoreArray<LoreString>,
    values: LoreArray<LoreString>,
    formats: 

Source from the content-addressed store, hash-verified

737/// state so the updated pin is visible in `lore status`. The parent is not committed.
738#[allow(clippy::too_many_arguments)]
739async fn commit_link_only(
740 repository: Arc<RepositoryContext>,
741 token: RepositoryWriteToken,
742 message: String,
743 link_path: String,
744 keys: LoreArray<LoreString>,
745 values: LoreArray<LoreString>,
746 formats: LoreArray<LoreMetadataType>,
747 stats: bool,
748) -> Result<Hash, CommitError> {
749 let (current_revision, current_branch) = crate::instance::load_current_anchor(&repository)
750 .await
751 .forward::<CommitError>("Failed to deserialize current anchor")?;
752
753 // Load the parent's current state
754 let state_parent_current = State::deserialize(repository.clone(), current_revision)
755 .await
756 .forward_with::<CommitError, _>(|| {
757 format!("Failed to deserialize revision state {current_revision}")
758 })?;
759
760 // Load the parent's staged state (contains the modified link state)
761 let parent_staged_revision = match crate::instance::load_staged_revision(&repository).await {
762 Ok(Some(revision)) if revision != current_revision => revision,
763 _ => return Err(NothingStaged.into()),
764 };
765 let state_parent_staged = State::deserialize(repository.clone(), parent_staged_revision)
766 .await
767 .forward_with::<CommitError, _>(|| {
768 format!("Failed to deserialize revision state {parent_staged_revision}")
769 })?;
770
771 // Resolve the link in both staged and current parent states
772 let resolved_staged = match link::resolve_link_at_path(
773 &state_parent_staged,
774 repository.clone(),
775 &link_path,
776 )
777 .await
778 {
779 Ok(resolved) => resolved,
780 Err(err) if err.is_not_a_link() => {
781 return Err(NotALink { path: link_path }.into());
782 }
783 Err(_) => {
784 return Err(LinkPathNotFound { path: link_path }.into());
785 }
786 };
787
788 let resolved_current =
789 link::resolve_link_at_path(&state_parent_current, repository.clone(), &link_path)
790 .await
791 .debug_map_err(LinkPathNotFound {
792 path: link_path.clone(),
793 })?;
794
795 let link_staged_revision = resolved_staged.link_node.linked_node().revision;
796 let link_current_revision = resolved_current.link_node.linked_node().revision;

Callers 1

commit_implFunction · 0.85

Calls 15

load_current_anchorFunction · 0.85
deserializeFunction · 0.85
load_staged_revisionFunction · 0.85
resolve_link_at_pathFunction · 0.85
load_latestFunction · 0.85
build_commit_metadataFunction · 0.85
commit_staged_revisionFunction · 0.85
finalize_commitFunction · 0.85
update_link_pin_by_nodeFunction · 0.85
execution_contextFunction · 0.85
store_staged_anchorFunction · 0.85
debug_map_errMethod · 0.80

Tested by

no test coverage detected