-
-
Notifications
You must be signed in to change notification settings - Fork 616
Feature #875: Delete referring branches #935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
b26eddf
4f44f77
a2c14ac
e862988
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ use crate::{ | |
CommandInfo, Component, DrawableComponent, EventState, | ||
}, | ||
keys::SharedKeyConfig, | ||
queue::{InternalEvent, Queue}, | ||
queue::{Action, InternalEvent, Queue}, | ||
strings, | ||
ui::{self, style::SharedTheme}, | ||
}; | ||
|
@@ -15,13 +15,14 @@ use asyncgit::{ | |
extract_username_password, need_username_password, | ||
BasicAuthCredential, | ||
}, | ||
get_branch_remote, get_default_remote, | ||
get_branch_remote, get_branch_trackers, get_default_remote, | ||
}, | ||
AsyncGitNotification, AsyncPush, PushRequest, RemoteProgress, | ||
RemoteProgressState, CWD, | ||
}; | ||
use crossbeam_channel::Sender; | ||
use crossterm::event::Event; | ||
use std::collections::HashSet; | ||
use tui::{ | ||
backend::Backend, | ||
layout::Rect, | ||
|
@@ -60,6 +61,7 @@ pub struct PushComponent { | |
theme: SharedTheme, | ||
key_config: SharedKeyConfig, | ||
input_cred: CredComponent, | ||
tracking_branches: Option<Vec<String>>, | ||
} | ||
|
||
impl PushComponent { | ||
|
@@ -84,6 +86,7 @@ impl PushComponent { | |
), | ||
theme, | ||
key_config, | ||
tracking_branches: None, | ||
} | ||
} | ||
|
||
|
@@ -141,6 +144,19 @@ impl PushComponent { | |
remote | ||
}; | ||
|
||
self.tracking_branches = if self.modifier.delete() { | ||
let remote_ref = | ||
format!("refs/remotes/{}/{}", remote, self.branch); | ||
Some( | ||
get_branch_trackers(CWD, &remote_ref) | ||
.unwrap_or_else(|_| HashSet::new()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need an empty hashset here? can't we go with None in case there was a problem? |
||
.into_iter() | ||
.collect(), | ||
) | ||
} else { | ||
None | ||
}; | ||
|
||
self.pending = true; | ||
self.progress = None; | ||
self.git_push.request(PushRequest { | ||
|
@@ -175,6 +191,20 @@ impl PushComponent { | |
self.queue.push(InternalEvent::ShowErrorMsg( | ||
format!("push failed:\n{}", err), | ||
)); | ||
} else if self.modifier.delete() { | ||
// Check if we need to delete the tracking branches | ||
let tracking_branches = self | ||
.tracking_branches | ||
.take() | ||
.unwrap_or_else(Vec::new); | ||
|
||
if !tracking_branches.is_empty() { | ||
self.queue.push(InternalEvent::ConfirmAction( | ||
Action::DeleteTrackingBranches( | ||
tracking_branches.into_iter().collect(), | ||
), | ||
)); | ||
} | ||
} | ||
self.hide(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,6 +207,15 @@ pub fn confirm_msg_delete_branch( | |
) -> String { | ||
format!("Confirm deleting branch: '{}' ?", branch_ref) | ||
} | ||
pub fn confirm_msg_delete_tracking_branches( | ||
_key_config: &SharedKeyConfig, | ||
branches_ref: &[String], | ||
) -> String { | ||
format!( | ||
"Do you want to delete the referring tracking branches: {} ?", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since it is a list and we have a multiline message box, lets list the branch names one per line after the question |
||
branches_ref.join(", ") | ||
) | ||
} | ||
pub fn confirm_title_delete_remote_branch( | ||
_key_config: &SharedKeyConfig, | ||
) -> String { | ||
|
@@ -218,6 +227,15 @@ pub fn confirm_msg_delete_remote_branch( | |
) -> String { | ||
format!("Confirm deleting remote branch: '{}' ?", branch_ref) | ||
} | ||
pub fn confirm_msg_delete_referring_remote_branch( | ||
_key_config: &SharedKeyConfig, | ||
branch_ref: &str, | ||
) -> String { | ||
format!( | ||
"Do you want to delete the referring remote branch: '{}' ?", | ||
branch_ref | ||
) | ||
} | ||
pub fn confirm_title_delete_tag( | ||
_key_config: &SharedKeyConfig, | ||
) -> String { | ||
|
Uh oh!
There was an error while loading. Please reload this page.