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:
co-authored by
Jakub Konka
parent
d877e562ab
commit
87e3d6e014
@@ -2096,10 +2096,11 @@ impl GitStore {
|
||||
let repository_handle = Self::repository_for_request(&this, repository_id, &mut cx)?;
|
||||
|
||||
let branch_name = envelope.payload.branch_name;
|
||||
let is_push = envelope.payload.is_push;
|
||||
|
||||
let remotes = repository_handle
|
||||
.update(&mut cx, |repository_handle, _| {
|
||||
repository_handle.get_remotes(branch_name)
|
||||
repository_handle.get_remotes(branch_name, is_push)
|
||||
})?
|
||||
.await??;
|
||||
|
||||
@@ -4737,12 +4738,26 @@ impl Repository {
|
||||
pub fn get_remotes(
|
||||
&mut self,
|
||||
branch_name: Option<String>,
|
||||
is_push: bool,
|
||||
) -> oneshot::Receiver<Result<Vec<Remote>>> {
|
||||
let id = self.id;
|
||||
self.send_job(None, move |repo, _cx| async move {
|
||||
match repo {
|
||||
RepositoryState::Local(LocalRepositoryState { backend, .. }) => {
|
||||
backend.get_remotes(branch_name).await
|
||||
let remote = if let Some(branch_name) = branch_name {
|
||||
if is_push {
|
||||
backend.get_push_remote(branch_name).await?
|
||||
} else {
|
||||
backend.get_branch_remote(branch_name).await?
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
match remote {
|
||||
Some(remote) => Ok(vec![remote]),
|
||||
None => backend.get_all_remotes().await,
|
||||
}
|
||||
}
|
||||
RepositoryState::Remote(RemoteRepositoryState { project_id, client }) => {
|
||||
let response = client
|
||||
@@ -4750,6 +4765,7 @@ impl Repository {
|
||||
project_id: project_id.0,
|
||||
repository_id: id.to_proto(),
|
||||
branch_name,
|
||||
is_push,
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user