added public helper methods for project versions
parent
99f38e21bd
commit
b2f65f2ffc
|
|
@ -33,15 +33,7 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string pyprojectPath = Path.Combine(
|
string installedVersion = GetInstalledVersion();
|
||||||
saveLocation,
|
|
||||||
ServerFolder,
|
|
||||||
"src",
|
|
||||||
"pyproject.toml"
|
|
||||||
);
|
|
||||||
string installedVersion = ParseVersionFromPyproject(
|
|
||||||
File.ReadAllText(pyprojectPath)
|
|
||||||
);
|
|
||||||
string latestVersion = GetLatestVersion();
|
string latestVersion = GetLatestVersion();
|
||||||
|
|
||||||
if (IsNewerVersion(latestVersion, installedVersion))
|
if (IsNewerVersion(latestVersion, installedVersion))
|
||||||
|
|
@ -148,10 +140,24 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
RunCommand("git", $"checkout {BranchName}", workingDirectory: location);
|
RunCommand("git", $"checkout {BranchName}", workingDirectory: location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fetches the currently installed version from the local pyproject.toml file.
|
||||||
|
/// </summary>
|
||||||
|
public static string GetInstalledVersion()
|
||||||
|
{
|
||||||
|
string pyprojectPath = Path.Combine(
|
||||||
|
GetSaveLocation(),
|
||||||
|
ServerFolder,
|
||||||
|
"src",
|
||||||
|
"pyproject.toml"
|
||||||
|
);
|
||||||
|
return ParseVersionFromPyproject(File.ReadAllText(pyprojectPath));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches the latest version from the GitHub pyproject.toml file.
|
/// Fetches the latest version from the GitHub pyproject.toml file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static string GetLatestVersion()
|
public static string GetLatestVersion()
|
||||||
{
|
{
|
||||||
using WebClient webClient = new();
|
using WebClient webClient = new();
|
||||||
string pyprojectContent = webClient.DownloadString(PyprojectUrl);
|
string pyprojectContent = webClient.DownloadString(PyprojectUrl);
|
||||||
|
|
@ -188,7 +194,7 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compares two version strings to determine if the latest is newer.
|
/// Compares two version strings to determine if the latest is newer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static bool IsNewerVersion(string latest, string installed)
|
public static bool IsNewerVersion(string latest, string installed)
|
||||||
{
|
{
|
||||||
int[] latestParts = latest.Split('.').Select(int.Parse).ToArray();
|
int[] latestParts = latest.Split('.').Select(int.Parse).ToArray();
|
||||||
int[] installedParts = installed.Split('.').Select(int.Parse).ToArray();
|
int[] installedParts = installed.Split('.').Select(int.Parse).ToArray();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue