From c0296687b8bf3515d1060f4911a5af4b629fda5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20R=C3=BC=C3=9Fler?= Date: Mon, 14 Jun 2021 19:17:53 +0200 Subject: [PATCH] Add push to commands in tags popup - Update missing remote tags after tags are pushed. --- src/components/taglist.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/components/taglist.rs b/src/components/taglist.rs index 96c465e5..e4845950 100644 --- a/src/components/taglist.rs +++ b/src/components/taglist.rs @@ -13,7 +13,10 @@ use anyhow::Result; use asyncgit::{ asyncjob::AsyncSingleJob, remote_tags::AsyncRemoteTagsJob, - sync::cred::{extract_username_password, need_username_password}, + sync::cred::{ + extract_username_password, need_username_password, + BasicAuthCredential, + }, sync::{get_tags_with_metadata, TagWithMetadata}, AsyncGitNotification, CWD, }; @@ -41,6 +44,7 @@ pub struct TagListComponent { table_state: std::cell::Cell, current_height: std::cell::Cell, missing_remote_tags: Option>, + basic_credential: Option, async_remote_tags: AsyncSingleJob, key_config: SharedKeyConfig, @@ -161,6 +165,11 @@ impl Component for TagListComponent { self.valid_selection(), true, )); + out.push(CommandInfo::new( + strings::commands::push_tags(&self.key_config), + true, + true, + )); } visibility_blocking(self) } @@ -212,6 +221,8 @@ impl Component for TagListComponent { Ok(EventState::Consumed) }, ); + } else if key == self.key_config.push { + self.queue.push(InternalEvent::PushTags); } } @@ -250,6 +261,7 @@ impl TagListComponent { visible: false, table_state: std::cell::Cell::new(TableState::default()), current_height: std::cell::Cell::new(0), + basic_credential: None, missing_remote_tags: None, async_remote_tags: AsyncSingleJob::new( sender.clone(), @@ -264,8 +276,6 @@ impl TagListComponent { self.table_state.get_mut().select(Some(0)); self.show()?; - self.update_tags()?; - let basic_credential = if need_username_password()? { let credential = extract_username_password()?; @@ -278,8 +288,10 @@ impl TagListComponent { None }; - self.async_remote_tags - .spawn(AsyncRemoteTagsJob::new(basic_credential)); + self.basic_credential = basic_credential; + + self.update_tags()?; + self.update_missing_remote_tags(); Ok(()) } @@ -293,6 +305,8 @@ impl TagListComponent { Some(missing_remote_tags); } } + } else if event == AsyncGitNotification::PushTags { + self.update_missing_remote_tags(); } } @@ -310,6 +324,12 @@ impl TagListComponent { Ok(()) } + pub fn update_missing_remote_tags(&mut self) { + self.async_remote_tags.spawn(AsyncRemoteTagsJob::new( + self.basic_credential.clone(), + )); + } + /// fn move_selection(&mut self, scroll_type: ScrollType) -> bool { let mut table_state = self.table_state.take();