@@ -1424,12 +1424,9 @@ public static string ReadGitBranchInfo(string projectPath, bool searchParentFold
1424
1424
{
1425
1425
string dirName = Path . Combine ( projectPath , ".git" ) ;
1426
1426
if ( Directory . Exists ( dirName ) )
1427
-
1428
-
1429
1427
{
1430
1428
string branchFile = Path . Combine ( dirName , "HEAD" ) ;
1431
1429
if ( File . Exists ( branchFile ) )
1432
-
1433
1430
{
1434
1431
// removes extra end of line
1435
1432
results = string . Join ( " " , File . ReadAllLines ( branchFile ) ) ;
@@ -1438,30 +1435,40 @@ public static string ReadGitBranchInfo(string projectPath, bool searchParentFold
1438
1435
results = results . Substring ( pos , results . Length - pos ) ;
1439
1436
1440
1437
}
1441
-
1442
1438
}
1443
1439
}
1444
1440
return results ;
1445
1441
}
1446
1442
1447
1443
public static string ReadPlasticBranchInfo ( string projectPath )
1448
1444
{
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 ) )
1452
1449
{
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 )
1455
1452
{
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
+ }
1462
1469
}
1463
1470
}
1464
- return results ;
1471
+ return branchName ;
1465
1472
}
1466
1473
1467
1474
//public static Platform GetTargetPlatform(string projectPath)
0 commit comments