Skip to content

Commit e537611

Browse files
committed
refactor
1 parent 58b5060 commit e537611

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

gitoxide-core/src/repository/branch.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,6 @@ pub enum Kind {
55
All,
66
}
77

8-
impl Kind {
9-
fn includes_local_branches(&self) -> bool {
10-
match self {
11-
Self::Local | Self::All => true,
12-
}
13-
}
14-
15-
fn includes_remote_branches(&self) -> bool {
16-
match self {
17-
Self::Local => false,
18-
Self::All => true,
19-
}
20-
}
21-
}
22-
238
pub struct Options {
249
pub kind: Kind,
2510
}
@@ -36,7 +21,12 @@ pub fn list(
3621

3722
let platform = repo.references()?;
3823

39-
if options.kind.includes_local_branches() {
24+
let (show_local, show_remotes) = match options.kind {
25+
Kind::Local => (true, false),
26+
Kind::All => (true, true),
27+
};
28+
29+
if show_local {
4030
let mut branch_names: Vec<String> = platform
4131
.local_branches()?
4232
.flatten()
@@ -50,7 +40,7 @@ pub fn list(
5040
}
5141
}
5242

53-
if options.kind.includes_remote_branches() {
43+
if show_remotes {
5444
let mut branch_names: Vec<String> = platform
5545
.remote_branches()?
5646
.flatten()

src/plumbing/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,14 @@ pub fn main() -> Result<()> {
511511
),
512512
Subcommands::Branch(platform) => match platform.cmds {
513513
Some(branch::Subcommands::List) | None => {
514-
use core::repository::branch::{Kind, Options};
514+
use core::repository::branch;
515515

516-
let kind = if platform.all { Kind::All } else { Kind::Local };
517-
let options = Options { kind };
516+
let kind = if platform.all {
517+
branch::Kind::All
518+
} else {
519+
branch::Kind::Local
520+
};
521+
let options = branch::Options { kind };
518522

519523
prepare_and_run(
520524
"branch-list",

0 commit comments

Comments
 (0)