1
- using System . Threading . Tasks ;
1
+ using System ;
2
+ using System . Threading . Tasks ;
2
3
3
4
namespace SourceGit . ViewModels
4
5
{
@@ -7,13 +8,11 @@ public class Merge : Popup
7
8
public string Source
8
9
{
9
10
get ;
10
- private set ;
11
11
}
12
12
13
13
public string Into
14
14
{
15
15
get ;
16
- private set ;
17
16
}
18
17
19
18
public Models . MergeMode SelectedMode
@@ -27,7 +26,7 @@ public Merge(Repository repo, string source, string into)
27
26
_repo = repo ;
28
27
Source = source ;
29
28
Into = into ;
30
- SelectedMode = Models . MergeMode . Supported [ 0 ] ;
29
+ SelectedMode = AutoSelectMergeMode ( ) ;
31
30
View = new Views . Merge ( ) { DataContext = this } ;
32
31
}
33
32
@@ -44,6 +43,21 @@ public override Task<bool> Sure()
44
43
} ) ;
45
44
}
46
45
46
+ private Models . MergeMode AutoSelectMergeMode ( )
47
+ {
48
+ var config = new Commands . Config ( _repo . FullPath ) . Get ( $ "branch.{ Into } .mergeoptions") ;
49
+ if ( string . IsNullOrEmpty ( config ) )
50
+ return Models . MergeMode . Supported [ 0 ] ;
51
+ if ( config . Equals ( "--no-ff" , StringComparison . Ordinal ) )
52
+ return Models . MergeMode . Supported [ 1 ] ;
53
+ if ( config . Equals ( "--squash" , StringComparison . Ordinal ) )
54
+ return Models . MergeMode . Supported [ 2 ] ;
55
+ if ( config . Equals ( "--no-commit" , StringComparison . Ordinal ) || config . Equals ( "--no-ff --no-commit" , StringComparison . Ordinal ) )
56
+ return Models . MergeMode . Supported [ 3 ] ;
57
+
58
+ return Models . MergeMode . Supported [ 0 ] ;
59
+ }
60
+
47
61
private readonly Repository _repo = null ;
48
62
}
49
63
}
0 commit comments