diff --git a/asyncgit/src/sync/mod.rs b/asyncgit/src/sync/mod.rs index 5bd4b0b7..ead8f99b 100644 --- a/asyncgit/src/sync/mod.rs +++ b/asyncgit/src/sync/mod.rs @@ -71,8 +71,8 @@ pub use merge::{ }; pub use rebase::rebase_branch; pub use remotes::{ - get_default_remote, get_remotes, push::AsyncProgress, - tags::PushTagsProgress, + get_default_remote, get_remotes, has_default_remote, + push::AsyncProgress, tags::PushTagsProgress, }; pub(crate) use repository::repo; pub use repository::{RepoPath, RepoPathRef}; diff --git a/asyncgit/src/sync/remotes/mod.rs b/asyncgit/src/sync/remotes/mod.rs index d17df4c6..c7ecbd50 100644 --- a/asyncgit/src/sync/remotes/mod.rs +++ b/asyncgit/src/sync/remotes/mod.rs @@ -85,6 +85,14 @@ pub(crate) fn get_default_remote_in_repo( Err(Error::NoDefaultRemoteFound) } +/// returns true based on result of `get_default_remote_in_repo` being anything but `NoDefaultRemoteFound` +pub fn has_default_remote(repo: &Repository) -> bool { + !matches!( + get_default_remote_in_repo(repo), + Err(Error::NoDefaultRemoteFound) + ) +} + /// fn fetch_from_remote( repo_path: &RepoPath, diff --git a/src/components/push.rs b/src/components/push.rs index a8295a7e..1a74df46 100644 --- a/src/components/push.rs +++ b/src/components/push.rs @@ -109,6 +109,8 @@ impl PushComponent { (false, false) => PushComponentModifier::None, }; + //TODO: check if branch is tracked on a remote or if we find a default remote if not go into a remote selection popup + self.show()?; if need_username_password(&self.repo.borrow())? {