Skip to content

Commit

Permalink
Rename GitRepository.path() to GitRepository.dot_git_dir() (zed-i…
Browse files Browse the repository at this point in the history
…ndustries#22026)

Release Notes:

- N/A
  • Loading branch information
mgsloan authored Dec 14, 2024
1 parent 2597065 commit d459f01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions crates/git/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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>,
Expand All @@ -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(),
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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(())
}
Expand All @@ -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(())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/worktree/src/worktree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down

0 comments on commit d459f01

Please sign in to comment.