summaryrefslogtreecommitdiffstats
path: root/src/tabs
diff options
context:
space:
mode:
authorextrawurst <mail@rusticorn.com>2024-04-16 08:25:20 +0200
committerextrawurst <mail@rusticorn.com>2024-04-16 08:25:20 +0200
commit115fd168f5a6fb8b726b8ccee51b05fd722027c8 (patch)
treeaf6716ab93062d876e901e365c5fa73c19f7d4a7 /src/tabs
parent47db649e39d98560ffc6f977f0e33e8ff9088d18 (diff)
parent920c28cfd78b75d84aed7e3fcc543ac821e7afcb (diff)
Merge branch 'master'ratatui-25-update
Diffstat (limited to 'src/tabs')
-rw-r--r--src/tabs/revlog.rs4
-rw-r--r--src/tabs/status.rs23
2 files changed, 20 insertions, 7 deletions
diff --git a/src/tabs/revlog.rs b/src/tabs/revlog.rs
index 524550dd..cf4f966b 100644
--- a/src/tabs/revlog.rs
+++ b/src/tabs/revlog.rs
@@ -342,7 +342,7 @@ impl Revlog {
}
}
- fn is_in_search_mode(&self) -> bool {
+ const fn is_in_search_mode(&self) -> bool {
!matches!(self.search, LogSearch::Off)
}
@@ -396,7 +396,7 @@ impl Revlog {
);
}
- fn can_close_search(&self) -> bool {
+ const fn can_close_search(&self) -> bool {
self.is_in_search_mode() && !self.is_search_pending()
}
diff --git a/src/tabs/status.rs b/src/tabs/status.rs
index 67605f8e..feaf62bd 100644
--- a/src/tabs/status.rs
+++ b/src/tabs/status.rs
@@ -57,6 +57,11 @@ enum DiffTarget {
WorkingDir,
}
+struct RemoteStatus {
+ has_remotes: bool,
+ has_remote_for_push: bool,
+}
+
pub struct Status {
repo: RepoPathRef,
visible: bool,
@@ -65,8 +70,8 @@ pub struct Status {
index: ChangesComponent,
index_wd: ChangesComponent,
diff: DiffComponent,
+ remotes: RemoteStatus,
git_diff: AsyncDiff,
- has_remotes: bool,
git_state: RepoState,
git_status_workdir: AsyncStatus,
git_status_stage: AsyncStatus,
@@ -155,7 +160,10 @@ impl Status {
Self {
queue: env.queue.clone(),
visible: true,
- has_remotes: false,
+ remotes: RemoteStatus {
+ has_remotes: false,
+ has_remote_for_push: false,
+ },
git_state: RepoState::Clean,
focus: Focus::WorkDir,
diff_target: DiffTarget::WorkingDir,
@@ -407,9 +415,14 @@ impl Status {
}
fn check_remotes(&mut self) {
- self.has_remotes =
+ self.remotes.has_remotes =
sync::get_default_remote(&self.repo.borrow().clone())
.is_ok();
+ self.remotes.has_remote_for_push =
+ sync::get_default_remote_for_push(
+ &self.repo.borrow().clone(),
+ )
+ .is_ok();
}
///
@@ -600,11 +613,11 @@ impl Status {
.as_ref()
.map_or(true, |state| state.ahead > 0);
- is_ahead && self.has_remotes
+ is_ahead && self.remotes.has_remote_for_push
}
const fn can_pull(&self) -> bool {
- self.has_remotes && self.git_branch_state.is_some()
+ self.remotes.has_remotes && self.git_branch_state.is_some()
}
fn can_abort_merge(&self) -> bool {