Use current upstream for permalink to line (#26398)
Release Notes: - git: Copy permalink to line now uses the upstream of the current branch instead of "origin"
This commit is contained in:
parent
8ceba89d81
commit
94e4aa626d
2 changed files with 17 additions and 3 deletions
|
@ -56,6 +56,14 @@ pub struct Upstream {
|
||||||
pub tracking: UpstreamTracking,
|
pub tracking: UpstreamTracking,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Upstream {
|
||||||
|
pub fn remote_name(&self) -> Option<&str> {
|
||||||
|
self.ref_name
|
||||||
|
.strip_prefix("refs/remotes/")
|
||||||
|
.and_then(|stripped| stripped.split("/").next())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||||
pub enum UpstreamTracking {
|
pub enum UpstreamTracking {
|
||||||
/// Remote ref not present in local repository.
|
/// Remote ref not present in local repository.
|
||||||
|
|
|
@ -1692,11 +1692,17 @@ impl BufferStore {
|
||||||
Err(e) => return Task::ready(Err(e)),
|
Err(e) => return Task::ready(Err(e)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let remote = repo_entry
|
||||||
|
.branch()
|
||||||
|
.and_then(|b| b.upstream.as_ref())
|
||||||
|
.and_then(|b| b.remote_name())
|
||||||
|
.unwrap_or("origin")
|
||||||
|
.to_string();
|
||||||
|
|
||||||
cx.spawn(|cx| async move {
|
cx.spawn(|cx| async move {
|
||||||
const REMOTE_NAME: &str = "origin";
|
|
||||||
let origin_url = repo
|
let origin_url = repo
|
||||||
.remote_url(REMOTE_NAME)
|
.remote_url(&remote)
|
||||||
.ok_or_else(|| anyhow!("remote \"{REMOTE_NAME}\" not found"))?;
|
.ok_or_else(|| anyhow!("remote \"{remote}\" not found"))?;
|
||||||
|
|
||||||
let sha = repo
|
let sha = repo
|
||||||
.head_sha()
|
.head_sha()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue