@@ -1424,12 +1424,9 @@ public static string ReadGitBranchInfo(string projectPath, bool searchParentFold
14241424 {
14251425 string dirName = Path . Combine ( projectPath , ".git" ) ;
14261426 if ( Directory . Exists ( dirName ) )
1427-
1428-
14291427 {
14301428 string branchFile = Path . Combine ( dirName , "HEAD" ) ;
14311429 if ( File . Exists ( branchFile ) )
1432-
14331430 {
14341431 // removes extra end of line
14351432 results = string . Join ( " " , File . ReadAllLines ( branchFile ) ) ;
@@ -1438,30 +1435,40 @@ public static string ReadGitBranchInfo(string projectPath, bool searchParentFold
14381435 results = results . Substring ( pos , results . Length - pos ) ;
14391436
14401437 }
1441-
14421438 }
14431439 }
14441440 return results ;
14451441 }
14461442
14471443 public static string ReadPlasticBranchInfo ( string projectPath )
14481444 {
1449- string results = null ;
1450- string dirName = Path . Combine ( projectPath , ".plastic" ) ;
1451- if ( Directory . Exists ( dirName ) )
1445+ string branchName = null ;
1446+ string plasticSelectorPath = Path . Combine ( projectPath , ".plastic" , "plastic.selector" ) ;
1447+
1448+ if ( File . Exists ( plasticSelectorPath ) )
14521449 {
1453- string branchFile = Path . Combine ( dirName , "plastic.selector" ) ;
1454- if ( File . Exists ( branchFile ) )
1450+ string [ ] lines = File . ReadAllLines ( plasticSelectorPath ) ;
1451+ foreach ( string line in lines )
14551452 {
1456- // removes extra end of line
1457- results = string . Join ( " " , File . ReadAllText ( branchFile ) ) ;
1458- // get branch only
1459- int pos = results . LastIndexOf ( "\" /" ) + 1 ;
1460- // -1 to remove last "
1461- results = results . Substring ( pos , results . Length - pos - 1 ) ;
1453+ string trimmedLine = line . Trim ( ) ;
1454+ if ( trimmedLine . StartsWith ( "br " ) || trimmedLine . StartsWith ( "smartbranch " ) )
1455+ {
1456+ // Extract the branch name between quotes
1457+ var match = Regex . Match ( trimmedLine , "\" ([^\" ]+)\" " ) ;
1458+ if ( match . Success )
1459+ {
1460+ branchName = match . Groups [ 1 ] . Value ;
1461+ // Remove the leading slash if present
1462+ if ( branchName . StartsWith ( "/" ) )
1463+ {
1464+ branchName = branchName . Substring ( 1 ) ;
1465+ }
1466+ break ;
1467+ }
1468+ }
14621469 }
14631470 }
1464- return results ;
1471+ return branchName ;
14651472 }
14661473
14671474 //public static Platform GetTargetPlatform(string projectPath)
0 commit comments