mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-25 18:44:53 +03:00
Don’t show upstream if commit is local branch head
This commit is contained in:
parent
3af256c75a
commit
2554f04ace
@ -55,9 +55,18 @@ pub struct LocalBranch {
|
||||
///
|
||||
pub has_upstream: bool,
|
||||
///
|
||||
pub upstream: Option<UpstreamBranch>,
|
||||
///
|
||||
pub remote: Option<String>,
|
||||
}
|
||||
|
||||
///
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct UpstreamBranch {
|
||||
///
|
||||
pub reference: String,
|
||||
}
|
||||
|
||||
///
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RemoteBranch {
|
||||
@ -154,10 +163,18 @@ pub fn get_branches_info(
|
||||
|
||||
let name_bytes = branch.name_bytes()?;
|
||||
|
||||
let upstream_branch =
|
||||
upstream.ok().and_then(|upstream| {
|
||||
bytes2string(upstream.get().name_bytes())
|
||||
.ok()
|
||||
.map(|reference| UpstreamBranch { reference })
|
||||
});
|
||||
|
||||
let details = if local {
|
||||
BranchDetails::Local(LocalBranch {
|
||||
is_head: branch.is_head(),
|
||||
has_upstream: upstream.is_ok(),
|
||||
has_upstream: upstream_branch.is_some(),
|
||||
upstream: upstream_branch,
|
||||
remote,
|
||||
})
|
||||
} else {
|
||||
|
@ -41,7 +41,7 @@ pub use branch::{
|
||||
merge_commit::merge_upstream_commit,
|
||||
merge_ff::branch_merge_upstream_fastforward,
|
||||
merge_rebase::merge_upstream_rebase, rename::rename_branch,
|
||||
validate_branch_name, BranchCompare, BranchInfo,
|
||||
validate_branch_name, BranchCompare, BranchDetails, BranchInfo,
|
||||
};
|
||||
pub use commit::{amend, commit, tag_commit};
|
||||
pub use commit_details::{
|
||||
|
@ -13,7 +13,8 @@ use crate::{
|
||||
};
|
||||
use anyhow::Result;
|
||||
use asyncgit::sync::{
|
||||
checkout_commit, BranchInfo, CommitId, RepoPathRef, Tags,
|
||||
checkout_commit, BranchDetails, BranchInfo, CommitId,
|
||||
RepoPathRef, Tags,
|
||||
};
|
||||
use chrono::{DateTime, Local};
|
||||
use crossterm::event::Event;
|
||||
@ -430,13 +431,40 @@ impl CommitList {
|
||||
let remote_branches = self
|
||||
.remote_branches
|
||||
.get(&e.id)
|
||||
.map(|remote_branches| {
|
||||
remote_branches
|
||||
.and_then(|remote_branches| {
|
||||
let filtered_branches: Vec<_> = remote_branches
|
||||
.iter()
|
||||
.filter(|remote_branch| {
|
||||
self.local_branches
|
||||
.get(&e.id)
|
||||
.map_or(true, |local_branch| {
|
||||
local_branch.iter().any(
|
||||
|local_branch| {
|
||||
let has_corresponding_local_branch = match &local_branch.details {
|
||||
BranchDetails::Local(details) =>
|
||||
details
|
||||
.upstream
|
||||
.as_ref()
|
||||
.map_or(false, |upstream| upstream.reference == remote_branch.reference),
|
||||
BranchDetails::Remote(_) =>
|
||||
false,
|
||||
};
|
||||
|
||||
!has_corresponding_local_branch
|
||||
},
|
||||
)
|
||||
})
|
||||
})
|
||||
.map(|remote_branch| {
|
||||
format!("[{0}]", remote_branch.name)
|
||||
})
|
||||
.join(" ")
|
||||
.collect();
|
||||
|
||||
if filtered_branches.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(filtered_branches.join(" "))
|
||||
}
|
||||
});
|
||||
|
||||
let marked = if any_marked {
|
||||
|
Loading…
Reference in New Issue
Block a user