1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . IO ;
4
- using System . Linq ;
5
4
using System . Threading . Tasks ;
6
5
7
6
using Avalonia . Controls ;
@@ -1796,6 +1795,21 @@ public ContextMenu CreateContextForOpenAI()
1796
1795
return visible ;
1797
1796
}
1798
1797
1798
+ private List < Models . Change > GetCanStagedChanges ( List < Models . Change > changes )
1799
+ {
1800
+ if ( ! HasUnsolvedConflicts )
1801
+ return changes ;
1802
+
1803
+ var outs = new List < Models . Change > ( ) ;
1804
+ foreach ( var c in changes )
1805
+ {
1806
+ if ( ! c . IsConflicted )
1807
+ outs . Add ( c ) ;
1808
+ }
1809
+
1810
+ return outs ;
1811
+ }
1812
+
1799
1813
private List < Models . Change > GetStagedChanges ( )
1800
1814
{
1801
1815
if ( _useAmend )
@@ -1871,18 +1885,13 @@ private void UpdateInProgressState()
1871
1885
1872
1886
private async void StageChanges ( List < Models . Change > changes , Models . Change next )
1873
1887
{
1874
- var nonConflictChanges = HasUnsolvedConflicts
1875
- ? changes . Where ( c => ! c . IsConflicted ) . ToList ( )
1876
- : changes ;
1877
-
1878
- var count = nonConflictChanges . Count ;
1888
+ var canStaged = GetCanStagedChanges ( changes ) ;
1889
+ var count = canStaged . Count ;
1879
1890
if ( count == 0 )
1880
1891
return ;
1881
1892
1882
- // Use `_selectedUnstaged` instead of `SelectedUnstaged` to avoid UI refresh.
1883
- _selectedUnstaged = next != null ? [ next ] : [ ] ;
1884
-
1885
1893
IsStaging = true ;
1894
+ _selectedUnstaged = next != null ? [ next ] : [ ] ;
1886
1895
_repo . SetWatcherEnabled ( false ) ;
1887
1896
1888
1897
var log = _repo . CreateLog ( "Stage" ) ;
@@ -1895,7 +1904,7 @@ private async void StageChanges(List<Models.Change> changes, Models.Change next)
1895
1904
var pathSpecFile = Path . GetTempFileName ( ) ;
1896
1905
await using ( var writer = new StreamWriter ( pathSpecFile ) )
1897
1906
{
1898
- foreach ( var c in nonConflictChanges )
1907
+ foreach ( var c in canStaged )
1899
1908
await writer . WriteLineAsync ( c . Path ) ;
1900
1909
}
1901
1910
@@ -1915,10 +1924,8 @@ private async void UnstageChanges(List<Models.Change> changes, Models.Change nex
1915
1924
if ( count == 0 )
1916
1925
return ;
1917
1926
1918
- // Use `_selectedStaged` instead of `SelectedStaged` to avoid UI refresh.
1919
- _selectedStaged = next != null ? [ next ] : [ ] ;
1920
-
1921
1927
IsUnstaging = true ;
1928
+ _selectedStaged = next != null ? [ next ] : [ ] ;
1922
1929
_repo . SetWatcherEnabled ( false ) ;
1923
1930
1924
1931
var log = _repo . CreateLog ( "Unstage" ) ;
@@ -1974,6 +1981,12 @@ private void DoCommit(bool autoStage, bool autoPush, CommitCheckPassed checkPass
1974
1981
return ;
1975
1982
}
1976
1983
1984
+ if ( autoStage && HasUnsolvedConflicts )
1985
+ {
1986
+ App . RaiseException ( _repo . FullPath , "Repository has unsolved conflict(s). Auto-stage and commit is disabled!" ) ;
1987
+ return ;
1988
+ }
1989
+
1977
1990
if ( _repo . CurrentBranch is { IsDetachedHead : true } && checkPassed < CommitCheckPassed . DetachedHead )
1978
1991
{
1979
1992
var msg = App . Text ( "WorkingCopy.ConfirmCommitWithDetachedHead" ) ;
0 commit comments