| |
}
|
| |
|
| |
/// Get the Id of project in current working directory
|
| + |
///
|
| + |
/// It will atempt to search parent directories if `path` did not find
|
| + |
/// a git repository.
|
| + |
///
|
| + |
/// # Safety
|
| + |
///
|
| + |
/// This function should only perform read operations since we do not
|
| + |
/// want to modify the wrong repository in the case that it found a
|
| + |
/// Git repository that is not a Radicle repository.
|
| |
pub fn cwd() -> Result<(git2::Repository, Id), RemoteError> {
|
| - |
let repo = git2::Repository::open(Path::new("."))?;
|
| + |
let mut flags = git2::RepositoryOpenFlags::empty();
|
| + |
// Allow to search upwards.
|
| + |
flags.set(git2::RepositoryOpenFlags::NO_SEARCH, false);
|
| + |
// Allow to use `GIT_DIR` env.
|
| + |
flags.set(git2::RepositoryOpenFlags::FROM_ENV, true);
|
| + |
let ceilings: &[&str] = &[];
|
| + |
let repo = git2::Repository::open_ext(Path::new("."), flags, ceilings)?;
|
| |
let (_, id) = remote(&repo)?;
|
| |
|
| |
Ok((repo, id))
|