Skip to content

Commit c029668

Browse files
cruesslerStephan Dilly
authored andcommitted
Add push to commands in tags popup
- Update missing remote tags after tags are pushed.
1 parent 2a5834a commit c029668

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

src/components/taglist.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ use anyhow::Result;
1313
use asyncgit::{
1414
asyncjob::AsyncSingleJob,
1515
remote_tags::AsyncRemoteTagsJob,
16-
sync::cred::{extract_username_password, need_username_password},
16+
sync::cred::{
17+
extract_username_password, need_username_password,
18+
BasicAuthCredential,
19+
},
1720
sync::{get_tags_with_metadata, TagWithMetadata},
1821
AsyncGitNotification, CWD,
1922
};
@@ -41,6 +44,7 @@ pub struct TagListComponent {
4144
table_state: std::cell::Cell<TableState>,
4245
current_height: std::cell::Cell<usize>,
4346
missing_remote_tags: Option<Vec<String>>,
47+
basic_credential: Option<BasicAuthCredential>,
4448
async_remote_tags:
4549
AsyncSingleJob<AsyncRemoteTagsJob, AsyncGitNotification>,
4650
key_config: SharedKeyConfig,
@@ -161,6 +165,11 @@ impl Component for TagListComponent {
161165
self.valid_selection(),
162166
true,
163167
));
168+
out.push(CommandInfo::new(
169+
strings::commands::push_tags(&self.key_config),
170+
true,
171+
true,
172+
));
164173
}
165174
visibility_blocking(self)
166175
}
@@ -212,6 +221,8 @@ impl Component for TagListComponent {
212221
Ok(EventState::Consumed)
213222
},
214223
);
224+
} else if key == self.key_config.push {
225+
self.queue.push(InternalEvent::PushTags);
215226
}
216227
}
217228

@@ -250,6 +261,7 @@ impl TagListComponent {
250261
visible: false,
251262
table_state: std::cell::Cell::new(TableState::default()),
252263
current_height: std::cell::Cell::new(0),
264+
basic_credential: None,
253265
missing_remote_tags: None,
254266
async_remote_tags: AsyncSingleJob::new(
255267
sender.clone(),
@@ -264,8 +276,6 @@ impl TagListComponent {
264276
self.table_state.get_mut().select(Some(0));
265277
self.show()?;
266278

267-
self.update_tags()?;
268-
269279
let basic_credential = if need_username_password()? {
270280
let credential = extract_username_password()?;
271281

@@ -278,8 +288,10 @@ impl TagListComponent {
278288
None
279289
};
280290

281-
self.async_remote_tags
282-
.spawn(AsyncRemoteTagsJob::new(basic_credential));
291+
self.basic_credential = basic_credential;
292+
293+
self.update_tags()?;
294+
self.update_missing_remote_tags();
283295

284296
Ok(())
285297
}
@@ -293,6 +305,8 @@ impl TagListComponent {
293305
Some(missing_remote_tags);
294306
}
295307
}
308+
} else if event == AsyncGitNotification::PushTags {
309+
self.update_missing_remote_tags();
296310
}
297311
}
298312

@@ -310,6 +324,12 @@ impl TagListComponent {
310324
Ok(())
311325
}
312326

327+
pub fn update_missing_remote_tags(&mut self) {
328+
self.async_remote_tags.spawn(AsyncRemoteTagsJob::new(
329+
self.basic_credential.clone(),
330+
));
331+
}
332+
313333
///
314334
fn move_selection(&mut self, scroll_type: ScrollType) -> bool {
315335
let mut table_state = self.table_state.take();

0 commit comments

Comments
 (0)