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

Method paths

atomic-cli/src/commands/git/import.rs:1937–1984  ·  view source on GitHub ↗

Every repository path the materialization writes.

(&self, git_repo: &GitRepository)

Source from the content-addressed store, hash-verified

1935
1936 /// Every repository path the materialization writes.
1937 fn paths(&self, git_repo: &GitRepository) -> CliResult<HashSet<String>> {
1938 let mut paths = HashSet::new();
1939 match self {
1940 Self::Branch(branch) => {
1941 // A view imported ahead of its Git branch (a switch that
1942 // stopped before creating the branch) has no tree to collide
1943 // with; the tracked-changes requirement above still holds.
1944 let branch_ref = match git_repo.find_branch(branch, git2::BranchType::Local) {
1945 Ok(found) => found,
1946 Err(error) if error.code() == git2::ErrorCode::NotFound => return Ok(paths),
1947 Err(error) => {
1948 return Err(CliError::GitError {
1949 message: format!("cannot read branch '{branch}': {error}"),
1950 })
1951 }
1952 };
1953 let tree = branch_ref
1954 .get()
1955 .peel_to_tree()
1956 .map_err(|error| CliError::GitError {
1957 message: format!("cannot read the tree of branch '{branch}': {error}"),
1958 })?;
1959 tree.walk(git2::TreeWalkMode::PreOrder, |directory, entry| {
1960 if let Ok(name) = entry.name() {
1961 paths.insert(format!("{directory}{name}"));
1962 }
1963 git2::TreeWalkResult::Ok
1964 })
1965 .map_err(|error| CliError::GitError {
1966 message: format!("cannot walk the tree of branch '{branch}': {error}"),
1967 })?;
1968 }
1969 Self::CurrentView(repo) => {
1970 for file in repo
1971 .list_tracked_files()
1972 .map_err(|error| CliError::Internal(error.into()))?
1973 {
1974 let canonical = file.path.to_string_lossy();
1975 paths.insert(
1976 super::parallel::canonical_tree_path(&canonical)
1977 .to_string_lossy()
1978 .into_owned(),
1979 );
1980 }
1981 }
1982 }
1983 Ok(paths)
1984 }
1985}
1986
1987/// Refuse to materialize over a worktree holding work Git has not recorded:

Callers 2

build_optionsMethod · 0.45

Calls 7

canonical_tree_pathFunction · 0.85
list_tracked_filesMethod · 0.80
getMethod · 0.65
codeMethod · 0.45
walkMethod · 0.45
nameMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected