Skip to content

Commit fbf6a64

Browse files
committed
refactor: only auto-track remote branch after creating new local branch when the created branch's name is the same with based remote branch (#1926)
Signed-off-by: leo <[email protected]>
1 parent f736f3b commit fbf6a64

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/ViewModels/CreateBranch.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,20 +186,9 @@ public override async Task<bool> Sure()
186186
.CreateAsync(_baseOnRevision, _allowOverwrite);
187187
}
188188

189-
if (succ && BasedOn is Models.Branch { IsLocal: false } basedOn)
189+
if (succ && BasedOn is Models.Branch { IsLocal: false } basedOn && _name.Equals(basedOn.Name, StringComparison.Ordinal))
190190
{
191-
var autoSetUpstream = true;
192-
foreach (var b in _repo.Branches)
193-
{
194-
if (b.IsLocal && b.Upstream.Equals(basedOn.FullName, StringComparison.Ordinal))
195-
{
196-
autoSetUpstream = false;
197-
break;
198-
}
199-
}
200-
201-
if (autoSetUpstream)
202-
await new Commands.Branch(_repo.FullPath, _name)
191+
await new Commands.Branch(_repo.FullPath, _name)
203192
.Use(log)
204193
.SetUpstreamAsync(basedOn);
205194
}

0 commit comments

Comments
 (0)