77 lines
2.4 KiB
C#
77 lines
2.4 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Beyond
|
|
{
|
|
public class BuildVersionScriptable : ScriptableObject
|
|
{
|
|
public string version;
|
|
public string path = "/Users/marcin/projects/beYond ";
|
|
public string ProcessVersion(string v)
|
|
{
|
|
if (!String.IsNullOrEmpty(v))
|
|
{
|
|
int id = v.IndexOf(':');
|
|
if (id > 0)
|
|
{
|
|
v = v.Substring(id+1);
|
|
}
|
|
|
|
id = v.IndexOf('M');
|
|
if (id > 0)
|
|
{
|
|
v = v.Substring(0, v.IndexOf('M'));
|
|
}
|
|
}
|
|
|
|
return v;
|
|
}
|
|
[Button]
|
|
public void Update()
|
|
{
|
|
var result = ExecuteProcessTerminal("/opt/homebrew/bin/svnversion -c");
|
|
if (!String.IsNullOrEmpty(result))
|
|
{
|
|
version = ProcessVersion(result);
|
|
}
|
|
//UpdateProjectVersion();
|
|
}
|
|
|
|
private string ExecuteProcessTerminal(string argument)
|
|
{
|
|
string output = "";
|
|
try
|
|
{
|
|
UnityEngine.Debug.Log("============== Start Executing [" + argument + "] ===============");
|
|
ProcessStartInfo startInfo = new ProcessStartInfo("/bin/bash")
|
|
{
|
|
WorkingDirectory = "/Users/marcin/projects/beYond",
|
|
UseShellExecute = false,
|
|
RedirectStandardOutput = true
|
|
};
|
|
Process myProcess = new Process
|
|
{
|
|
StartInfo = startInfo
|
|
};
|
|
//myProcess.StartInfo.Arguments = argument;
|
|
//myProcess.StartInfo.Arguments = " -c \"" + argument + " \"";
|
|
myProcess.StartInfo.Arguments = " -c \"" + argument + " \"";
|
|
myProcess.Start();
|
|
output = myProcess.StandardOutput.ReadToEnd();
|
|
UnityEngine.Debug.Log("Result for [" + argument + "] is : \n" + output);
|
|
myProcess.WaitForExit();
|
|
UnityEngine.Debug.Log("============== End ===============");
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
UnityEngine.Debug.LogError(e);
|
|
}
|
|
|
|
return output;
|
|
}
|
|
|
|
}
|
|
} |