Skip to content

Commit b471291

Browse files
author
Stephan Dilly
committed
fix conflict
1 parent b126015 commit b471291

File tree

9 files changed

+66
-5
lines changed

9 files changed

+66
-5
lines changed

asyncgit/src/sync/merge.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use crate::{
22
error::{Error, Result},
33
sync::{
44
branch::merge_commit::commit_merge_with_head,
5-
rebase::{continue_rebase, get_rebase_progress},
5+
rebase::{
6+
abort_rebase, continue_rebase, get_rebase_progress,
7+
},
68
reset_stage, reset_workdir, utils, CommitId,
79
},
810
};
@@ -74,6 +76,15 @@ pub fn continue_pending_rebase(
7476
continue_rebase(&repo)
7577
}
7678

79+
///
80+
pub fn abort_pending_rebase(repo_path: &str) -> Result<()> {
81+
scope_time!("abort_pending_rebase");
82+
83+
let repo = utils::repo(repo_path)?;
84+
85+
abort_rebase(&repo)
86+
}
87+
7788
///
7889
pub fn merge_branch_repo(
7990
repo: &Repository,

asyncgit/src/sync/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ pub use hunks::{reset_hunk, stage_hunk, unstage_hunk};
5858
pub use ignore::add_to_ignore;
5959
pub use logwalker::{LogWalker, LogWalkerFilter};
6060
pub use merge::{
61-
abort_merge, continue_pending_rebase, merge_branch, merge_commit,
62-
merge_msg, mergehead_ids, rebase_progress,
61+
abort_merge, abort_pending_rebase, continue_pending_rebase,
62+
merge_branch, merge_commit, merge_msg, mergehead_ids,
63+
rebase_progress,
6364
};
6465
pub use rebase::rebase_branch;
6566
pub use remotes::{

asyncgit/src/sync/rebase.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ pub fn get_rebase_progress(
161161
}
162162

163163
///
164-
#[allow(dead_code)]
165164
pub fn abort_rebase(repo: &git2::Repository) -> Result<()> {
166165
let mut rebase = repo.open_rebase(None)?;
167166

src/app.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,10 @@ impl App {
821821
self.status_tab.abort_merge();
822822
flags.insert(NeedsUpdate::ALL);
823823
}
824+
Action::AbortRebase => {
825+
self.status_tab.abort_rebase();
826+
flags.insert(NeedsUpdate::ALL);
827+
}
824828
};
825829

826830
Ok(())

src/components/reset.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ impl ConfirmComponent {
200200
Action::AbortMerge => (
201201
strings::confirm_title_abortmerge(),
202202
strings::confirm_msg_abortmerge(),
203+
),
204+
Action::AbortRebase => (
205+
strings::confirm_title_abortrebase(),
206+
strings::confirm_msg_abortrebase(),
203207
),
204208
};
205209
}

src/keys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl Default for KeyConfig {
158158
force_push: KeyEvent { code: KeyCode::Char('P'), modifiers: KeyModifiers::SHIFT},
159159
undo_commit: KeyEvent { code: KeyCode::Char('U'), modifiers: KeyModifiers::SHIFT},
160160
pull: KeyEvent { code: KeyCode::Char('f'), modifiers: KeyModifiers::empty()},
161-
abort_merge: KeyEvent { code: KeyCode::Char('M'), modifiers: KeyModifiers::SHIFT},
161+
abort_merge: KeyEvent { code: KeyCode::Char('A'), modifiers: KeyModifiers::SHIFT},
162162
open_file_tree: KeyEvent { code: KeyCode::Char('F'), modifiers: KeyModifiers::SHIFT},
163163
file_find: KeyEvent { code: KeyCode::Char('f'), modifiers: KeyModifiers::empty()},
164164
}

src/queue.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub enum Action {
4141
ForcePush(String, bool),
4242
PullMerge { incoming: usize, rebase: bool },
4343
AbortMerge,
44+
AbortRebase,
4445
}
4546

4647
///

src/strings.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ pub fn confirm_msg_abortmerge() -> String {
153153
"This will revert all uncommitted changes. Are you sure?"
154154
.to_string()
155155
}
156+
pub fn confirm_title_abortrebase() -> String {
157+
"Abort rebase?".to_string()
158+
}
159+
pub fn confirm_msg_abortrebase() -> String {
160+
"This will revert all uncommitted changes. Are you sure?"
161+
.to_string()
162+
}
156163
pub fn confirm_msg_reset() -> String {
157164
"confirm file reset?".to_string()
158165
}
@@ -641,6 +648,18 @@ pub mod commands {
641648
CMD_GROUP_GENERAL,
642649
)
643650
}
651+
652+
pub fn abort_rebase(key_config: &SharedKeyConfig) -> CommandText {
653+
CommandText::new(
654+
format!(
655+
"Abort rebase [{}]",
656+
key_config.get_hint(key_config.abort_merge),
657+
),
658+
"abort ongoing rebase",
659+
CMD_GROUP_GENERAL,
660+
)
661+
}
662+
644663
pub fn select_staging(
645664
key_config: &SharedKeyConfig,
646665
) -> CommandText {

src/tabs/status.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,14 @@ impl Status {
550550
try_or_popup!(self, "abort merge", sync::abort_merge(CWD));
551551
}
552552

553+
pub fn abort_rebase(&self) {
554+
try_or_popup!(
555+
self,
556+
"abort rebase",
557+
sync::abort_pending_rebase(CWD)
558+
);
559+
}
560+
553561
fn continue_rebase(&self) {
554562
try_or_popup!(
555563
self,
@@ -655,11 +663,17 @@ impl Component for Status {
655663
true,
656664
Self::can_abort_merge() || force_all,
657665
));
666+
658667
out.push(CommandInfo::new(
659668
strings::commands::continue_rebase(&self.key_config),
660669
true,
661670
Self::pending_rebase() || force_all,
662671
));
672+
out.push(CommandInfo::new(
673+
strings::commands::abort_rebase(&self.key_config),
674+
true,
675+
Self::pending_rebase() || force_all,
676+
));
663677
}
664678

665679
{
@@ -765,6 +779,14 @@ impl Component for Status {
765779
Action::AbortMerge,
766780
));
767781

782+
Ok(EventState::Consumed)
783+
} else if k == self.key_config.abort_merge
784+
&& Self::pending_rebase()
785+
{
786+
self.queue.push(InternalEvent::ConfirmAction(
787+
Action::AbortRebase,
788+
));
789+
768790
Ok(EventState::Consumed)
769791
} else if k == self.key_config.rebase_branch
770792
&& Self::pending_rebase()

0 commit comments

Comments
 (0)