Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions crates/git_ui/src/git_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3161,11 +3161,29 @@ impl GitPanel {
];

cx.spawn_in(window, async move |git_panel, cx| {
git_panel.update(cx, |git_panel, cx| {
let task = git_panel.update(cx, |git_panel, cx| {
git_panel.project.read(cx).git_config(path, args, cx)
})
})?;
let result = task.await;

match result {
Ok(_) => {
let project =
git_panel.read_with(cx, |git_panel, _| git_panel.project.clone())?;
project.update(cx, |project, cx| {
project.global_git_configuration_updated(cx);
});
}
Err(e) => {
git_panel.update(cx, |git_panel, cx| {
git_panel.show_error_toast("trust directory", e, cx)
})?;
}
}

anyhow::Ok(())
})
.detach();
.detach_and_log_err(cx);
}
}

Expand Down
34 changes: 23 additions & 11 deletions crates/project/src/git_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,21 +542,15 @@ impl GitStore {
let fs = fs.clone();

cx.spawn(async move |this, cx| {
if !fs.is_file(&path).await {
return;
}

let watcher = fs.watch(&path, Duration::from_millis(100));
let (mut watcher, _) = watcher.await;
while let Some(_) = watcher.next().await {
let Ok(_) = this.update(cx, |this, cx| {
for repo in this.repositories.values() {
repo.update(cx, |this, cx| {
if this.job_sender.is_closed() {
let (job_sender, state) = (this.refetch_repo_state)(cx);
this.repository_state = state;
this.job_sender = job_sender;
this.schedule_scan(None, cx);
}
})
}
cx.emit(GitStoreEvent::GlobalConfigurationUpdated);
this.global_configuration_updated(cx);
}) else {
return;
};
Expand Down Expand Up @@ -692,6 +686,15 @@ impl GitStore {
matches!(self.state, GitStoreState::Local { .. })
}

pub fn global_configuration_updated(&mut self, cx: &mut Context<Self>) {
for repo in self.repositories.values() {
repo.update(cx, |repo, cx| {
repo.refetch_state_if_closed(cx);
});
}
cx.emit(GitStoreEvent::GlobalConfigurationUpdated);
}

fn set_active_repo_id(&mut self, repo_id: RepositoryId, cx: &mut Context<Self>) {
if self.active_repo_id != Some(repo_id) {
self.active_repo_id = Some(repo_id);
Expand Down Expand Up @@ -8191,6 +8194,15 @@ impl Repository {
ids
}

fn refetch_state_if_closed(&mut self, cx: &mut Context<Self>) {
if self.job_sender.is_closed() {
let (job_sender, state) = (self.refetch_repo_state)(cx);
self.repository_state = state;
self.job_sender = job_sender;
self.schedule_scan(None, cx);
}
}

pub fn access(&mut self, _cx: &App) -> oneshot::Receiver<GitAccess> {
self.send_job("access", None, move |git_repo, _cx| async move {
match git_repo {
Expand Down
6 changes: 6 additions & 0 deletions crates/project/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6033,6 +6033,12 @@ impl Project {
self.git_store.read(cx).git_config(path, args, cx)
}

pub fn global_git_configuration_updated(&self, cx: &mut Context<Self>) {
self.git_store.update(cx, |git_store, cx| {
git_store.global_configuration_updated(cx);
});
}

pub fn buffer_store(&self) -> &Entity<BufferStore> {
&self.buffer_store
}
Expand Down
Loading