fix: when upstream is null show CommitAndPush and stop auto push (#955) (#956)

This commit is contained in:
GadflyFang 2025-02-07 11:30:14 +08:00 committed by GitHub
parent d1f3469250
commit 2105fd450d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 14 additions and 13 deletions

View file

@ -59,15 +59,17 @@ namespace SourceGit.ViewModels
public void StartPopup(Popup popup) public void StartPopup(Popup popup)
{ {
Popup = popup; Popup = popup;
ProcessPopup(); ProcessPopup(true);
} }
public async void ProcessPopup() public async void ProcessPopup(bool autoCheck = false)
{ {
if (_popup != null) if (_popup != null)
{ {
if (!_popup.Check()) if (!_popup.Check())
return; return;
if (autoCheck && !_popup.AutoCheck())
return;
_popup.InProgress = true; _popup.InProgress = true;
var task = _popup.Sure(); var task = _popup.Sure();

View file

@ -37,6 +37,11 @@ namespace SourceGit.ViewModels
return !HasErrors; return !HasErrors;
} }
public virtual bool AutoCheck()
{
return true;
}
public virtual Task<bool> Sure() public virtual Task<bool> Sure()
{ {
return null; return null;

View file

@ -152,6 +152,11 @@ namespace SourceGit.ViewModels
View = new Views.Push() { DataContext = this }; View = new Views.Push() { DataContext = this };
} }
public override bool AutoCheck()
{
return !string.IsNullOrEmpty(_selectedRemoteBranch?.Head);
}
public override Task<bool> Sure() public override Task<bool> Sure()
{ {
_repo.SetWatcherEnabled(false); _repo.SetWatcherEnabled(false);

View file

@ -937,9 +937,6 @@ namespace SourceGit.ViewModels
CurrentBranch = branches.Find(x => x.IsCurrent); CurrentBranch = branches.Find(x => x.IsCurrent);
LocalBranchTrees = builder.Locals; LocalBranchTrees = builder.Locals;
RemoteBranchTrees = builder.Remotes; RemoteBranchTrees = builder.Remotes;
if (_workingCopy != null)
_workingCopy.CanCommitWithPush = _currentBranch != null && !string.IsNullOrEmpty(_currentBranch.Upstream);
}); });
} }

View file

@ -26,12 +26,6 @@ namespace SourceGit.ViewModels
} }
} }
public bool CanCommitWithPush
{
get => _canCommitWithPush;
set => SetProperty(ref _canCommitWithPush, value);
}
public bool HasUnsolvedConflicts public bool HasUnsolvedConflicts
{ {
get => _hasUnsolvedConflicts; get => _hasUnsolvedConflicts;
@ -1625,7 +1619,6 @@ namespace SourceGit.ViewModels
private bool _isUnstaging = false; private bool _isUnstaging = false;
private bool _isCommitting = false; private bool _isCommitting = false;
private bool _useAmend = false; private bool _useAmend = false;
private bool _canCommitWithPush = false;
private List<Models.Change> _cached = []; private List<Models.Change> _cached = [];
private List<Models.Change> _unstaged = []; private List<Models.Change> _unstaged = [];
private List<Models.Change> _staged = []; private List<Models.Change> _staged = [];

View file

@ -375,7 +375,6 @@
<Button.IsVisible> <Button.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}"> <MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="UseAmend" Converter="{x:Static BoolConverters.Not}"/> <Binding Path="UseAmend" Converter="{x:Static BoolConverters.Not}"/>
<Binding Path="CanCommitWithPush"/>
<Binding Path="InProgressContext" Converter="{x:Static ObjectConverters.IsNull}"/> <Binding Path="InProgressContext" Converter="{x:Static ObjectConverters.IsNull}"/>
</MultiBinding> </MultiBinding>
</Button.IsVisible> </Button.IsVisible>