fn find_package_root_for_manifest(&self, manifest_path: &Path) -> Result<PathBuf> {
    let has_git_repo_root = {
      let is_git = self.source_id.as_ref().map_or(false, SourceId::is_git);
      is_git && self.settings.genmode == GenMode::Remote
    };

    // Return manifest path itself if not git
    if !has_git_repo_root {
      // TODO(acmcarther): How do we know parent is valid here?
      // UNWRAP: Pathbuf guaranteed to succeed from Path
      return Ok(PathBuf::from(manifest_path.parent().unwrap()));
    }

    // If package is git package it may be nested under a parent repository. We need to find the
    // package root.
    {
      let mut check_path = manifest_path;
      while let Some(c) = check_path.parent() {
        let joined = c.join(".git");
        if joined.is_dir() {
          // UNWRAP: Pathbuf guaranteed to succeed from Path
          return Ok(PathBuf::from(c));
        } else {
          check_path = c;
        }
      }

      // Reached filesystem root and did not find Git repo
      Err(
        RazeError::Generic(format!(
          "Unable to locate git repository root for manifest at {:?}. {}",
          manifest_path, PLEASE_FILE_A_BUG
        ))
        .into(),
      )
    }
  }
/// Finds the root of a contained git package.
/// This function needs to access the file system if the dependency is a git dependency in order
/// to find the true filesystem root of the dependency. The root cause is that git dependencies
/// often aren't solely the crate of interest, but rather a repository that contains the crate of
/// interest among others.
Finds the root of a contained git package.
This function needs to access the file system if the dependency is a git dependency in order
to find the true filesystem root of the dependency. The root cause is that git dependencies
often aren't solely the crate of interest, but rather a repository that contains the crate of
interest among others.
Finds the root of a contained git package . This function needs to access the file system if the dependency is a git dependency in order to find the true filesystem root of the dependency . The root cause is that git dependencies often aren ' t solely the crate of interest but rather a repository that contains the crate of interest among others .
fn find_package_root_for_manifest(&self, manifest_path: &Path) -> Result<PathBuf> {
    let has_git_repo_root = {
      let is_git = self.source_id.as_ref().map_or(false, SourceId::is_git);
      is_git && self.settings.genmode == GenMode::Remote
    };
    // Return manifest path itself if not git
    if !has_git_repo_root {
      // TODO(acmcarther): How do we know parent is valid here?
      // UNWRAP: Pathbuf guaranteed to succeed from Path
      return Ok(PathBuf::from(manifest_path.parent().unwrap()));
    }
    // If package is git package it may be nested under a parent repository. We need to find the
    // package root.
    {
      let mut check_path = manifest_path;
      while let Some(c) = check_path.parent() {
        let joined = c.join(".git");
        if joined.is_dir() {
          // UNWRAP: Pathbuf guaranteed to succeed from Path
          return Ok(PathBuf::from(c));
        } else {
          check_path = c;
        }
      }
      // Reached filesystem root and did not find Git repo
      Err(
        RazeError::Generic(format!(
          "Unable to locate git repository root for manifest at {:?}. {}",
          manifest_path, PLEASE_FILE_A_BUG
        ))
        .into(),
      )
    }
  }
fn find_package_root_for_manifest ( & self , manifest_path : & Path ) -> Result < PathBuf > { let has_git_repo_root = { let is_git = self . source_id . as_ref ( ) . map_or ( false , SourceId :: is_git ) ; is_git && self . settings . genmode == GenMode :: Remote } ; // Return manifest path itself if not git if ! has_git_repo_root { // TODO(acmcarther): How do we know parent is valid here? // UNWRAP: Pathbuf guaranteed to succeed from Path return Ok ( PathBuf :: from ( manifest_path . parent ( ) . unwrap ( ) ) ) ; } // If package is git package it may be nested under a parent repository. We need to find the // package root. { let mut check_path = manifest_path ; while let Some ( c ) = check_path . parent ( ) { let joined = c . join ( " " ) ; if joined . is_dir ( ) { // UNWRAP: Pathbuf guaranteed to succeed from Path return Ok ( PathBuf :: from ( c ) ) ; } else { check_path = c ; } } // Reached filesystem root and did not find Git repo Err ( RazeError :: Generic ( format ! ( " " manifest_path PLEASE_FILE_A_BUG ) ) . into ( ) , ) } }
Finds the root of a contained git package.
Finds the root of a contained git package .
&self
manifest_path
&Path
&self
manifest_path
&Path