Skip to content

Reset branch in branch popup #2171

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

Merged
merged 4 commits into from
Apr 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
extrawurst committed Apr 7, 2024
commit 51f32eb596ca8add6656ad794e77e3bedd721b3c
15 changes: 6 additions & 9 deletions src/popups/branchlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl Component for BranchListPopup {
) && self.valid_selection()
{
self.hide();
if let Some(commit_id) = self.get_selected() {
if let Some(commit_id) = self.get_selected_commit() {
self.queue.push(InternalEvent::OpenPopup(
StackablePopupOpen::CompareCommits(
InspectCommitOpen::new(commit_id),
Expand All @@ -296,9 +296,9 @@ impl Component for BranchListPopup {
self.queue.push(InternalEvent::FetchRemotes);
} else if key_match(e, self.key_config.keys.reset_branch)
{
if let Some(b) = self.get_selected_branch() {
if let Some(commit_id) = self.get_selected_commit() {
self.queue.push(InternalEvent::OpenResetPopup(
b.top_commit,
commit_id,
));
}
} else if key_match(
Expand Down Expand Up @@ -479,7 +479,7 @@ impl BranchListPopup {
}

fn inspect_head_of_branch(&mut self) {
if let Some(commit_id) = self.get_selected() {
if let Some(commit_id) = self.get_selected_commit() {
self.hide();
self.queue.push(InternalEvent::OpenPopup(
StackablePopupOpen::InspectCommit(
Expand Down Expand Up @@ -522,16 +522,13 @@ impl BranchListPopup {
.count() > 0
}

fn get_selected(&self) -> Option<CommitId> {
// top commit of selected branch
fn get_selected_commit(&self) -> Option<CommitId> {
self.branches
.get(usize::from(self.selection))
.map(|b| b.top_commit)
}

fn get_selected_branch(&self) -> Option<&BranchInfo> {
self.branches.get(usize::from(self.selection))
}

///
fn move_selection(&mut self, scroll: ScrollType) -> Result<bool> {
let new_selection = match scroll {
Expand Down