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 <longshuang@msn.cn>
This commit is contained in:
leo
2025-11-19 20:16:05 +08:00
parent f736f3bdc6
commit fbf6a646ba

View File

@@ -186,20 +186,9 @@ namespace SourceGit.ViewModels
.CreateAsync(_baseOnRevision, _allowOverwrite);
}
if (succ && BasedOn is Models.Branch { IsLocal: false } basedOn)
if (succ && BasedOn is Models.Branch { IsLocal: false } basedOn && _name.Equals(basedOn.Name, StringComparison.Ordinal))
{
var autoSetUpstream = true;
foreach (var b in _repo.Branches)
{
if (b.IsLocal && b.Upstream.Equals(basedOn.FullName, StringComparison.Ordinal))
{
autoSetUpstream = false;
break;
}
}
if (autoSetUpstream)
await new Commands.Branch(_repo.FullPath, _name)
await new Commands.Branch(_repo.FullPath, _name)
.Use(log)
.SetUpstreamAsync(basedOn);
}