use std::path::{Path, PathBuf};
use super::git_ops::git_repository_root;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum ServiceScopeFilter {
Versioning,
Release,
}
pub(crate) const LAST_VERSION_SCOPE_FILE: &str = "last-version-scope";
pub(crate) fn normalized_relative_path(path: &Path) -> String {
path.to_string_lossy().replace('\\', "/")
}
pub(crate) fn same_filesystem_path(left: &Path, right: &Path) -> bool {
if left == right {
return true;
}
match (left.canonicalize(), right.canonicalize()) {
(Ok(left), Ok(right)) => left == right,
_ => false,
}
}
pub(crate) fn enclosing_git_root(dir: &Path) -> Option<PathBuf> {
for ancestor in dir.ancestors() {
if ancestor.join(".git").exists() {
return Some(ancestor.to_path_buf());
}
}
git_repository_root(dir)
}