Skip to content

Commit c01fc72

Browse files
committed
refactor
- fmt - test
1 parent 4b346ac commit c01fc72

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

crates/but/src/branch/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@ pub enum Subcommands {
4848
},
4949
}
5050

51-
pub async fn handle(cmd: &Option<Subcommands>, project: &Project, _json: bool) -> anyhow::Result<()> {
51+
pub async fn handle(
52+
cmd: &Option<Subcommands>,
53+
project: &Project,
54+
_json: bool,
55+
) -> anyhow::Result<()> {
5256
match cmd {
5357
None => {
54-
// Default to list when no subcommand is provided
55-
list::list(project, false).await
58+
let local = false;
59+
list::list(project, local).await
5660
}
61+
Some(Subcommands::List { local }) => list::list(project, *local).await,
5762
Some(Subcommands::New {
5863
branch_name,
5964
anchor,
@@ -145,7 +150,6 @@ pub async fn handle(cmd: &Option<Subcommands>, project: &Project, _json: bool) -
145150
println!("Branch '{}' not found in any stack", branch_name);
146151
Ok(())
147152
}
148-
Some(Subcommands::List { local }) => list::list(project, *local).await,
149153
Some(Subcommands::Unapply { branch_name, force }) => {
150154
let stacks = but_api::workspace::stacks(
151155
project.id,

crates/but/tests/but/journey.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ fn from_workspace() -> anyhow::Result<()> {
118118
"snapshots/from-workspace/status01-verbose.stdout.term.svg"
119119
]);
120120

121+
// List is the default
122+
env.but("branch")
123+
.assert()
124+
.success()
125+
.stdout_eq(file!["snapshots/from-workspace/branch01.stdout.term.svg"]);
126+
127+
// But list is also explicit.
128+
env.but("branch list")
129+
.assert()
130+
.success()
131+
.stdout_eq(file!["snapshots/from-workspace/branch01.stdout.term.svg"]);
132+
121133
// TODO: more operations on the repository!
122134
Ok(())
123135
}
Lines changed: 28 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)