Skip to content

Commit fb251ec

Browse files
committed
add branch set-base as a way to go back to the integration branch
1 parent 93a117e commit fb251ec

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

crates/gitbutler-cli/src/args.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ pub mod vbranch {
5151
ListLocal,
5252
/// Provide the current state of all applied virtual branches.
5353
Status,
54+
/// Switch to the GitButler workspace.
55+
SetBase {
56+
/// The name of the remote branch to integrate with, like `origin/main`.
57+
short_tracking_branch_name: String,
58+
},
5459
/// Make the named branch the default so all worktree or index changes are associated with it automatically.
5560
SetDefault {
5661
/// The name of the new default virtual branch.

crates/gitbutler-cli/src/command/vbranch.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ use gitbutler_stack::{Stack, VirtualBranchesHandle};
77

88
use crate::command::debug_print;
99

10+
pub fn set_base(project: Project, short_tracking_branch_name: String) -> Result<()> {
11+
let branch_name = format!("refs/remotes/{}", short_tracking_branch_name)
12+
.parse()
13+
.context("Invalid branch name")?;
14+
debug_print(gitbutler_branch_actions::set_base_branch(
15+
&project,
16+
&branch_name,
17+
)?)
18+
}
19+
1020
pub fn list_all(project: Project) -> Result<()> {
1121
let ctx = CommandContext::open(&project)?;
1222
debug_print(list_branches(&ctx, None, None)?)

crates/gitbutler-cli/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ fn main() -> Result<()> {
2828
args::Subcommands::Branch(vbranch::Platform { cmd }) => {
2929
let project = command::prepare::project_from_path(args.current_dir)?;
3030
match cmd {
31+
Some(vbranch::SubCommands::SetBase {
32+
short_tracking_branch_name,
33+
}) => command::vbranch::set_base(project, short_tracking_branch_name),
3134
Some(vbranch::SubCommands::ListLocal) => command::vbranch::list_local(project),
3235
Some(vbranch::SubCommands::Status) => command::vbranch::status(project),
3336
Some(vbranch::SubCommands::Unapply { name }) => {

0 commit comments

Comments
 (0)