Skip to content

Commit

Permalink
repository(doc): path::discover (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Sep 13, 2021
1 parent 2f2d856 commit 1958e8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion git-repository/src/path/create.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(missing_docs)]
use std::{
fs::{self, OpenOptions},
io::Write,
Expand Down
10 changes: 7 additions & 3 deletions git-repository/src/path/discover.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#![allow(missing_docs)]
//!
use std::{
borrow::Cow,
path::{Component, Path},
};

use crate::path;

///
pub mod existing {
use std::path::PathBuf;

/// The error returned by [path::discover::existing()][super::existing()].
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error("Failed to access a directory, or path is not a directory: '{}'", .path.display())]
InaccessibleDirectory { path: PathBuf },
Expand All @@ -18,8 +21,9 @@ pub mod existing {
}
}

/// Returns the work tree if possible and the found repository is not bare or the git repository itself,
/// and traverse parent directories until a Repository is found.
/// Find the location of the git repository directly in `directory` or in any of its parent directories.
///
/// Fail if no valid-looking git repository could be found.
pub fn existing(directory: impl AsRef<Path>) -> Result<crate::Path, existing::Error> {
// Canonicalize the path so that `Path::parent` _actually_ gives
// us the parent directory. (`Path::parent` just strips off the last
Expand Down

0 comments on commit 1958e8a

Please sign in to comment.