1mod ids;
2mod queries;
3mod tables;
4#[cfg(test)]
5pub mod tests;
6
7use crate::{Error, Result};
8use anyhow::{Context as _, anyhow};
9use collections::{BTreeMap, BTreeSet, HashMap, HashSet};
10use dashmap::DashMap;
11use futures::StreamExt;
12use project_repository_statuses::StatusKind;
13use rpc::ExtensionProvides;
14use rpc::{
15 ConnectionId, ExtensionMetadata,
16 proto::{self},
17};
18use sea_orm::{
19 ActiveValue, Condition, ConnectionTrait, DatabaseConnection, DatabaseTransaction,
20 FromQueryResult, IntoActiveModel, IsolationLevel, JoinType, QueryOrder, QuerySelect, Statement,
21 TransactionTrait,
22 entity::prelude::*,
23 sea_query::{Alias, Expr, OnConflict},
24};
25use semver::Version;
26use serde::{Deserialize, Serialize};
27use std::ops::RangeInclusive;
28use std::{
29 future::Future,
30 marker::PhantomData,
31 ops::{Deref, DerefMut},
32 rc::Rc,
33 sync::Arc,
34};
35use time::PrimitiveDateTime;
36use tokio::sync::{Mutex, OwnedMutexGuard};
37use util::paths::PathStyle;
38use worktree_settings_file::LocalSettingsKind;
39
40#[cfg(test)]
41pub use tests::TestDb;
42
43pub use ids::*;
44pub use sea_orm::ConnectOptions;
45pub use tables::user::Model as User;
46pub use tables::*;
47
48#[cfg(test)]
49pub struct DatabaseTestOptions {
50 pub executor: gpui::BackgroundExecutor,
51 pub runtime: tokio::runtime::Runtime,
52 pub query_failure_probability: parking_lot::Mutex<f64>,
53}
54
55/// Database gives you a handle that lets you access the database.
56/// It handles pooling internally.
57pub struct Database {
58 options: ConnectOptions,
59 pool: DatabaseConnection,
60 rooms: DashMap<RoomId, Arc<Mutex<()>>>,
61 projects: DashMap<ProjectId, Arc<Mutex<()>>>,
62 notification_kinds_by_id: HashMap<NotificationKindId, &'static str>,
63 notification_kinds_by_name: HashMap<String, NotificationKindId>,
64 #[cfg(test)]
65 test_options: Option<DatabaseTestOptions>,
66}
67
68// The `Database` type has so many methods that its impl blocks are split into
69// separate files in the `queries` folder.
70impl Database {
71 /// Connects to the database with the given options
72 pub async fn new(options: ConnectOptions) -> Result<Self> {
73 sqlx::any::install_default_drivers();
74 Ok(Self {
75 options: options.clone(),
76 pool: sea_orm::Database::connect(options).await?,
77 rooms: DashMap::with_capacity(16384),
78 projects: DashMap::with_capacity(16384),
79 notification_kinds_by_id: HashMap::default(),
80 notification_kinds_by_name: HashMap::default(),
81 #[cfg(test)]
82 test_options: None,
83 })
84 }
85
86 pub fn options(&self) -> &ConnectOptions {
87 &self.options
88 }
89
90 #[cfg(test)]
91 pub fn reset(&self) {
92 self.rooms.clear();
93 self.projects.clear();
94 }
95
96 pub async fn transaction<F, Fut, T>(&self, f: F) -> Result<T>
97 where
98 F: Send + Fn(TransactionHandle) -> Fut,
99 Fut: Send + Future<Output = Result<T>>,
100 {
101 let body = async {
102 let (tx, result) = self.with_transaction(&f).await?;
103 match result {
104 Ok(result) => match tx.commit().await.map_err(Into::into) {
105 Ok(()) => Ok(result),
106 Err(error) => Err(error),
107 },
108 Err(error) => {
109 tx.rollback().await?;
110 Err(error)
111 }
112 }
113 };
114
115 self.run(body).await
116 }
117
118 /// The same as room_transaction, but if you need to only optionally return a Room.
119 async fn optional_room_transaction<F, Fut, T>(
120 &self,
121 f: F,
122 ) -> Result<Option<TransactionGuard<T>>>
123 where
124 F: Send + Fn(TransactionHandle) -> Fut,
125 Fut: Send + Future<Output = Result<Option<(RoomId, T)>>>,
126 {
127 let body = async {
128 let (tx, result) = self.with_transaction(&f).await?;
129 match result {
130 Ok(Some((room_id, data))) => {
131 let lock = self.rooms.entry(room_id).or_default().clone();
132 let _guard = lock.lock_owned().await;
133 match tx.commit().await.map_err(Into::into) {
134 Ok(()) => Ok(Some(TransactionGuard {
135 data,
136 _guard,
137 _not_send: PhantomData,
138 })),
139 Err(error) => Err(error),
140 }
141 }
142 Ok(None) => match tx.commit().await.map_err(Into::into) {
143 Ok(()) => Ok(None),
144 Err(error) => Err(error),
145 },
146 Err(error) => {
147 tx.rollback().await?;
148 Err(error)
149 }
150 }
151 };
152
153 self.run(body).await
154 }
155
156 async fn project_transaction<F, Fut, T>(
157 &self,
158 project_id: ProjectId,
159 f: F,
160 ) -> Result<TransactionGuard<T>>
161 where
162 F: Send + Fn(TransactionHandle) -> Fut,
163 Fut: Send + Future<Output = Result<T>>,
164 {
165 let room_id = Database::room_id_for_project(self, project_id).await?;
166 let body = async {
167 let lock = if let Some(room_id) = room_id {
168 self.rooms.entry(room_id).or_default().clone()
169 } else {
170 self.projects.entry(project_id).or_default().clone()
171 };
172 let _guard = lock.lock_owned().await;
173 let (tx, result) = self.with_transaction(&f).await?;
174 match result {
175 Ok(data) => match tx.commit().await.map_err(Into::into) {
176 Ok(()) => Ok(TransactionGuard {
177 data,
178 _guard,
179 _not_send: PhantomData,
180 }),
181 Err(error) => Err(error),
182 },
183 Err(error) => {
184 tx.rollback().await?;
185 Err(error)
186 }
187 }
188 };
189
190 self.run(body).await
191 }
192
193 /// room_transaction runs the block in a transaction. It returns a RoomGuard, that keeps
194 /// the database locked until it is dropped. This ensures that updates sent to clients are
195 /// properly serialized with respect to database changes.
196 async fn room_transaction<F, Fut, T>(
197 &self,
198 room_id: RoomId,
199 f: F,
200 ) -> Result<TransactionGuard<T>>
201 where
202 F: Send + Fn(TransactionHandle) -> Fut,
203 Fut: Send + Future<Output = Result<T>>,
204 {
205 let body = async {
206 let lock = self.rooms.entry(room_id).or_default().clone();
207 let _guard = lock.lock_owned().await;
208 let (tx, result) = self.with_transaction(&f).await?;
209 match result {
210 Ok(data) => match tx.commit().await.map_err(Into::into) {
211 Ok(()) => Ok(TransactionGuard {
212 data,
213 _guard,
214 _not_send: PhantomData,
215 }),
216 Err(error) => Err(error),
217 },
218 Err(error) => {
219 tx.rollback().await?;
220 Err(error)
221 }
222 }
223 };
224
225 self.run(body).await
226 }
227
228 async fn with_transaction<F, Fut, T>(&self, f: &F) -> Result<(DatabaseTransaction, Result<T>)>
229 where
230 F: Send + Fn(TransactionHandle) -> Fut,
231 Fut: Send + Future<Output = Result<T>>,
232 {
233 let tx = self
234 .pool
235 .begin_with_config(Some(IsolationLevel::ReadCommitted), None)
236 .await?;
237
238 let mut tx = Arc::new(Some(tx));
239 let result = f(TransactionHandle(tx.clone())).await;
240 let tx = Arc::get_mut(&mut tx)
241 .and_then(|tx| tx.take())
242 .context("couldn't complete transaction because it's still in use")?;
243
244 Ok((tx, result))
245 }
246
247 async fn run<F, T>(&self, future: F) -> Result<T>
248 where
249 F: Future<Output = Result<T>>,
250 {
251 #[cfg(test)]
252 {
253 use rand::prelude::*;
254
255 let test_options = self.test_options.as_ref().unwrap();
256 test_options.executor.simulate_random_delay().await;
257 let fail_probability = *test_options.query_failure_probability.lock();
258 if test_options.executor.rng().random_bool(fail_probability) {
259 return Err(anyhow!("simulated query failure"))?;
260 }
261
262 test_options.runtime.block_on(future)
263 }
264
265 #[cfg(not(test))]
266 {
267 future.await
268 }
269 }
270}
271
272/// A handle to a [`DatabaseTransaction`].
273pub struct TransactionHandle(pub(crate) Arc<Option<DatabaseTransaction>>);
274
275impl Deref for TransactionHandle {
276 type Target = DatabaseTransaction;
277
278 fn deref(&self) -> &Self::Target {
279 self.0.as_ref().as_ref().unwrap()
280 }
281}
282
283/// [`TransactionGuard`] keeps a database transaction alive until it is dropped.
284/// It wraps data that depends on the state of the database and prevents an additional
285/// transaction from starting that would invalidate that data.
286pub struct TransactionGuard<T> {
287 data: T,
288 _guard: OwnedMutexGuard<()>,
289 _not_send: PhantomData<Rc<()>>,
290}
291
292impl<T> Deref for TransactionGuard<T> {
293 type Target = T;
294
295 fn deref(&self) -> &T {
296 &self.data
297 }
298}
299
300impl<T> DerefMut for TransactionGuard<T> {
301 fn deref_mut(&mut self) -> &mut T {
302 &mut self.data
303 }
304}
305
306impl<T> TransactionGuard<T> {
307 /// Returns the inner value of the guard.
308 pub fn into_inner(self) -> T {
309 self.data
310 }
311}
312
313#[derive(Clone, Debug, PartialEq, Eq)]
314pub enum Contact {
315 Accepted { user_id: UserId, busy: bool },
316 Outgoing { user_id: UserId },
317 Incoming { user_id: UserId },
318}
319
320impl Contact {
321 pub fn user_id(&self) -> UserId {
322 match self {
323 Contact::Accepted { user_id, .. } => *user_id,
324 Contact::Outgoing { user_id } => *user_id,
325 Contact::Incoming { user_id, .. } => *user_id,
326 }
327 }
328}
329
330pub type NotificationBatch = Vec<(UserId, proto::Notification)>;
331
332pub struct CreatedChannelMessage {
333 pub message_id: MessageId,
334 pub participant_connection_ids: HashSet<ConnectionId>,
335 pub notifications: NotificationBatch,
336}
337
338pub struct UpdatedChannelMessage {
339 pub message_id: MessageId,
340 pub participant_connection_ids: Vec<ConnectionId>,
341 pub notifications: NotificationBatch,
342 pub reply_to_message_id: Option<MessageId>,
343 pub timestamp: PrimitiveDateTime,
344 pub deleted_mention_notification_ids: Vec<NotificationId>,
345 pub updated_mention_notifications: Vec<rpc::proto::Notification>,
346}
347
348#[derive(Clone, Debug, PartialEq, Eq, FromQueryResult, Serialize, Deserialize)]
349pub struct Invite {
350 pub email_address: String,
351 pub email_confirmation_code: String,
352}
353
354#[derive(Clone, Debug, Deserialize)]
355pub struct NewSignup {
356 pub email_address: String,
357 pub platform_mac: bool,
358 pub platform_windows: bool,
359 pub platform_linux: bool,
360 pub editor_features: Vec<String>,
361 pub programming_languages: Vec<String>,
362 pub device_id: Option<String>,
363 pub added_to_mailing_list: bool,
364 pub created_at: Option<DateTime>,
365}
366
367#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, FromQueryResult)]
368pub struct WaitlistSummary {
369 pub count: i64,
370 pub linux_count: i64,
371 pub mac_count: i64,
372 pub windows_count: i64,
373 pub unknown_count: i64,
374}
375
376/// The parameters to create a new user.
377#[derive(Debug, Serialize, Deserialize)]
378pub struct NewUserParams {
379 pub github_login: String,
380 pub github_user_id: i32,
381}
382
383/// The result of creating a new user.
384#[derive(Debug)]
385pub struct NewUserResult {
386 pub user_id: UserId,
387}
388
389/// The result of updating a channel membership.
390#[derive(Debug)]
391pub struct MembershipUpdated {
392 pub channel_id: ChannelId,
393 pub new_channels: ChannelsForUser,
394 pub removed_channels: Vec<ChannelId>,
395}
396
397/// The result of setting a member's role.
398#[derive(Debug)]
399
400pub enum SetMemberRoleResult {
401 InviteUpdated(Channel),
402 MembershipUpdated(MembershipUpdated),
403}
404
405/// The result of inviting a member to a channel.
406#[derive(Debug)]
407pub struct InviteMemberResult {
408 pub channel: Channel,
409 pub notifications: NotificationBatch,
410}
411
412#[derive(Debug)]
413pub struct RespondToChannelInvite {
414 pub membership_update: Option<MembershipUpdated>,
415 pub notifications: NotificationBatch,
416}
417
418#[derive(Debug)]
419pub struct RemoveChannelMemberResult {
420 pub membership_update: MembershipUpdated,
421 pub notification_id: Option<NotificationId>,
422}
423
424#[derive(Debug, PartialEq, Eq, Hash)]
425pub struct Channel {
426 pub id: ChannelId,
427 pub name: String,
428 pub visibility: ChannelVisibility,
429 /// parent_path is the channel ids from the root to this one (not including this one)
430 pub parent_path: Vec<ChannelId>,
431 pub channel_order: i32,
432}
433
434impl Channel {
435 pub fn from_model(value: channel::Model) -> Self {
436 Channel {
437 id: value.id,
438 visibility: value.visibility,
439 name: value.clone().name,
440 parent_path: value.ancestors().collect(),
441 channel_order: value.channel_order,
442 }
443 }
444
445 pub fn to_proto(&self) -> proto::Channel {
446 proto::Channel {
447 id: self.id.to_proto(),
448 name: self.name.clone(),
449 visibility: self.visibility.into(),
450 parent_path: self.parent_path.iter().map(|c| c.to_proto()).collect(),
451 channel_order: self.channel_order,
452 }
453 }
454
455 pub fn root_id(&self) -> ChannelId {
456 self.parent_path.first().copied().unwrap_or(self.id)
457 }
458}
459
460#[derive(Debug, PartialEq, Eq, Hash)]
461pub struct ChannelMember {
462 pub role: ChannelRole,
463 pub user_id: UserId,
464 pub kind: proto::channel_member::Kind,
465}
466
467impl ChannelMember {
468 pub fn to_proto(&self) -> proto::ChannelMember {
469 proto::ChannelMember {
470 role: self.role.into(),
471 user_id: self.user_id.to_proto(),
472 kind: self.kind.into(),
473 }
474 }
475}
476
477#[derive(Debug, PartialEq)]
478pub struct ChannelsForUser {
479 pub channels: Vec<Channel>,
480 pub channel_memberships: Vec<channel_member::Model>,
481 pub channel_participants: HashMap<ChannelId, Vec<UserId>>,
482 pub invited_channels: Vec<Channel>,
483
484 pub observed_buffer_versions: Vec<proto::ChannelBufferVersion>,
485 pub latest_buffer_versions: Vec<proto::ChannelBufferVersion>,
486}
487
488#[derive(Debug)]
489pub struct RejoinedChannelBuffer {
490 pub buffer: proto::RejoinedChannelBuffer,
491 pub old_connection_id: ConnectionId,
492}
493
494#[derive(Clone)]
495pub struct JoinRoom {
496 pub room: proto::Room,
497 pub channel: Option<channel::Model>,
498}
499
500pub struct RejoinedRoom {
501 pub room: proto::Room,
502 pub rejoined_projects: Vec<RejoinedProject>,
503 pub reshared_projects: Vec<ResharedProject>,
504 pub channel: Option<channel::Model>,
505}
506
507pub struct ResharedProject {
508 pub id: ProjectId,
509 pub old_connection_id: ConnectionId,
510 pub collaborators: Vec<ProjectCollaborator>,
511 pub worktrees: Vec<proto::WorktreeMetadata>,
512}
513
514pub struct RejoinedProject {
515 pub id: ProjectId,
516 pub old_connection_id: ConnectionId,
517 pub collaborators: Vec<ProjectCollaborator>,
518 pub worktrees: Vec<RejoinedWorktree>,
519 pub updated_repositories: Vec<proto::UpdateRepository>,
520 pub removed_repositories: Vec<u64>,
521 pub language_servers: Vec<LanguageServer>,
522}
523
524impl RejoinedProject {
525 pub fn to_proto(&self) -> proto::RejoinedProject {
526 let (language_servers, language_server_capabilities) = self
527 .language_servers
528 .clone()
529 .into_iter()
530 .map(|server| (server.server, server.capabilities))
531 .unzip();
532 proto::RejoinedProject {
533 id: self.id.to_proto(),
534 worktrees: self
535 .worktrees
536 .iter()
537 .map(|worktree| proto::WorktreeMetadata {
538 id: worktree.id,
539 root_name: worktree.root_name.clone(),
540 visible: worktree.visible,
541 abs_path: worktree.abs_path.clone(),
542 })
543 .collect(),
544 collaborators: self
545 .collaborators
546 .iter()
547 .map(|collaborator| collaborator.to_proto())
548 .collect(),
549 language_servers,
550 language_server_capabilities,
551 }
552 }
553}
554
555#[derive(Debug)]
556pub struct RejoinedWorktree {
557 pub id: u64,
558 pub abs_path: String,
559 pub root_name: String,
560 pub visible: bool,
561 pub updated_entries: Vec<proto::Entry>,
562 pub removed_entries: Vec<u64>,
563 pub updated_repositories: Vec<proto::RepositoryEntry>,
564 pub removed_repositories: Vec<u64>,
565 pub diagnostic_summaries: Vec<proto::DiagnosticSummary>,
566 pub settings_files: Vec<WorktreeSettingsFile>,
567 pub scan_id: u64,
568 pub completed_scan_id: u64,
569}
570
571pub struct LeftRoom {
572 pub room: proto::Room,
573 pub channel: Option<channel::Model>,
574 pub left_projects: HashMap<ProjectId, LeftProject>,
575 pub canceled_calls_to_user_ids: Vec<UserId>,
576 pub deleted: bool,
577}
578
579pub struct RefreshedRoom {
580 pub room: proto::Room,
581 pub channel: Option<channel::Model>,
582 pub stale_participant_user_ids: Vec<UserId>,
583 pub canceled_calls_to_user_ids: Vec<UserId>,
584}
585
586pub struct RefreshedChannelBuffer {
587 pub connection_ids: Vec<ConnectionId>,
588 pub collaborators: Vec<proto::Collaborator>,
589}
590
591pub struct Project {
592 pub id: ProjectId,
593 pub role: ChannelRole,
594 pub collaborators: Vec<ProjectCollaborator>,
595 pub worktrees: BTreeMap<u64, Worktree>,
596 pub repositories: Vec<proto::UpdateRepository>,
597 pub language_servers: Vec<LanguageServer>,
598 pub path_style: PathStyle,
599}
600
601pub struct ProjectCollaborator {
602 pub connection_id: ConnectionId,
603 pub user_id: UserId,
604 pub replica_id: ReplicaId,
605 pub is_host: bool,
606 pub committer_name: Option<String>,
607 pub committer_email: Option<String>,
608}
609
610impl ProjectCollaborator {
611 pub fn to_proto(&self) -> proto::Collaborator {
612 proto::Collaborator {
613 peer_id: Some(self.connection_id.into()),
614 replica_id: self.replica_id.0 as u32,
615 user_id: self.user_id.to_proto(),
616 is_host: self.is_host,
617 committer_name: self.committer_name.clone(),
618 committer_email: self.committer_email.clone(),
619 }
620 }
621}
622
623#[derive(Debug, Clone)]
624pub struct LanguageServer {
625 pub server: proto::LanguageServer,
626 pub capabilities: String,
627}
628
629#[derive(Debug)]
630pub struct LeftProject {
631 pub id: ProjectId,
632 pub should_unshare: bool,
633 pub connection_ids: Vec<ConnectionId>,
634}
635
636pub struct Worktree {
637 pub id: u64,
638 pub abs_path: String,
639 pub root_name: String,
640 pub visible: bool,
641 pub entries: Vec<proto::Entry>,
642 pub legacy_repository_entries: BTreeMap<u64, proto::RepositoryEntry>,
643 pub diagnostic_summaries: Vec<proto::DiagnosticSummary>,
644 pub settings_files: Vec<WorktreeSettingsFile>,
645 pub scan_id: u64,
646 pub completed_scan_id: u64,
647}
648
649#[derive(Debug)]
650pub struct WorktreeSettingsFile {
651 pub path: String,
652 pub content: String,
653 pub kind: LocalSettingsKind,
654}
655
656pub struct NewExtensionVersion {
657 pub name: String,
658 pub version: semver::Version,
659 pub description: String,
660 pub authors: Vec<String>,
661 pub repository: String,
662 pub schema_version: i32,
663 pub wasm_api_version: Option<String>,
664 pub provides: BTreeSet<ExtensionProvides>,
665 pub published_at: PrimitiveDateTime,
666}
667
668pub struct ExtensionVersionConstraints {
669 pub schema_versions: RangeInclusive<i32>,
670 pub wasm_api_versions: RangeInclusive<semver::Version>,
671}
672
673impl LocalSettingsKind {
674 pub fn from_proto(proto_kind: proto::LocalSettingsKind) -> Self {
675 match proto_kind {
676 proto::LocalSettingsKind::Settings => Self::Settings,
677 proto::LocalSettingsKind::Tasks => Self::Tasks,
678 proto::LocalSettingsKind::Editorconfig => Self::Editorconfig,
679 proto::LocalSettingsKind::Debug => Self::Debug,
680 }
681 }
682
683 pub fn to_proto(self) -> proto::LocalSettingsKind {
684 match self {
685 Self::Settings => proto::LocalSettingsKind::Settings,
686 Self::Tasks => proto::LocalSettingsKind::Tasks,
687 Self::Editorconfig => proto::LocalSettingsKind::Editorconfig,
688 Self::Debug => proto::LocalSettingsKind::Debug,
689 }
690 }
691}
692
693fn db_status_to_proto(
694 entry: project_repository_statuses::Model,
695) -> anyhow::Result<proto::StatusEntry> {
696 use proto::git_file_status::{Tracked, Unmerged, Variant};
697
698 let (simple_status, variant) =
699 match (entry.status_kind, entry.first_status, entry.second_status) {
700 (StatusKind::Untracked, None, None) => (
701 proto::GitStatus::Added as i32,
702 Variant::Untracked(Default::default()),
703 ),
704 (StatusKind::Ignored, None, None) => (
705 proto::GitStatus::Added as i32,
706 Variant::Ignored(Default::default()),
707 ),
708 (StatusKind::Unmerged, Some(first_head), Some(second_head)) => (
709 proto::GitStatus::Conflict as i32,
710 Variant::Unmerged(Unmerged {
711 first_head,
712 second_head,
713 }),
714 ),
715 (StatusKind::Tracked, Some(index_status), Some(worktree_status)) => {
716 let simple_status = if worktree_status != proto::GitStatus::Unmodified as i32 {
717 worktree_status
718 } else if index_status != proto::GitStatus::Unmodified as i32 {
719 index_status
720 } else {
721 proto::GitStatus::Unmodified as i32
722 };
723 (
724 simple_status,
725 Variant::Tracked(Tracked {
726 index_status,
727 worktree_status,
728 }),
729 )
730 }
731 _ => {
732 anyhow::bail!("Unexpected combination of status fields: {entry:?}");
733 }
734 };
735 Ok(proto::StatusEntry {
736 repo_path: entry.repo_path,
737 simple_status,
738 status: Some(proto::GitFileStatus {
739 variant: Some(variant),
740 }),
741 })
742}
743
744fn proto_status_to_db(
745 status_entry: proto::StatusEntry,
746) -> (String, StatusKind, Option<i32>, Option<i32>) {
747 use proto::git_file_status::{Tracked, Unmerged, Variant};
748
749 let (status_kind, first_status, second_status) = status_entry
750 .status
751 .clone()
752 .and_then(|status| status.variant)
753 .map_or(
754 (StatusKind::Untracked, None, None),
755 |variant| match variant {
756 Variant::Untracked(_) => (StatusKind::Untracked, None, None),
757 Variant::Ignored(_) => (StatusKind::Ignored, None, None),
758 Variant::Unmerged(Unmerged {
759 first_head,
760 second_head,
761 }) => (StatusKind::Unmerged, Some(first_head), Some(second_head)),
762 Variant::Tracked(Tracked {
763 index_status,
764 worktree_status,
765 }) => (
766 StatusKind::Tracked,
767 Some(index_status),
768 Some(worktree_status),
769 ),
770 },
771 );
772 (
773 status_entry.repo_path,
774 status_kind,
775 first_status,
776 second_status,
777 )
778}