diff --git a/Assets/Scripts/Editor/GameEditor/FrameTool/HotFixWindow.cs b/Assets/Scripts/Editor/GameEditor/FrameTool/HotFixWindow.cs index 6622be594f..10d9331e5a 100644 --- a/Assets/Scripts/Editor/GameEditor/FrameTool/HotFixWindow.cs +++ b/Assets/Scripts/Editor/GameEditor/FrameTool/HotFixWindow.cs @@ -352,6 +352,10 @@ namespace GameEditor.FrameTool { _CurConfig.CalHotFixSize(); } + if (GUILayout.Button("刷新", GUILayout.Height(20f))) + { + _CurConfig.CalHotFixSize(); + } if (GUILayout.Button("更新到GIT", GUILayout.Height(20f))) { HotfixConfimWindow.Create("是否要将工程热更文件同步到GIT: " + _CurConfig.desc, _CurConfig.project_local_list, () => @@ -436,33 +440,65 @@ namespace GameEditor.FrameTool string updateName; List updateList; List log = new List(); - // 初始化数据 - updateName = benchName + DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss"); - log.Add("热更文件的版本:" + updateName); updateList = hfc.project_local_list; if (updateList.Count <= 0) { UnityEngine.Debug.Log("未检测到文件改动"); 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 log.Add("热更文件:"); string fromPath = hfc.project_files_path; string toPath = hfc.local_files_path; + int i = 0; foreach (ResourceFile rf in updateList) { + EditorUtility.DisplayProgressBar("正在复制文件:" + toPath, rf.fileName, (float)i/updateList.Count); File.Copy(fromPath + rf.fileName, toPath + rf.fileName, true); log.Add(rf.fileName); } - // write log - string[] logArray = log.ToArray(); - - + // write logf + string logName = updateName.Replace("/", "$"); + EditorUtility.DisplayProgressBar("正在生成Log文件:", logName, 1f); + WriteLog(toPath+"/_log", logName, log.ToArray()); // 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); + } + } //看热更大小 diff --git a/Assets/Scripts/Editor/Util/GitUtil.cs b/Assets/Scripts/Editor/Util/GitUtil.cs index b8afd2e866..604ddc780e 100644 --- a/Assets/Scripts/Editor/Util/GitUtil.cs +++ b/Assets/Scripts/Editor/Util/GitUtil.cs @@ -20,5 +20,28 @@ namespace GameEditor.Util 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; + } } } \ No newline at end of file