fix: for init-commit, app will crash with COMMIT & PUSH due to local branch has not been updated (#1229)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-04-22 18:45:14 +08:00
parent f2000b4a84
commit 87ebe3741d
No known key found for this signature in database
2 changed files with 15 additions and 1 deletions

View file

@ -114,6 +114,9 @@ namespace SourceGit.ViewModels
// Set default selected local branch.
if (localBranch != null)
{
if (LocalBranches.Count == 0)
LocalBranches.Add(localBranch);
_selectedLocalBranch = localBranch;
HasSpecifiedLocalBranch = true;
}

View file

@ -1733,7 +1733,18 @@ namespace SourceGit.ViewModels
UseAmend = false;
if (autoPush && _repo.Remotes.Count > 0)
_repo.ShowAndStartPopup(new Push(_repo, null));
{
if (_repo.CurrentBranch == null)
{
var currentBranchName = Commands.Branch.ShowCurrent(_repo.FullPath);
var tmp = new Models.Branch() { Name = currentBranchName };
_repo.ShowAndStartPopup(new Push(_repo, tmp));
}
else
{
_repo.ShowAndStartPopup(new Push(_repo, null));
}
}
}
_repo.MarkBranchesDirtyManually();