Skip to content

Commit

Permalink
Add confirmation dialog for undo commit (#1909)
Browse files Browse the repository at this point in the history
  • Loading branch information
sainad2222 authored Oct 17, 2023
1 parent 2fd957e commit 0e2b3db
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
* `theme.ron` now supports customizing line break symbol ([#1894](https://github.com/extrawurst/gitui/issues/1894))

* add confirmation for dialog for undo commit ([#1912](https://github.com/extrawurst/gitui/issues/1912))

## [0.24.3] - 2023-09-09

### Fixes
Expand Down
14 changes: 13 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ use crate::{
setup_popups,
strings::{self, ellipsis_trim_start, order},
tabs::{FilesTab, Revlog, StashList, Stashing, Status},
try_or_popup,
ui::style::{SharedTheme, Theme},
AsyncAppNotification, AsyncNotification,
};
use anyhow::{bail, Result};
use asyncgit::{
sync::{self, utils::repo_work_dir, RepoPath, RepoPathRef},
sync::{
self,
utils::{repo_work_dir, undo_last_commit},
RepoPath, RepoPathRef,
},
AsyncGitNotification, PushType,
};
use crossbeam_channel::Sender;
Expand Down Expand Up @@ -1076,6 +1081,13 @@ impl App {
Action::AbortRebase => {
self.status_tab.abort_rebase();
}
Action::UndoCommit => {
try_or_popup!(
self,
"undo commit failed:",
undo_last_commit(&self.repo.borrow())
);
}
};

flags.insert(NeedsUpdate::ALL);
Expand Down
4 changes: 4 additions & 0 deletions src/components/reset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ impl ConfirmComponent {
strings::confirm_title_abortrevert(),
strings::confirm_msg_revertchanges(),
),
Action::UndoCommit => (
strings::confirm_title_undo_commit(),
strings::confirm_msg_undo_commit(),
),
};
}

Expand Down
1 change: 1 addition & 0 deletions src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub enum Action {
AbortMerge,
AbortRebase,
AbortRevert,
UndoCommit,
}

#[derive(Debug)]
Expand Down
6 changes: 6 additions & 0 deletions src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ pub fn stash_popup_msg(_key_config: &SharedKeyConfig) -> String {
pub fn confirm_title_reset() -> String {
"Reset".to_string()
}
pub fn confirm_title_undo_commit() -> String {
"Undo commit".to_string()
}
pub fn confirm_title_stashdrop(
_key_config: &SharedKeyConfig,
multiple: bool,
Expand Down Expand Up @@ -203,6 +206,9 @@ pub fn confirm_msg_reset_lines(lines: usize) -> String {
"are you sure you want to discard {lines} selected lines?"
)
}
pub fn confirm_msg_undo_commit() -> String {
"confirm undo last commit?".to_string()
}
pub fn confirm_msg_stashdrop(
_key_config: &SharedKeyConfig,
ids: &[CommitId],
Expand Down
7 changes: 2 additions & 5 deletions src/tabs/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,11 +610,8 @@ impl Status {
}

fn undo_last_commit(&self) {
try_or_popup!(
self,
"undo commit failed:",
sync::utils::undo_last_commit(&self.repo.borrow())
);
self.queue
.push(InternalEvent::ConfirmAction(Action::UndoCommit));
}

fn branch_compare(&mut self) {
Expand Down

0 comments on commit 0e2b3db

Please sign in to comment.