Skip to content

Commit 87ebe37

Browse files
committed
fix: for init-commit, app will crash with COMMIT & PUSH due to local branch has not been updated (#1229)
Signed-off-by: leo <[email protected]>
1 parent f2000b4 commit 87ebe37

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/ViewModels/Push.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ public Push(Repository repo, Models.Branch localBranch)
114114
// Set default selected local branch.
115115
if (localBranch != null)
116116
{
117+
if (LocalBranches.Count == 0)
118+
LocalBranches.Add(localBranch);
119+
117120
_selectedLocalBranch = localBranch;
118121
HasSpecifiedLocalBranch = true;
119122
}

src/ViewModels/WorkingCopy.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,18 @@ private void DoCommit(bool autoStage, bool autoPush, bool allowEmpty = false, bo
17331733
UseAmend = false;
17341734

17351735
if (autoPush && _repo.Remotes.Count > 0)
1736-
_repo.ShowAndStartPopup(new Push(_repo, null));
1736+
{
1737+
if (_repo.CurrentBranch == null)
1738+
{
1739+
var currentBranchName = Commands.Branch.ShowCurrent(_repo.FullPath);
1740+
var tmp = new Models.Branch() { Name = currentBranchName };
1741+
_repo.ShowAndStartPopup(new Push(_repo, tmp));
1742+
}
1743+
else
1744+
{
1745+
_repo.ShowAndStartPopup(new Push(_repo, null));
1746+
}
1747+
}
17371748
}
17381749

17391750
_repo.MarkBranchesDirtyManually();

0 commit comments

Comments
 (0)