Skip to content

Commit 2105fd4

Browse files
authored
fix: when upstream is null show CommitAndPush and stop auto push (#955) (#956)
1 parent d1f3469 commit 2105fd4

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

src/ViewModels/LauncherPage.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,17 @@ public bool CanCreatePopup()
5959
public void StartPopup(Popup popup)
6060
{
6161
Popup = popup;
62-
ProcessPopup();
62+
ProcessPopup(true);
6363
}
6464

65-
public async void ProcessPopup()
65+
public async void ProcessPopup(bool autoCheck = false)
6666
{
6767
if (_popup != null)
6868
{
6969
if (!_popup.Check())
7070
return;
71+
if (autoCheck && !_popup.AutoCheck())
72+
return;
7173

7274
_popup.InProgress = true;
7375
var task = _popup.Sure();

src/ViewModels/Popup.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public bool Check()
3737
return !HasErrors;
3838
}
3939

40+
public virtual bool AutoCheck()
41+
{
42+
return true;
43+
}
44+
4045
public virtual Task<bool> Sure()
4146
{
4247
return null;

src/ViewModels/Push.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ public Push(Repository repo, Models.Branch localBranch)
152152
View = new Views.Push() { DataContext = this };
153153
}
154154

155+
public override bool AutoCheck()
156+
{
157+
return !string.IsNullOrEmpty(_selectedRemoteBranch?.Head);
158+
}
159+
155160
public override Task<bool> Sure()
156161
{
157162
_repo.SetWatcherEnabled(false);

src/ViewModels/Repository.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -937,9 +937,6 @@ public void RefreshBranches()
937937
CurrentBranch = branches.Find(x => x.IsCurrent);
938938
LocalBranchTrees = builder.Locals;
939939
RemoteBranchTrees = builder.Remotes;
940-
941-
if (_workingCopy != null)
942-
_workingCopy.CanCommitWithPush = _currentBranch != null && !string.IsNullOrEmpty(_currentBranch.Upstream);
943940
});
944941
}
945942

src/ViewModels/WorkingCopy.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ public bool IncludeUntracked
2626
}
2727
}
2828

29-
public bool CanCommitWithPush
30-
{
31-
get => _canCommitWithPush;
32-
set => SetProperty(ref _canCommitWithPush, value);
33-
}
34-
3529
public bool HasUnsolvedConflicts
3630
{
3731
get => _hasUnsolvedConflicts;
@@ -1625,7 +1619,6 @@ private bool IsChanged(List<Models.Change> old, List<Models.Change> cur)
16251619
private bool _isUnstaging = false;
16261620
private bool _isCommitting = false;
16271621
private bool _useAmend = false;
1628-
private bool _canCommitWithPush = false;
16291622
private List<Models.Change> _cached = [];
16301623
private List<Models.Change> _unstaged = [];
16311624
private List<Models.Change> _staged = [];

src/Views/WorkingCopy.axaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@
375375
<Button.IsVisible>
376376
<MultiBinding Converter="{x:Static BoolConverters.And}">
377377
<Binding Path="UseAmend" Converter="{x:Static BoolConverters.Not}"/>
378-
<Binding Path="CanCommitWithPush"/>
379378
<Binding Path="InProgressContext" Converter="{x:Static ObjectConverters.IsNull}"/>
380379
</MultiBinding>
381380
</Button.IsVisible>

0 commit comments

Comments
 (0)