Skip to content

Commit e18aa48

Browse files
author
Stephan Dilly
authored
fix issue with taglist component without remotes (#1112)
1 parent 11c0552 commit e18aa48

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Fixed
11+
* opening tags list without remotes ([#1111](https://github.com/extrawurst/gitui/1111))
12+
1013
## [0.20.1] - 2021-01-26
1114

1215
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`.

src/components/taglist.rs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ use asyncgit::{
1818
extract_username_password, need_username_password,
1919
BasicAuthCredential,
2020
},
21-
sync::{get_tags_with_metadata, RepoPathRef, TagWithMetadata},
21+
sync::{
22+
self, get_tags_with_metadata, RepoPathRef, TagWithMetadata,
23+
},
2224
AsyncGitNotification,
2325
};
2426
use crossbeam_channel::Sender;
@@ -46,6 +48,7 @@ pub struct TagListComponent {
4648
table_state: std::cell::Cell<TableState>,
4749
current_height: std::cell::Cell<usize>,
4850
missing_remote_tags: Option<Vec<String>>,
51+
has_remotes: bool,
4952
basic_credential: Option<BasicAuthCredential>,
5053
async_remote_tags: AsyncSingleJob<AsyncRemoteTagsJob>,
5154
key_config: SharedKeyConfig,
@@ -170,7 +173,7 @@ impl Component for TagListComponent {
170173
));
171174
out.push(CommandInfo::new(
172175
strings::commands::push_tags(&self.key_config),
173-
true,
176+
self.has_remotes,
174177
true,
175178
));
176179
out.push(CommandInfo::new(
@@ -235,7 +238,9 @@ impl Component for TagListComponent {
235238
Ok(EventState::Consumed)
236239
},
237240
);
238-
} else if key == self.key_config.keys.push {
241+
} else if key == self.key_config.keys.push
242+
&& self.has_remotes
243+
{
239244
self.queue.push(InternalEvent::PushTags);
240245
}
241246
}
@@ -274,6 +279,7 @@ impl TagListComponent {
274279
queue: queue.clone(),
275280
tags: None,
276281
visible: false,
282+
has_remotes: false,
277283
table_state: std::cell::Cell::new(TableState::default()),
278284
current_height: std::cell::Cell::new(0),
279285
basic_credential: None,
@@ -289,7 +295,12 @@ impl TagListComponent {
289295
self.table_state.get_mut().select(Some(0));
290296
self.show()?;
291297

292-
let basic_credential =
298+
self.has_remotes =
299+
sync::get_branches_info(&self.repo.borrow(), false)
300+
.map(|branches| !branches.is_empty())
301+
.unwrap_or(false);
302+
303+
let basic_credential = if self.has_remotes {
293304
if need_username_password(&self.repo.borrow())? {
294305
let credential =
295306
extract_username_password(&self.repo.borrow())?;
@@ -301,7 +312,10 @@ impl TagListComponent {
301312
}
302313
} else {
303314
None
304-
};
315+
}
316+
} else {
317+
None
318+
};
305319

306320
self.basic_credential = basic_credential;
307321

@@ -346,10 +360,12 @@ impl TagListComponent {
346360
}
347361

348362
pub fn update_missing_remote_tags(&mut self) {
349-
self.async_remote_tags.spawn(AsyncRemoteTagsJob::new(
350-
self.repo.borrow().clone(),
351-
self.basic_credential.clone(),
352-
));
363+
if self.has_remotes {
364+
self.async_remote_tags.spawn(AsyncRemoteTagsJob::new(
365+
self.repo.borrow().clone(),
366+
self.basic_credential.clone(),
367+
));
368+
}
353369
}
354370

355371
///

0 commit comments

Comments
 (0)