MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / align_index_to_tree

Function align_index_to_tree

atomic-cli/src/commands/git/shadow.rs:1984–2010  ·  view source on GitHub ↗
(
    git_repo: &GitRepository,
    tree_oid: git2::Oid,
    publication: &VerifiedPublication,
)

Source from the content-addressed store, hash-verified

1982}
1983
1984fn align_index_to_tree(
1985 git_repo: &GitRepository,
1986 tree_oid: git2::Oid,
1987 publication: &VerifiedPublication,
1988) -> CliResult<()> {
1989 if publication.git_tree_oid()? != tree_oid {
1990 return Err(git_error("refusing to align index to an unverified tree"));
1991 }
1992 let tree = git_repo.find_tree(tree_oid).map_err(|error| {
1993 git_error(format!(
1994 "cannot read shadow projection tree while aligning Git index: {error}"
1995 ))
1996 })?;
1997 let mut index = git_repo.index().map_err(|error| {
1998 git_error(format!(
1999 "cannot open Git index while aligning shadow view: {error}"
2000 ))
2001 })?;
2002 index
2003 .read_tree(&tree)
2004 .and_then(|_| index.write())
2005 .map_err(|error| {
2006 git_error(format!(
2007 "cannot align Git index to the shadow projection tree: {error}"
2008 ))
2009 })
2010}
2011
2012fn snapshot_reference(git_repo: &GitRepository, name: &str) -> CliResult<ReferenceSnapshot> {
2013 match git_repo.find_reference(name) {

Callers

nothing calls this directly

Calls 4

git_tree_oidMethod · 0.80
git_errorFunction · 0.70
indexMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected