diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rs index 5c73253048..c82b50a8b0 100644 --- a/crates/collab/src/tests/integration_tests.rs +++ b/crates/collab/src/tests/integration_tests.rs @@ -3072,12 +3072,7 @@ async fn test_git_status_sync( .collect::>(); assert_eq!(repos.len(), 1); let repo = repos.into_iter().next().unwrap(); - assert_eq!( - repo.read(cx) - .status_for_path(&file.into()) - .map(|entry| entry.status), - status - ); + assert_eq!(repo.read(cx).status_for_path(&file.into()), status); } project_local.read_with(cx_a, |project, cx| { diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index b7110190fd..9f02e7de5c 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -685,7 +685,7 @@ impl Item for Editor { .git_store() .read(cx) .repository_and_path_for_buffer_id(buffer_id, cx)?; - let status = repo.read(cx).status_for_path(&repo_path)?.status; + let status = repo.read(cx).status_for_path(&repo_path)?; Some(entry_git_aware_label_color( status.summary(), diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index 10698cead8..a82dd5dd4b 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -2693,9 +2693,7 @@ impl OutlinePanel { let status = git_store .read(cx) .repository_and_path_for_buffer_id(buffer_id, cx) - .and_then(|(repo, path)| { - Some(repo.read(cx).status_for_path(&path)?.status) - }); + .and_then(|(repo, path)| Some(repo.read(cx).status_for_path(&path)?)); buffer_excerpts .entry(buffer_id) .or_insert_with(|| { diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index 5cf298a8bf..9b51d7b732 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -809,7 +809,7 @@ impl GitStore { cx: &App, ) -> Option { let (repo, repo_path) = self.repository_and_path_for_project_path(project_path, cx)?; - Some(repo.read(cx).status_for_path(&repo_path)?.status) + Some(repo.read(cx).status_for_path(&repo_path)?) } pub fn checkpoint(&self, cx: &mut App) -> Task> { @@ -1391,8 +1391,7 @@ impl GitStore { pub fn status_for_buffer_id(&self, buffer_id: BufferId, cx: &App) -> Option { let (repo, path) = self.repository_and_path_for_buffer_id(buffer_id, cx)?; - let status = repo.read(cx).snapshot.status_for_path(&path)?; - Some(status.status) + repo.read(cx).snapshot.status_for_path(&path) } pub fn repository_and_path_for_buffer_id( @@ -2844,10 +2843,10 @@ impl RepositorySnapshot { self.statuses_by_path.summary().item_summary } - pub fn status_for_path(&self, path: &RepoPath) -> Option { + pub fn status_for_path(&self, path: &RepoPath) -> Option { self.statuses_by_path .get(&PathKey(path.0.clone()), &()) - .cloned() + .map(|entry| entry.status.clone()) } pub fn abs_path_to_repo_path(&self, abs_path: &Path) -> Option { @@ -2874,7 +2873,7 @@ impl RepositorySnapshot { self.merge.conflicted_paths.contains(repo_path); let has_conflict_currently = self .status_for_path(repo_path) - .is_some_and(|entry| entry.status.is_conflicted()); + .is_some_and(|status| status.is_conflicted()); had_conflict_on_last_merge_head_change || has_conflict_currently } diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rs index 6dcd07482e..084eae8af1 100644 --- a/crates/project/src/project_tests.rs +++ b/crates/project/src/project_tests.rs @@ -8246,7 +8246,7 @@ async fn test_repository_subfolder_git_status( assert_eq!(repository.status_for_path(&C_TXT.into()), None); assert_eq!( - repository.status_for_path(&E_TXT.into()).unwrap().status, + repository.status_for_path(&E_TXT.into()).unwrap(), FileStatus::Untracked ); }); @@ -8459,15 +8459,11 @@ async fn test_rename_work_directory(cx: &mut gpui::TestAppContext) { root_path.join("projects/project1").as_path() ); assert_eq!( - repository - .status_for_path(&"a".into()) - .map(|entry| entry.status), + repository.status_for_path(&"a".into()), Some(StatusCode::Modified.worktree()), ); assert_eq!( - repository - .status_for_path(&"b".into()) - .map(|entry| entry.status), + repository.status_for_path(&"b".into()), Some(FileStatus::Untracked), ); }); @@ -8485,11 +8481,11 @@ async fn test_rename_work_directory(cx: &mut gpui::TestAppContext) { root_path.join("projects/project2").as_path() ); assert_eq!( - repository.status_for_path(&"a".into()).unwrap().status, + repository.status_for_path(&"a".into()).unwrap(), StatusCode::Modified.worktree(), ); assert_eq!( - repository.status_for_path(&"b".into()).unwrap().status, + repository.status_for_path(&"b".into()).unwrap(), FileStatus::Untracked, ); }); @@ -8562,11 +8558,11 @@ async fn test_file_status(cx: &mut gpui::TestAppContext) { ); assert_eq!( - repository.status_for_path(&B_TXT.into()).unwrap().status, + repository.status_for_path(&B_TXT.into()).unwrap(), FileStatus::Untracked, ); assert_eq!( - repository.status_for_path(&F_TXT.into()).unwrap().status, + repository.status_for_path(&F_TXT.into()).unwrap(), FileStatus::Untracked, ); }); @@ -8582,7 +8578,7 @@ async fn test_file_status(cx: &mut gpui::TestAppContext) { // The worktree detects that the file's git status has changed. repository.read_with(cx, |repository, _| { assert_eq!( - repository.status_for_path(&A_TXT.into()).unwrap().status, + repository.status_for_path(&A_TXT.into()).unwrap(), StatusCode::Modified.worktree(), ); }); @@ -8600,7 +8596,7 @@ async fn test_file_status(cx: &mut gpui::TestAppContext) { // The worktree detects that the files' git status have changed. repository.read_with(cx, |repository, _cx| { assert_eq!( - repository.status_for_path(&F_TXT.into()).unwrap().status, + repository.status_for_path(&F_TXT.into()).unwrap(), FileStatus::Untracked, ); assert_eq!(repository.status_for_path(&B_TXT.into()), None); @@ -8623,11 +8619,11 @@ async fn test_file_status(cx: &mut gpui::TestAppContext) { repository.read_with(cx, |repository, _cx| { assert_eq!(repository.status_for_path(&A_TXT.into()), None); assert_eq!( - repository.status_for_path(&B_TXT.into()).unwrap().status, + repository.status_for_path(&B_TXT.into()).unwrap(), FileStatus::Untracked, ); assert_eq!( - repository.status_for_path(&E_TXT.into()).unwrap().status, + repository.status_for_path(&E_TXT.into()).unwrap(), StatusCode::Modified.worktree(), ); }); @@ -8666,8 +8662,7 @@ async fn test_file_status(cx: &mut gpui::TestAppContext) { assert_eq!( repository .status_for_path(&Path::new(renamed_dir_name).join(RENAMED_FILE).into()) - .unwrap() - .status, + .unwrap(), FileStatus::Untracked, ); }); @@ -8690,8 +8685,7 @@ async fn test_file_status(cx: &mut gpui::TestAppContext) { assert_eq!( repository .status_for_path(&Path::new(renamed_dir_name).join(RENAMED_FILE).into()) - .unwrap() - .status, + .unwrap(), FileStatus::Untracked, ); }); @@ -9000,7 +8994,7 @@ async fn test_git_worktrees_and_submodules(cx: &mut gpui::TestAppContext) { barrier.await.unwrap(); worktree_repo.update(cx, |repo, _| { pretty_assertions::assert_eq!( - repo.status_for_path(&"src/b.txt".into()).unwrap().status, + repo.status_for_path(&"src/b.txt".into()).unwrap(), StatusCode::Modified.worktree(), ); }); @@ -9039,7 +9033,7 @@ async fn test_git_worktrees_and_submodules(cx: &mut gpui::TestAppContext) { barrier.await.unwrap(); submodule_repo.update(cx, |repo, _| { pretty_assertions::assert_eq!( - repo.status_for_path(&"c.txt".into()).unwrap().status, + repo.status_for_path(&"c.txt".into()).unwrap(), StatusCode::Modified.worktree(), ); }); @@ -9300,9 +9294,7 @@ fn assert_entry_git_state( let entry = tree .entry_for_path(path) .unwrap_or_else(|| panic!("entry {path} not found")); - let status = repository - .status_for_path(&path.into()) - .map(|entry| entry.status); + let status = repository.status_for_path(&path.into()).map(|entry| entry); let expected = index_status.map(|index_status| { TrackedStatus { index_status,