Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd1cae3b

Browse files
committed
add searchparentfolder support for plastic branch searchfixes#185
1 parentc5f2707 commitd1cae3b

File tree

2 files changed

+54
-53
lines changed

2 files changed

+54
-53
lines changed

‎UnityLauncherPro/GetProjects.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static Project GetProjectInfo(string projectPath, bool getGitBranch = false, boo
170170
// check for plastic, if enabled
171171
if(getPlasticBranch==true&&gitBranch==null)
172172
{
173-
gitBranch=folderExists?Tools.ReadPlasticBranchInfo(projectPath):null;
173+
gitBranch=folderExists?Tools.ReadPlasticBranchInfo(projectPath,searchGitbranchRecursively):null;
174174
}
175175
}
176176

‎UnityLauncherPro/Tools.cs‎

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,83 +1394,84 @@ public static void RemoveContextMenuRegistryAPKInstall(string contextRegRoot)
13941394
/// <returns></returns>
13951395
publicstaticstringReadGitBranchInfo(stringprojectPath,boolsearchParentFolders)
13961396
{
1397-
stringresults=null;
1398-
1399-
if(searchParentFolders)
1397+
DirectoryInfodirectoryInfo=newDirectoryInfo(projectPath);
1398+
while(directoryInfo!=null)
14001399
{
1401-
DirectoryInfodirectoryInfo=newDirectoryInfo(projectPath);
1400+
stringgitDir=Path.Combine(directoryInfo.FullName,".git");
1401+
stringheadFile=Path.Combine(gitDir,"HEAD");
14021402

1403-
while(directoryInfo!=null)
1403+
if(Directory.Exists(gitDir)&&File.Exists(headFile))
14041404
{
1405-
stringdirName=Path.Combine(directoryInfo.FullName,".git");
1405+
stringheadContent=File.ReadAllText(headFile).Trim();
1406+
intpos=headContent.LastIndexOf('/')+1;
1407+
return(pos<headContent.Length)?headContent.Substring(pos):headContent;
1408+
}
14061409

1407-
if(Directory.Exists(dirName))
1408-
{
1409-
stringbranchFile=Path.Combine(dirName,"HEAD");
1410-
if(File.Exists(branchFile))
1411-
{
1412-
// removes extra end of line
1413-
results=string.Join(" ",File.ReadAllLines(branchFile));
1414-
// get branch only
1415-
intpos=results.LastIndexOf("/")+1;
1416-
results=results.Substring(pos,results.Length-pos);
1417-
returnresults;
1418-
}
1419-
}
1420-
directoryInfo=directoryInfo.Parent;
1410+
if(!searchParentFolders)
1411+
{
1412+
break;
14211413
}
1414+
directoryInfo=directoryInfo.Parent;
14221415
}
1423-
else
1416+
1417+
returnnull;
1418+
}
1419+
1420+
1421+
publicstaticstringReadPlasticBranchInfo(stringprojectPath,boolsearchParentFolders)
1422+
{
1423+
stringbranchName=null;
1424+
DirectoryInfodirectoryInfo=newDirectoryInfo(projectPath);
1425+
1426+
while(directoryInfo!=null)
14241427
{
1425-
stringdirName=Path.Combine(projectPath,".git");
1426-
if(Directory.Exists(dirName))
1428+
stringplasticSelectorPath=Path.Combine(directoryInfo.FullName,".plastic","plastic.selector");
1429+
if(File.Exists(plasticSelectorPath))
14271430
{
1428-
stringbranchFile=Path.Combine(dirName,"HEAD");
1429-
if(File.Exists(branchFile))
1431+
branchName=ExtractPlasticBranch(plasticSelectorPath);
1432+
if(!string.IsNullOrEmpty(branchName))
14301433
{
1431-
// removes extra end of line
1432-
results=string.Join(" ",File.ReadAllLines(branchFile));
1433-
// get branch only
1434-
intpos=results.LastIndexOf("/")+1;
1435-
results=results.Substring(pos,results.Length-pos);
1436-
1434+
returnbranchName;
14371435
}
14381436
}
1437+
1438+
if(!searchParentFolders)
1439+
{
1440+
break;
1441+
}
1442+
1443+
directoryInfo=directoryInfo.Parent;
14391444
}
1440-
returnresults;
1445+
1446+
returnbranchName;
14411447
}
14421448

1443-
publicstaticstringReadPlasticBranchInfo(stringprojectPath)
1449+
privatestaticstringExtractPlasticBranch(stringplasticSelectorPath)
14441450
{
1445-
stringbranchName=null;
1446-
stringplasticSelectorPath=Path.Combine(projectPath,".plastic","plastic.selector");
1447-
1448-
if(File.Exists(plasticSelectorPath))
1451+
string[]lines=File.ReadAllLines(plasticSelectorPath);
1452+
foreach(stringlineinlines)
14491453
{
1450-
string[]lines=File.ReadAllLines(plasticSelectorPath);
1451-
foreach(stringlineinlines)
1454+
stringtrimmedLine=line.Trim();
1455+
if(trimmedLine.StartsWith("br ")||trimmedLine.StartsWith("smartbranch "))
14521456
{
1453-
stringtrimmedLine=line.Trim();
1454-
if(trimmedLine.StartsWith("br ")||trimmedLine.StartsWith("smartbranch "))
1457+
// Extract the first quoted string
1458+
varmatch=Regex.Match(trimmedLine,"\"([^\"]+)\"");
1459+
if(match.Success)
14551460
{
1456-
// Extract the branch name between quotes
1457-
varmatch=Regex.Match(trimmedLine,"\"([^\"]+)\"");
1458-
if(match.Success)
1461+
stringbranchName=match.Groups[1].Value;
1462+
// Remove leading slash if present (e.g., "/main" becomes "main")
1463+
if(branchName.StartsWith("/"))
14591464
{
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;
1465+
branchName=branchName.Substring(1);
14671466
}
1467+
returnbranchName;
14681468
}
14691469
}
14701470
}
1471-
returnbranchName;
1471+
returnnull;
14721472
}
14731473

1474+
14741475
//public static Platform GetTargetPlatform(string projectPath)
14751476
staticstringGetTargetPlatformRaw(stringprojectPath)
14761477
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp