1- using System . ComponentModel . DataAnnotations ;
1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . ComponentModel . DataAnnotations ;
24using System . Threading . Tasks ;
35
46namespace SourceGit . ViewModels
@@ -11,12 +13,18 @@ public Models.GitFlowBranchType Type
1113 private set ;
1214 }
1315
14- public string StartPoint
16+ public List < Models . Branch > LocalBranches
1517 {
1618 get ;
1719 private set ;
1820 }
1921
22+ public Models . Branch StartPoint
23+ {
24+ get => _startPoint ;
25+ set => SetProperty ( ref _startPoint , value ) ;
26+ }
27+
2028 public string Prefix
2129 {
2230 get ;
@@ -38,11 +46,21 @@ public GitFlowStart(Repository repo, Models.GitFlowBranchType type)
3846
3947 Type = type ;
4048 Prefix = _repo . GitFlow . GetPrefix ( type ) ;
41- StartPoint = type switch
49+ LocalBranches = new List < Models . Branch > ( ) ;
50+
51+ foreach ( var b in _repo . Branches )
52+ {
53+ if ( b . IsLocal && ! b . IsDetachedHead )
54+ LocalBranches . Add ( b ) ;
55+ }
56+
57+ var defBranch = type switch
4258 {
4359 Models . GitFlowBranchType . Hotfix => _repo . GitFlow . ProductionBranch ,
4460 _ => _repo . GitFlow . DevelopmentBranch ,
4561 } ;
62+
63+ StartPoint = LocalBranches . Find ( b => b . Name . Equals ( defBranch , StringComparison . Ordinal ) ) ;
4664 }
4765
4866 public static ValidationResult ValidateBranchName ( string name , ValidationContext ctx )
@@ -70,13 +88,14 @@ public override async Task<bool> Sure()
7088
7189 var succ = await new Commands . GitFlow ( _repo . FullPath )
7290 . Use ( log )
73- . StartAsync ( Type , _name ) ;
91+ . StartAsync ( Type , _name , _startPoint ) ;
7492
7593 log . Complete ( ) ;
7694 return succ ;
7795 }
7896
7997 private readonly Repository _repo ;
8098 private string _name = null ;
99+ private Models . Branch _startPoint = null ;
81100 }
82101}
0 commit comments