Rename GitRepository.path() to GitRepository.dot_git_dir() (#22026)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan
2024-12-14 15:30:56 -07:00
committed by GitHub
parent 25970650a7
commit d459f010b6
2 changed files with 11 additions and 10 deletions
+10 -9
View File
@@ -46,7 +46,8 @@ pub trait GitRepository: Send + Sync {
fn blame(&self, path: &Path, content: Rope) -> Result<crate::blame::Blame>;
fn path(&self) -> PathBuf;
/// Returns the path to the repository, typically the `.git` folder.
fn dot_git_dir(&self) -> PathBuf;
}
impl std::fmt::Debug for dyn GitRepository {
@@ -85,7 +86,7 @@ impl GitRepository for RealGitRepository {
}
}
fn path(&self) -> PathBuf {
fn dot_git_dir(&self) -> PathBuf {
let repo = self.repository.lock();
repo.path().into()
}
@@ -233,7 +234,7 @@ pub struct FakeGitRepository {
#[derive(Debug, Clone)]
pub struct FakeGitRepositoryState {
pub path: PathBuf,
pub dot_git_dir: PathBuf,
pub event_emitter: smol::channel::Sender<PathBuf>,
pub index_contents: HashMap<PathBuf, String>,
pub blames: HashMap<PathBuf, Blame>,
@@ -249,9 +250,9 @@ impl FakeGitRepository {
}
impl FakeGitRepositoryState {
pub fn new(path: PathBuf, event_emitter: smol::channel::Sender<PathBuf>) -> Self {
pub fn new(dot_git_dir: PathBuf, event_emitter: smol::channel::Sender<PathBuf>) -> Self {
FakeGitRepositoryState {
path,
dot_git_dir,
event_emitter,
index_contents: Default::default(),
blames: Default::default(),
@@ -283,9 +284,9 @@ impl GitRepository for FakeGitRepository {
None
}
fn path(&self) -> PathBuf {
fn dot_git_dir(&self) -> PathBuf {
let state = self.state.lock();
state.path.clone()
state.dot_git_dir.clone()
}
fn status(&self, path_prefixes: &[PathBuf]) -> Result<GitStatus> {
@@ -334,7 +335,7 @@ impl GitRepository for FakeGitRepository {
state.current_branch_name = Some(name.to_owned());
state
.event_emitter
.try_send(state.path.clone())
.try_send(state.dot_git_dir.clone())
.expect("Dropped repo change event");
Ok(())
}
@@ -344,7 +345,7 @@ impl GitRepository for FakeGitRepository {
state.branches.insert(name.to_owned());
state
.event_emitter
.try_send(state.path.clone())
.try_send(state.dot_git_dir.clone())
.expect("Dropped repo change event");
Ok(())
}
+1 -1
View File
@@ -3118,7 +3118,7 @@ impl BackgroundScannerState {
let t0 = Instant::now();
let repository = fs.open_repo(&dot_git_abs_path)?;
let actual_repo_path = repository.path();
let actual_repo_path = repository.dot_git_dir();
let actual_dot_git_dir_abs_path = smol::block_on(find_git_dir(&actual_repo_path, fs))?;
watcher.add(&actual_repo_path).log_err()?;