git: Check push config before falling back to branch remote (#41700)

Closes #26649

Release Notes:

- Improved git support for remotes handling. Git will now check pushRemote and pushDefault configurations before
falling back to branch remote.

---------

Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
This commit is contained in:
Mayank Verma
2025-11-28 11:47:21 +00:00
committed by GitHub
co-authored by Jakub Konka
parent d877e562ab
commit 87e3d6e014
5 changed files with 87 additions and 23 deletions
+5 -4
View File
@@ -2111,7 +2111,7 @@ impl GitPanel {
cx.spawn_in(window, async move |_, cx| {
let repo = repo?;
let remotes = repo
.update(cx, |repo, _| repo.get_remotes(None))
.update(cx, |repo, _| repo.get_remotes(None, false))
.ok()?
.await
.ok()?
@@ -2375,7 +2375,7 @@ impl GitPanel {
};
telemetry::event!("Git Pulled");
let branch = branch.clone();
let remote = self.get_remote(false, window, cx);
let remote = self.get_remote(false, false, window, cx);
cx.spawn_in(window, async move |this, cx| {
let remote = match remote.await {
Ok(Some(remote)) => remote,
@@ -2451,7 +2451,7 @@ impl GitPanel {
_ => None,
}
};
let remote = self.get_remote(select_remote, window, cx);
let remote = self.get_remote(select_remote, true, window, cx);
cx.spawn_in(window, async move |this, cx| {
let remote = match remote.await {
@@ -2528,6 +2528,7 @@ impl GitPanel {
fn get_remote(
&mut self,
always_select: bool,
is_push: bool,
window: &mut Window,
cx: &mut Context<Self>,
) -> impl Future<Output = anyhow::Result<Option<Remote>>> + use<> {
@@ -2545,7 +2546,7 @@ impl GitPanel {
let current_branch = repo.branch.as_ref().context("No active branch")?;
Some(current_branch.name().to_string())
};
anyhow::Ok(repo.get_remotes(current_branch))
anyhow::Ok(repo.get_remotes(current_branch, is_push))
})??
.await??;