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

Commit c5f2707

Browse files
fixing plastic branch parsing #185
1 parent 1420ae8 commit c5f2707

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

‎UnityLauncherPro/GetProjects.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
120120
return projectsFound;
121121
} // Scan()
122122

123-
static Project GetProjectInfo(string projectPath, bool getGitBranch = false, bool getPlasticBranch = false, bool getArguments = false, bool showMissingFolders = false, bool showTargetPlatform = false, bool searchGitbranchRecursivly = false, bool showSRP = false)
123+
static Project GetProjectInfo(string projectPath, bool getGitBranch = false, bool getPlasticBranch = false, bool getArguments = false, bool showMissingFolders = false, bool showTargetPlatform = false, bool searchGitbranchRecursively = false, bool showSRP = false)
124124
{
125125
bool folderExists = Directory.Exists(projectPath);
126126

@@ -165,7 +165,8 @@ static Project GetProjectInfo(string projectPath, bool getGitBranch = false, boo
165165
string gitBranch = "";
166166
if (getGitBranch == true)
167167
{
168-
gitBranch = folderExists ? Tools.ReadGitBranchInfo(projectPath, searchGitbranchRecursivly) : null;
168+
gitBranch = folderExists ? Tools.ReadGitBranchInfo(projectPath, searchGitbranchRecursively) : null;
169+
169170
// check for plastic, if enabled
170171
if (getPlasticBranch == true && gitBranch == null)
171172
{

‎UnityLauncherPro/Tools.cs‎

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
stringbranchFile = Path.Combine(dirName,"plastic.selector");
1454-
if(File.Exists(branchFile))
1450+
string[]lines = File.ReadAllLines(plasticSelectorPath);
1451+
foreach(stringlineinlines)
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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /