From d459f010b607eac9adfeabe4a4f11ce755f0110a Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Sat, 14 Dec 2024 15:30:56 -0700 Subject: [PATCH] Rename `GitRepository.path()` to `GitRepository.dot_git_dir()` (#22026) Release Notes: - N/A --- crates/git/src/repository.rs | 19 ++++++++++--------- crates/worktree/src/worktree.rs | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index 78f6ece508..b37e517d43 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -46,7 +46,8 @@ pub trait GitRepository: Send + Sync { fn blame(&self, path: &Path, content: Rope) -> Result; - 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, pub index_contents: HashMap, pub blames: HashMap, @@ -249,9 +250,9 @@ impl FakeGitRepository { } impl FakeGitRepositoryState { - pub fn new(path: PathBuf, event_emitter: smol::channel::Sender) -> Self { + pub fn new(dot_git_dir: PathBuf, event_emitter: smol::channel::Sender) -> 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 { @@ -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(()) } diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 7b118c1c57..13f335334a 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -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()?;