@@ -122,7 +122,8 @@ func (branch Branch) hasRemoteBranch(configuration config.Configuration) bool {
122122 return false
123123}
124124
125- func (branch Branch ) hasLocalBranch (localBranches []string ) bool {
125+ func (branch Branch ) hasLocalBranch () bool {
126+ localBranches := gitBranches ()
126127 say .Debug ("Local Branches: " + strings .Join (localBranches , "\n " ))
127128 say .Debug ("Local Branch: " + branch .Name )
128129
@@ -529,7 +530,7 @@ func deleteRemoteWipBranch(configuration config.Configuration) {
529530 currentBaseBranch , currentWipBranch := determineBranches (gitCurrentBranch (), gitBranches (), configuration )
530531
531532 git ("checkout" , currentBaseBranch .String ())
532- if hasLocalBranch ( currentWipBranch .String () ) {
533+ if currentWipBranch .hasLocalBranch ( ) {
533534 git ("branch" , "--delete" , "--force" , currentWipBranch .String ())
534535 }
535536 if currentWipBranch .hasRemoteBranch (configuration ) {
@@ -550,8 +551,7 @@ func start(configuration config.Configuration) error {
550551
551552 git ("fetch" , configuration .RemoteName , "--prune" )
552553 currentBranch := gitCurrentBranch ()
553- localBranches := gitBranches ()
554- currentBaseBranch , currentWipBranch := determineBranches (currentBranch , localBranches , configuration )
554+ currentBaseBranch , currentWipBranch := determineBranches (currentBranch , gitBranches (), configuration )
555555
556556 if ! currentWipBranch .hasRemoteBranch (configuration ) && configuration .StartJoin {
557557 say .Error ("Remote wip branch " + currentWipBranch .remote (configuration ).String () + " is missing" )
@@ -566,7 +566,7 @@ func start(configuration config.Configuration) error {
566566
567567 createRemoteBranch (configuration , currentBaseBranch )
568568
569- if currentBaseBranch .hasLocalBranch (localBranches ) && currentBaseBranch .hasUnpushedCommits (configuration ) {
569+ if currentBaseBranch .hasLocalBranch () && currentBaseBranch .hasUnpushedCommits (configuration ) {
570570 say .Error ("cannot start; unpushed changes on base branch must be pushed upstream" )
571571 say .Fix ("to fix this, push those commits and try again" , "git push " + configuration .RemoteName + " " + currentBaseBranch .String ())
572572 return errors .New ("cannot start; unpushed changes on base branch must be pushed upstream" )
@@ -766,7 +766,7 @@ func startJoinMobSession(configuration config.Configuration) {
766766 baseBranch , currentWipBranch := determineBranches (gitCurrentBranch (), gitBranches (), configuration )
767767
768768 say .Info ("joining existing session from " + currentWipBranch .remote (configuration ).String ())
769- if hasLocalBranch ( currentWipBranch .Name ) && doBranchesDiverge (baseBranch .remote (configuration ).Name , currentWipBranch .Name ) {
769+ if currentWipBranch .hasLocalBranch ( ) && doBranchesDiverge (baseBranch .remote (configuration ).Name , currentWipBranch .Name ) {
770770 say .Warning ("Careful, your wip branch (" + currentWipBranch .Name + ") diverges from your main branch (" + baseBranch .remote (configuration ).Name + ") !" )
771771 }
772772
@@ -1057,20 +1057,6 @@ func isMobProgramming(configuration config.Configuration) bool {
10571057 return currentWipBranch == currentBranch
10581058}
10591059
1060- func hasLocalBranch (localBranch string ) bool {
1061- localBranches := gitBranches ()
1062- say .Debug ("Local Branches: " + strings .Join (localBranches , "\n " ))
1063- say .Debug ("Local Branch: " + localBranch )
1064-
1065- for i := 0 ; i < len (localBranches ); i ++ {
1066- if localBranches [i ] == localBranch {
1067- return true
1068- }
1069- }
1070-
1071- return false
1072- }
1073-
10741060func gitBranches () []string {
10751061 return strings .Split (silentgit ("branch" , "--format=%(refname:short)" ), "\n " )
10761062}
0 commit comments