Skip to content

Commit ac0718d

Browse files
committed
GitCheckoutOptions now has a constructor to create a new branch with the -b flag
1 parent be562d4 commit ac0718d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- GitCheckoutOptions now has a constructor to create a new branch with the `-b` flag

src/ModularPipelines.Git/Options/GitCheckoutOptions.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,24 @@ namespace ModularPipelines.Git.Options;
55

66
[CommandPrecedingArguments("checkout")]
77
[ExcludeFromCodeCoverage]
8-
public record GitCheckoutOptions([property: PositionalArgument] string BranchName) : GitOptions
8+
public record GitCheckoutOptions : GitOptions
99
{
10+
public GitCheckoutOptions(string branchName) : this(branchName, false)
11+
{
12+
}
13+
14+
public GitCheckoutOptions(string branchName, bool create)
15+
{
16+
if (create)
17+
{
18+
NewBranchName = branchName;
19+
}
20+
else
21+
{
22+
BranchName = branchName;
23+
}
24+
}
25+
1026
[BooleanCommandSwitch("--quiet")]
1127
public bool? Quiet { get; set; }
1228

@@ -81,4 +97,10 @@ public record GitCheckoutOptions([property: PositionalArgument] string BranchNam
8197

8298
[BooleanCommandSwitch("--pathspec-file-nul")]
8399
public bool? PathspecFileNul { get; set; }
100+
101+
[PositionalArgument]
102+
public string? BranchName { get; set; }
103+
104+
[CommandEqualsSeparatorSwitch("-b")]
105+
public string? NewBranchName { get; set; }
84106
}

0 commit comments

Comments
 (0)