git: Always reload current branch after pushing (#28327)
Closes #27347 Release Notes: - Fixed a bug causing the git panel to not update after pushing to a remote
This commit is contained in:
parent
e66a24edcf
commit
b687a5e56d
1 changed files with 33 additions and 6 deletions
|
@ -3263,7 +3263,7 @@ impl Repository {
|
||||||
remote: SharedString,
|
remote: SharedString,
|
||||||
options: Option<PushOptions>,
|
options: Option<PushOptions>,
|
||||||
askpass: AskPassDelegate,
|
askpass: AskPassDelegate,
|
||||||
_cx: &mut App,
|
cx: &mut Context<Self>,
|
||||||
) -> oneshot::Receiver<Result<RemoteCommandOutput>> {
|
) -> oneshot::Receiver<Result<RemoteCommandOutput>> {
|
||||||
let askpass_delegates = self.askpass_delegates.clone();
|
let askpass_delegates = self.askpass_delegates.clone();
|
||||||
let askpass_id = util::post_inc(&mut self.latest_askpass_id);
|
let askpass_id = util::post_inc(&mut self.latest_askpass_id);
|
||||||
|
@ -3276,25 +3276,52 @@ impl Repository {
|
||||||
})
|
})
|
||||||
.unwrap_or("");
|
.unwrap_or("");
|
||||||
|
|
||||||
|
let updates_tx = self
|
||||||
|
.git_store()
|
||||||
|
.and_then(|git_store| match &git_store.read(cx).state {
|
||||||
|
GitStoreState::Local { downstream, .. } => downstream
|
||||||
|
.as_ref()
|
||||||
|
.map(|downstream| downstream.updates_tx.clone()),
|
||||||
|
_ => None,
|
||||||
|
});
|
||||||
|
|
||||||
|
let this = cx.weak_entity();
|
||||||
self.send_job(
|
self.send_job(
|
||||||
Some(format!("git push{} {} {}", args, branch, remote).into()),
|
Some(format!("git push {} {} {}", args, branch, remote).into()),
|
||||||
move |git_repo, cx| async move {
|
move |git_repo, mut cx| async move {
|
||||||
match git_repo {
|
match git_repo {
|
||||||
RepositoryState::Local {
|
RepositoryState::Local {
|
||||||
backend,
|
backend,
|
||||||
environment,
|
environment,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
backend
|
let result = backend
|
||||||
.push(
|
.push(
|
||||||
branch.to_string(),
|
branch.to_string(),
|
||||||
remote.to_string(),
|
remote.to_string(),
|
||||||
options,
|
options,
|
||||||
askpass,
|
askpass,
|
||||||
environment.clone(),
|
environment.clone(),
|
||||||
cx,
|
cx.clone(),
|
||||||
)
|
)
|
||||||
.await
|
.await;
|
||||||
|
if result.is_ok() {
|
||||||
|
let branches = backend.branches().await?;
|
||||||
|
let branch = branches.into_iter().find(|branch| branch.is_head);
|
||||||
|
log::info!("head branch after scan is {branch:?}");
|
||||||
|
let snapshot = this.update(&mut cx, |this, cx| {
|
||||||
|
this.snapshot.branch = branch;
|
||||||
|
let snapshot = this.snapshot.clone();
|
||||||
|
cx.emit(RepositoryEvent::Updated { full_scan: false });
|
||||||
|
snapshot
|
||||||
|
})?;
|
||||||
|
if let Some(updates_tx) = updates_tx {
|
||||||
|
updates_tx
|
||||||
|
.unbounded_send(DownstreamUpdate::UpdateRepository(snapshot))
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result
|
||||||
}
|
}
|
||||||
RepositoryState::Remote { project_id, client } => {
|
RepositoryState::Remote { project_id, client } => {
|
||||||
askpass_delegates.lock().insert(askpass_id, askpass);
|
askpass_delegates.lock().insert(askpass_id, askpass);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue