diff options
author | extrawurst <776816+extrawurst@users.noreply.github.com> | 2024-02-19 15:46:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-19 15:46:39 +0100 |
commit | ab95b98ef80938d56caa1e4f75c9d9c63af738c9 (patch) | |
tree | cd82882e9c65599fffeeff9d3e84f3e80d4bfe69 /src | |
parent | be10d9096a93b030ec3f1ab776a21225d974e272 (diff) |
allow pushing to empty repo (#2063)
closes #1919
Diffstat (limited to 'src')
-rw-r--r-- | src/tabs/status.rs | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/src/tabs/status.rs b/src/tabs/status.rs index 592d4d4e..f9d53cf9 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -15,14 +15,13 @@ use crate::{ }; use anyhow::Result; use asyncgit::{ - asyncjob::AsyncSingleJob, cached, sync::{ self, status::StatusType, RepoPath, RepoPathRef, RepoState, }, sync::{BranchCompare, CommitId}, - AsyncBranchesJob, AsyncDiff, AsyncGitNotification, AsyncStatus, - DiffParams, DiffType, PushType, StatusItem, StatusParams, + AsyncDiff, AsyncGitNotification, AsyncStatus, DiffParams, + DiffType, PushType, StatusItem, StatusParams, }; use crossterm::event::Event; @@ -74,7 +73,6 @@ pub struct Status { git_status_stage: AsyncStatus, git_branch_state: Option<BranchCompare>, git_branch_name: cached::BranchName, - git_branches: AsyncSingleJob<AsyncBranchesJob>, queue: Queue, git_action_executed: bool, options: SharedOptions, @@ -187,7 +185,6 @@ impl Status { repo_clone, env.sender_git.clone(), ), - git_branches: AsyncSingleJob::new(env.sender_git.clone()), git_action_executed: false, git_branch_state: None, git_branch_name: cached::BranchName::new( @@ -408,22 +405,12 @@ impl Status { self.git_diff.is_pending() || self.git_status_stage.is_pending() || self.git_status_workdir.is_pending() - || self.git_branches.is_pending() } fn check_remotes(&mut self) { - self.has_remotes = false; - - if let Some(result) = self.git_branches.take_last() { - if let Some(Ok(branches)) = result.result() { - self.has_remotes = !branches.is_empty(); - } - } else { - self.git_branches.spawn(AsyncBranchesJob::new( - self.repo.borrow().clone(), - false, - )); - } + self.has_remotes = + sync::get_default_remote(&self.repo.borrow().clone()) + .is_ok(); } /// @@ -609,10 +596,12 @@ impl Status { } fn can_push(&self) -> bool { - self.git_branch_state + let is_ahead = self + .git_branch_state .as_ref() - .map_or(true, |state| state.ahead > 0) - && self.has_remotes + .map_or(true, |state| state.ahead > 0); + + is_ahead && self.has_remotes } const fn can_pull(&self) -> bool { |