fix issue with taglist component without remotes (#1112)

This commit is contained in:
Stephan Dilly 2022-01-27 21:56:54 +01:00 committed by GitHub
parent 11c055220d
commit e18aa48aea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 9 deletions

View File

@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
### Fixed
* opening tags list without remotes ([#1111](https://github.com/extrawurst/gitui/1111))
## [0.20.1] - 2021-01-26 ## [0.20.1] - 2021-01-26
This is was a immediate followup patch release to `0.20` see [release notes](https://github.com/extrawurst/gitui/releases/tag/v0.20.0) for the whole list of goodies in `0.20`. This is was a immediate followup patch release to `0.20` see [release notes](https://github.com/extrawurst/gitui/releases/tag/v0.20.0) for the whole list of goodies in `0.20`.

View File

@ -18,7 +18,9 @@ use asyncgit::{
extract_username_password, need_username_password, extract_username_password, need_username_password,
BasicAuthCredential, BasicAuthCredential,
}, },
sync::{get_tags_with_metadata, RepoPathRef, TagWithMetadata}, sync::{
self, get_tags_with_metadata, RepoPathRef, TagWithMetadata,
},
AsyncGitNotification, AsyncGitNotification,
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
@ -46,6 +48,7 @@ pub struct TagListComponent {
table_state: std::cell::Cell<TableState>, table_state: std::cell::Cell<TableState>,
current_height: std::cell::Cell<usize>, current_height: std::cell::Cell<usize>,
missing_remote_tags: Option<Vec<String>>, missing_remote_tags: Option<Vec<String>>,
has_remotes: bool,
basic_credential: Option<BasicAuthCredential>, basic_credential: Option<BasicAuthCredential>,
async_remote_tags: AsyncSingleJob<AsyncRemoteTagsJob>, async_remote_tags: AsyncSingleJob<AsyncRemoteTagsJob>,
key_config: SharedKeyConfig, key_config: SharedKeyConfig,
@ -170,7 +173,7 @@ impl Component for TagListComponent {
)); ));
out.push(CommandInfo::new( out.push(CommandInfo::new(
strings::commands::push_tags(&self.key_config), strings::commands::push_tags(&self.key_config),
true, self.has_remotes,
true, true,
)); ));
out.push(CommandInfo::new( out.push(CommandInfo::new(
@ -235,7 +238,9 @@ impl Component for TagListComponent {
Ok(EventState::Consumed) Ok(EventState::Consumed)
}, },
); );
} else if key == self.key_config.keys.push { } else if key == self.key_config.keys.push
&& self.has_remotes
{
self.queue.push(InternalEvent::PushTags); self.queue.push(InternalEvent::PushTags);
} }
} }
@ -274,6 +279,7 @@ impl TagListComponent {
queue: queue.clone(), queue: queue.clone(),
tags: None, tags: None,
visible: false, visible: false,
has_remotes: false,
table_state: std::cell::Cell::new(TableState::default()), table_state: std::cell::Cell::new(TableState::default()),
current_height: std::cell::Cell::new(0), current_height: std::cell::Cell::new(0),
basic_credential: None, basic_credential: None,
@ -289,7 +295,12 @@ impl TagListComponent {
self.table_state.get_mut().select(Some(0)); self.table_state.get_mut().select(Some(0));
self.show()?; self.show()?;
let basic_credential = self.has_remotes =
sync::get_branches_info(&self.repo.borrow(), false)
.map(|branches| !branches.is_empty())
.unwrap_or(false);
let basic_credential = if self.has_remotes {
if need_username_password(&self.repo.borrow())? { if need_username_password(&self.repo.borrow())? {
let credential = let credential =
extract_username_password(&self.repo.borrow())?; extract_username_password(&self.repo.borrow())?;
@ -301,7 +312,10 @@ impl TagListComponent {
} }
} else { } else {
None None
}; }
} else {
None
};
self.basic_credential = basic_credential; self.basic_credential = basic_credential;
@ -346,10 +360,12 @@ impl TagListComponent {
} }
pub fn update_missing_remote_tags(&mut self) { pub fn update_missing_remote_tags(&mut self) {
self.async_remote_tags.spawn(AsyncRemoteTagsJob::new( if self.has_remotes {
self.repo.borrow().clone(), self.async_remote_tags.spawn(AsyncRemoteTagsJob::new(
self.basic_credential.clone(), self.repo.borrow().clone(),
)); self.basic_credential.clone(),
));
}
} }
/// ///