【工具】热更工具添加同步GIT的功能
parent
06a1d63a1e
commit
a943681b63
|
@ -352,6 +352,10 @@ namespace GameEditor.FrameTool
|
||||||
{
|
{
|
||||||
_CurConfig.CalHotFixSize();
|
_CurConfig.CalHotFixSize();
|
||||||
}
|
}
|
||||||
|
if (GUILayout.Button("刷新", GUILayout.Height(20f)))
|
||||||
|
{
|
||||||
|
_CurConfig.CalHotFixSize();
|
||||||
|
}
|
||||||
if (GUILayout.Button("更新到GIT", GUILayout.Height(20f)))
|
if (GUILayout.Button("更新到GIT", GUILayout.Height(20f)))
|
||||||
{
|
{
|
||||||
HotfixConfimWindow.Create("是否要将工程热更文件同步到GIT: " + _CurConfig.desc, _CurConfig.project_local_list, () =>
|
HotfixConfimWindow.Create("是否要将工程热更文件同步到GIT: " + _CurConfig.desc, _CurConfig.project_local_list, () =>
|
||||||
|
@ -436,33 +440,65 @@ namespace GameEditor.FrameTool
|
||||||
string updateName;
|
string updateName;
|
||||||
List<ResourceFile> updateList;
|
List<ResourceFile> updateList;
|
||||||
List<string> log = new List<string>();
|
List<string> log = new List<string>();
|
||||||
// 初始化数据
|
|
||||||
updateName = benchName + DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss");
|
|
||||||
log.Add("热更文件的版本:" + updateName);
|
|
||||||
updateList = hfc.project_local_list;
|
updateList = hfc.project_local_list;
|
||||||
if (updateList.Count <= 0)
|
if (updateList.Count <= 0)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log("未检测到文件改动");
|
UnityEngine.Debug.Log("未检测到文件改动");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 初始化数据
|
||||||
|
updateName = benchName + "_" + GitUtil.GetCurCommitHash() + "_"+DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss");
|
||||||
|
EditorUtility.DisplayProgressBar("正在获取数据:", updateName, 0f);
|
||||||
|
log.Add("热更文件版本:" + updateName);
|
||||||
|
log.Add("热更文件的工程对应的提交信息:" );
|
||||||
|
string[] infos = GitUtil.GetCurCommitSimpleInfo();
|
||||||
|
foreach(string info in infos)
|
||||||
|
{
|
||||||
|
log.Add(info);
|
||||||
|
}
|
||||||
|
log.Add("热更大小:"+hfc.project_local_size);
|
||||||
// copy unity3d
|
// copy unity3d
|
||||||
log.Add("热更文件:");
|
log.Add("热更文件:");
|
||||||
string fromPath = hfc.project_files_path;
|
string fromPath = hfc.project_files_path;
|
||||||
string toPath = hfc.local_files_path;
|
string toPath = hfc.local_files_path;
|
||||||
|
int i = 0;
|
||||||
foreach (ResourceFile rf in updateList)
|
foreach (ResourceFile rf in updateList)
|
||||||
{
|
{
|
||||||
|
EditorUtility.DisplayProgressBar("正在复制文件:" + toPath, rf.fileName, (float)i/updateList.Count);
|
||||||
File.Copy(fromPath + rf.fileName, toPath + rf.fileName, true);
|
File.Copy(fromPath + rf.fileName, toPath + rf.fileName, true);
|
||||||
log.Add(rf.fileName);
|
log.Add(rf.fileName);
|
||||||
}
|
}
|
||||||
// write log
|
// write logf
|
||||||
string[] logArray = log.ToArray();
|
string logName = updateName.Replace("/", "$");
|
||||||
|
EditorUtility.DisplayProgressBar("正在生成Log文件:", logName, 1f);
|
||||||
|
WriteLog(toPath+"/_log", logName, log.ToArray());
|
||||||
// git commit
|
// git commit
|
||||||
|
string commitName = hfc.dir_name + "热更文件更新:" + updateName;
|
||||||
|
EditorUtility.DisplayProgressBar("正在提交到GIT:", commitName, 1f);
|
||||||
|
ProcessUtil.ProcessCommand(toPath, "git add .");
|
||||||
|
ProcessUtil.ProcessCommand(toPath, "git commit -m " + commitName);
|
||||||
|
EditorUtility.ClearProgressBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void WriteLog(string path, string name, string[] contents)
|
||||||
|
{
|
||||||
|
|
||||||
|
UnityEngine.Debug.Log("创建log文件");
|
||||||
|
UnityEngine.Debug.Log(path);
|
||||||
|
UnityEngine.Debug.Log(name);
|
||||||
|
if (!Directory.Exists(path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(path);
|
||||||
|
}
|
||||||
|
string filePath = Path.Combine(path, name) + ".log";
|
||||||
|
//if (!File.Exists(filePath))
|
||||||
|
//{
|
||||||
|
// File.Create(filePath).Close();
|
||||||
|
//}
|
||||||
|
File.WriteAllLines(filePath, contents);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//看热更大小
|
//看热更大小
|
||||||
|
|
|
@ -20,5 +20,28 @@ namespace GameEditor.Util
|
||||||
return benchName;
|
return benchName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
public static string GetCurCommitHash()
|
||||||
|
{
|
||||||
|
string dir = Application.dataPath.Replace("/Assets", "");
|
||||||
|
string fileName = dir + "/Hash.txt";
|
||||||
|
ProcessUtil.ProcessCommand(dir, "git log -n1 --format=format:\"% H\">" + fileName);
|
||||||
|
string[] flines = File.ReadAllLines(fileName, System.Text.Encoding.UTF8);
|
||||||
|
string hash = flines[0].Trim();
|
||||||
|
File.Delete(fileName);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
public static string[] GetCurCommitSimpleInfo()
|
||||||
|
{
|
||||||
|
string dir = Application.dataPath.Replace("/Assets", "");
|
||||||
|
string fileName = dir + "/SimpleInfo.txt";
|
||||||
|
ProcessUtil.ProcessCommand(dir, "git show -q>" + fileName);
|
||||||
|
string[] flines = File.ReadAllLines(fileName, System.Text.Encoding.UTF8);
|
||||||
|
File.Delete(fileName);
|
||||||
|
return flines;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue