git: Add option to branch from default branch in branch picker (#34663)
Closes #33700 The option shows up as an icon that appears on entries that would create a new branch. You can also branch from the default by secondary confirming, which the icon has a tooltip for as well. We based the default branch on the results from this command: `git symbolic-ref refs/remotes/upstream/HEAD` and fallback to `git symbolic-ref refs/remotes/origin/HEAD` Release Notes: - Add option to create a branch from a default branch in git branch picker --------- Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
parent
fa8dd1c547
commit
9fa634f02f
7 changed files with 133 additions and 9 deletions
|
@ -4025,6 +4025,25 @@ impl Repository {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn default_branch(&mut self) -> oneshot::Receiver<Result<Option<SharedString>>> {
|
||||
let id = self.id;
|
||||
self.send_job(None, move |repo, _| async move {
|
||||
match repo {
|
||||
RepositoryState::Local { backend, .. } => backend.default_branch().await,
|
||||
RepositoryState::Remote { project_id, client } => {
|
||||
let response = client
|
||||
.request(proto::GetDefaultBranch {
|
||||
project_id: project_id.0,
|
||||
repository_id: id.to_proto(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
anyhow::Ok(response.branch.map(SharedString::from))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn diff(&mut self, diff_type: DiffType, _cx: &App) -> oneshot::Receiver<Result<String>> {
|
||||
let id = self.id;
|
||||
self.send_job(None, move |repo, _cx| async move {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue