Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 15 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,15 @@ Examples:
},

/// Fetch trunk, refresh it locally, and rebase stale branches onto their latest parent tips
Restack,
#[command(after_help = "\
Examples:
ez restack
ez restack --force")]
Restack {
/// Force restack even if merge commits are detected in feature branches
#[arg(long)]
force: bool,
},

/// Move up one branch in the stack
Up,
Expand Down Expand Up @@ -353,11 +361,16 @@ Examples:
#[command(after_help = "\
Examples:
ez move --onto main
ez move --onto feat/base")]
ez move --onto feat/base
ez move --force --onto main")]
Move {
/// New parent branch
#[arg(long)]
onto: String,

/// Force move even if merge commits or stale metadata are detected
#[arg(long)]
force: bool,
},

/// Merge the bottom PR of the current stack via GitHub
Expand Down
1 change: 1 addition & 0 deletions src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod move_branch;
pub mod mutation_guard;
pub mod navigate;
pub mod parent;
pub mod preflight;
pub mod pr_edit;
pub mod pr_link;
pub mod pr_view;
Expand Down
13 changes: 12 additions & 1 deletion src/cmd/move_branch.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use anyhow::{Result, bail};

use crate::cmd::preflight;
use crate::cmd::rebase_conflict;
use crate::error::EzError;
use crate::git;
use crate::github;
use crate::stack::StackState;
use crate::ui;

pub fn run(onto: &str) -> Result<()> {
pub fn run(onto: &str, force: bool) -> Result<()> {
let mut state = StackState::load()?;
if let Some(root) = git::current_linked_worktree_root()? {
ui::linked_worktree_warning(&root);
Expand Down Expand Up @@ -44,6 +45,16 @@ pub fn run(onto: &str) -> Result<()> {
)));
}

// Pre-flight: detect merge commits, stale metadata, and redundancy.
if let Some(check) = preflight::check_single(&state, &current) {
if preflight::report_and_check(&[check], force) {
bail!(EzError::UserMessage(
"move aborted — resolve the issues above or use `ez move --force --onto ...`"
.to_string()
));
}
}

let meta = state.get_branch(&current)?;
let old_parent = meta.parent.clone();
let old_parent_head = meta.parent_head.clone();
Expand Down
Loading