/** 推送分支 And Tag */ void Step_PushBranchAndTag() { // 切换分支 if (!CheckoutBranch()) { return; } tmp.Clear(gitNeedPassword); tmp.WriteLine("cd " + gitRoot); tmp.WriteLine(string.Format("git push origin {0}", branch), gitNeedPassword, gitPassword); for (int i = 0; i < centerList.Count; i++) { CenterSwitcher.CenterItem item = centerList[i]; if (item.gitToggle) { tmp.WriteLine(string.Format("git push origin :refs/tags/{0}", item.gitTagUse), gitNeedPassword, gitPassword); } } tmp.WriteLine(string.Format("git push origin --tags"), gitNeedPassword, gitPassword); tmp.Save(); Shell.RunFile(Shell.sh_tmp); }
void Step_AddTag() { GameConstConfig gameConstConfig = GameConstConfig.Load(gitServerEditor.gitGameConstPath); for (int i = 0; i < centerList.Count; i++) { CenterSwitcher.CenterItem item = centerList[i]; if (item.gitToggle) { item.gitTagUse = alreadyExistTagPlan == AlreadyExistTagPlan.Suffix ? item.gitTagLast : item.gitTag; gameConstConfig.CenterName = item.name; gameConstConfig.Save(gitServerEditor.gitGameConstPath); string verinfoPath = gitServerEditor.GetGitVerinfoPath(item.name, true); VersionInfo versionInfo = VersionInfo.Load(verinfoPath); versionInfo.version = gameConstConfig.Version; versionInfo.updateLoadUrl = gitServerEditor.GetGitHostUpdateUrlRoot(item.gitTagUse); versionInfo.Save(verinfoPath); tmp.Clear(); tmp.WriteLine("cd " + gitRoot); if (item.gitTagMaxIndex > 0) { switch (alreadyExistTagPlan) { case AlreadyExistTagPlan.Replace: tmp.WriteLine(string.Format("git tag -d {1} 2>&1 | tee -a {0}", Shell.txt_vertmp, item.gitTag)); break; } } tmp.WriteLine(string.Format("git add . 2>&1 | tee -a {0}", Shell.txt_vertmp)); tmp.WriteLine(string.Format("git commit -am \" 修改GameConstConfig.centerName= {1}\" 2>&1 | tee -a {0}", Shell.txt_vertmp, item.name)); string cmd = string.Format("git tag -a {1} -m \"add tag {1}\" 2>&1 | tee -a {0}", Shell.txt_vertmp, item.gitTagUse); tmp.WriteLine(cmd); tmp.Save(); Shell.RunTmp(Shell.sh_tmp); string txt = File.ReadAllText(Shell.txt_vertmp); if (txt.IndexOf("error:") != -1 || txt.IndexOf("fatal:") != -1) { EditorUtility.DisplayDialog(cmd, "错误: 建议先用git工具处理好再执行!\n" + txt, "终止执行"); stepIsContinue = false; return; } } } }
/** verinfo 将test转正 */ void Step_Verinfo_CopyFromTest() { tmp.Clear(gitNeedPassword); tmp.WriteLine("cd " + gitRoot); for (int i = 0; i < centerList.Count; i++) { CenterSwitcher.CenterItem item = centerList[i]; if (item.gitToggle) { string verinfoPath_Test = gitServerEditor.GetGitVerinfoPath(item.name, true); string verinfoPath = gitServerEditor.GetGitVerinfoPath(item.name, false); tmp.WriteLine(string.Format("cp {0} {1}", verinfoPath_Test, verinfoPath)); } } tmp.Save(); Shell.RunTmp(Shell.sh_tmp); }
/** 检测tag */ void Step_CheckTag() { tmp.Clear(); tmp.WriteLine("cd " + gitRoot); tmp.WriteLine("git tag > " + Shell.txt_vertmp); tmp.Save(); Shell.RunTmp(Shell.sh_tmp); string txt = File.ReadAllText(Shell.txt_vertmp); string[] tags = txt.Split('\n'); Dictionary <string, bool> tagDict = new Dictionary <string, bool>(); Dictionary <string, int> tagIndexDict = new Dictionary <string, int>(); for (int i = 0; i < tags.Length; i++) { tagDict.Add(tags[i], true); var arr = tags[i].Split('-'); int index = tagIndexDict.ContainsKey(arr[0]) ? tagIndexDict[arr[0]] : 0; if (arr.Length == 2) { if (index < Convert.ToInt32(arr[1])) { index = Convert.ToInt32(arr[1]); } } if (tagIndexDict.ContainsKey(arr[0])) { tagIndexDict[arr[0]] = index; } else { tagIndexDict.Add(arr[0], index); } } hasAlreadyExistTag = false; for (int i = 0; i < centerList.Count; i++) { CenterSwitcher.CenterItem item = centerList[i]; if (item.gitToggle) { item.gitTag = GetTag(item.name); item.gitTagMaxIndex = tagIndexDict.ContainsKey(item.gitTag) ? tagIndexDict[item.gitTag] + 1 : 0; if (item.gitTagMaxIndex > 0) { hasAlreadyExistTag = true; LogWarning(string.Format("已经存在tag={0}", item.gitTag)); } } } if (hasAlreadyExistTag) { switch (alreadyExistTagPlan) { case AlreadyExistTagPlan.Kill: stepIsContinue = false; break; } } }
void OnGUI() { gitServerEditor.Init(); Init(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); GUILayout.Space(20); gitServerEditor.OnGUI(); GUILayout.Space(20); // center foldout_center = EditorGUILayout.Foldout(foldout_center, "发行商选择"); if (foldout_center) { GUILayout.BeginVertical(HGUILayout.boxMPStyle, GUILayout.Height(50)); for (int i = 0; i < centerList.Count; i++) { CenterSwitcher.CenterItem item = centerList[i]; item.gitToggle = EditorGUILayout.ToggleLeft(item.name, item.gitToggle, GUILayout.Width(250)); } GUILayout.Space(20); HGUILayout.BeginCenterHorizontal(); if (GUILayout.Button("全选", GUILayout.MinHeight(30), GUILayout.MaxWidth(200))) { for (int i = 0; i < centerList.Count; i++) { CenterSwitcher.CenterItem item = centerList[i]; item.gitToggle = true; } } GUILayout.Space(20); if (GUILayout.Button("全不选", GUILayout.MinHeight(30), GUILayout.MaxWidth(200))) { for (int i = 0; i < CenterSwitcher.centerItemList.Length; i++) { CenterSwitcher.CenterItem item = CenterSwitcher.centerItemList[i]; item.gitToggle = false; } } HGUILayout.EndCenterHorizontal(); GUILayout.EndVertical(); } GUILayout.Space(30); // Res foldout_res = EditorGUILayout.Foldout(foldout_res, "资源"); if (foldout_res) { GUILayout.BeginVertical(HGUILayout.boxMPStyle, GUILayout.Height(50)); // 选项 foldout_res_popups = EditorGUILayout.Foldout(foldout_res_popups, "选项"); if (foldout_res_popups) { GUILayout.BeginVertical(HGUILayout.boxMPStyle, GUILayout.Height(50)); copyType = (CopyType)EditorGUILayout.EnumPopup("拷贝内容方式: ", copyType); GUILayout.Space(20); alreadyExistTagPlan = (AlreadyExistTagPlan)EditorGUILayout.EnumPopup("如果已经存在相同tag执行方案: ", alreadyExistTagPlan); GUILayout.Space(20); gitNeedPassword = EditorGUILayout.ToggleLeft("git是否需要密码提交", gitNeedPassword); gitPassword = EditorGUILayout.TextField("git密码:", gitPassword); GUILayout.Space(20); gitPullVisiableWindow = EditorGUILayout.ToggleLeft("Pull时是否显示命令窗口", gitPullVisiableWindow); GUILayout.Space(20); versionReadFile = (VersionReadFile)EditorGUILayout.EnumPopup("版本号读取目录: ", versionReadFile); EditorGUILayout.LabelField(version); GUILayout.EndVertical(); } GUILayout.Space(20); HGUILayout.BeginCenterHorizontal(); if (GUILayout.Button("推送资源", GUILayout.MinHeight(50), GUILayout.MaxWidth(200))) { Step_Begin(); Step_CheckBranch(); if (stepIsContinue) { Step_CheckTag(); } if (stepIsContinue) { Step_Copy(); } if (stepIsContinue) { Step_CommitBranch(); } if (stepIsContinue) { Step_AddTag(); } if (stepIsContinue) { Step_PushBranchAndTag(); } } HGUILayout.EndCenterHorizontal(); foldout_res_option = EditorGUILayout.Foldout(foldout_res_option, "高级"); if (foldout_res_option) { GUILayout.BeginVertical(HGUILayout.boxMPStyle, GUILayout.Height(50)); if (GUILayout.Button("Begin", GUILayout.MinHeight(30))) { Step_Begin(); } if (GUILayout.Button("检测分支", GUILayout.MinHeight(30))) { Step_CheckBranch(); } if (GUILayout.Button("检查tag是否已经存在", GUILayout.MinHeight(30))) { Step_CheckTag(); } if (GUILayout.Button("拷贝内容", GUILayout.MinHeight(30))) { Step_Copy(); } if (GUILayout.Button("commit branch", GUILayout.MinHeight(30))) { Step_CheckTag(); Step_CommitBranch(); } if (GUILayout.Button("add tag", GUILayout.MinHeight(30))) { Step_CheckTag(); if (stepIsContinue) { Step_AddTag(); } } if (GUILayout.Button("push", GUILayout.MinHeight(30))) { Step_PushBranchAndTag(); } GUILayout.EndVertical(); } foldout_res_option2 = EditorGUILayout.Foldout(foldout_res_option2, "其他"); if (foldout_res_option2) { GUILayout.BeginVertical(HGUILayout.boxMPStyle, GUILayout.Height(50)); if (GUILayout.Button("清除所有本地tag", GUILayout.MinHeight(30))) { ClearAllTagLoacl(); } if (GUILayout.Button("清除所有服务器tag", GUILayout.MinHeight(30))) { ClearAllTagOrigin(); } GUILayout.EndVertical(); } GUILayout.EndVertical(); } // 版本信息 foldout_verinfo = EditorGUILayout.Foldout(foldout_verinfo, "版本信息"); if (foldout_verinfo) { GUILayout.BeginVertical(HGUILayout.boxMPStyle, GUILayout.Height(50)); HGUILayout.BeginCenterHorizontal(); if (GUILayout.Button("推送正式版本信息", GUILayout.MinHeight(50), GUILayout.MaxWidth(200))) { Step_Begin(); Step_Verinfo_CopyFromTest(); Step_CommitBranch(true); if (stepIsContinue) { Step_PushBranch(); } } if (GUILayout.Button("打开版本信息编辑面板", GUILayout.MinHeight(50), GUILayout.MaxWidth(200))) { VersionInfoWindow.Open(); } HGUILayout.EndCenterHorizontal(); // 选项 foldout_verinfo_option = EditorGUILayout.Foldout(foldout_verinfo_option, "选项"); if (foldout_verinfo_option) { GUILayout.BeginVertical(HGUILayout.boxMPStyle, GUILayout.Height(50)); if (GUILayout.Button("Copy From Test", GUILayout.MinHeight(30))) { Step_Verinfo_CopyFromTest(); } if (GUILayout.Button("commit branch", GUILayout.MinHeight(30))) { Step_CommitBranch(true); } if (GUILayout.Button("push branch", GUILayout.MinHeight(30))) { Step_PushBranch(); } GUILayout.EndVertical(); } GUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); }
public GitServerItem AddCenter(CenterSwitcher.CenterItem centerItem) { centerList.Add(centerItem); return(this); }
void OnGUI() { gitServerEditor.Init(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); GUILayout.Space(20); gitServerEditor.OnGUI(); GUILayout.Space(30); // center foldout_center = EditorGUILayout.Foldout(foldout_center, "发行商选择"); if (foldout_center) { GUILayout.BeginVertical(HGUILayout.boxMPStyle, GUILayout.Height(50)); for (int i = 0; i < centerList.Count; i++) { CenterSwitcher.CenterItem item = centerList[i]; item.gitToggle = EditorGUILayout.ToggleLeft(item.name, item.gitToggle, GUILayout.Width(250)); } GUILayout.Space(20); HGUILayout.BeginCenterHorizontal(); if (GUILayout.Button("全选", GUILayout.MinHeight(30), GUILayout.MaxWidth(200))) { for (int i = 0; i < centerList.Count; i++) { CenterSwitcher.CenterItem item = centerList[i]; item.gitToggle = true; } } GUILayout.Space(20); if (GUILayout.Button("全不选", GUILayout.MinHeight(30), GUILayout.MaxWidth(200))) { for (int i = 0; i < CenterSwitcher.centerItemList.Length; i++) { CenterSwitcher.CenterItem item = CenterSwitcher.centerItemList[i]; item.gitToggle = false; } } HGUILayout.EndCenterHorizontal(); GUILayout.EndVertical(); } GUILayout.Space(30); // global foldout_global = EditorGUILayout.Foldout(foldout_global, "全局"); if (foldout_global) { if (GUILayout.Button("刷新", GUILayout.MinHeight(25))) { _versionInfo = null; } GUILayout.Space(30); GUILayout.BeginVertical(HGUILayout.boxMPStyle, GUILayout.ExpandWidth(true)); versionInfo.version = EditorGUILayout.TextField("版本号: ", versionInfo.version, GUILayout.ExpandWidth(true)); if (GUILayout.Button("修改选择的应用商", GUILayout.MinHeight(25), GUILayout.MaxWidth(200))) { for (int i = 0; i < CenterSwitcher.centerItemList.Length; i++) { CenterSwitcher.CenterItem item = CenterSwitcher.centerItemList[i]; if (item.gitToggle) { VersionInfo itemVerInfo = VersionInfo.Load(gitServerEditor.GetGitVerinfoPath(item.name, true)); itemVerInfo.version = versionInfo.version; itemVerInfo.Save(gitServerEditor.GetGitVerinfoPath(item.name, true)); } } } GUILayout.Space(30); EditorGUILayout.LabelField("大版本更新通知:"); versionInfo.noteDownApp = EditorGUILayout.TextArea(versionInfo.noteDownApp, GUILayout.ExpandWidth(true), GUILayout.Height(60)); if (GUILayout.Button("修改选择的应用商", GUILayout.MinHeight(25), GUILayout.MaxWidth(200))) { for (int i = 0; i < CenterSwitcher.centerItemList.Length; i++) { CenterSwitcher.CenterItem item = CenterSwitcher.centerItemList[i]; if (item.gitToggle) { VersionInfo itemVerInfo = VersionInfo.Load(gitServerEditor.GetGitVerinfoPath(item.name, true)); itemVerInfo.noteDownApp = versionInfo.noteDownApp; itemVerInfo.Save(gitServerEditor.GetGitVerinfoPath(item.name, true)); } } } GUILayout.Space(30); EditorGUILayout.LabelField("热更新通知:"); versionInfo.noteHostUpdate = EditorGUILayout.TextArea(versionInfo.noteHostUpdate, GUILayout.ExpandWidth(true), GUILayout.Height(60)); if (GUILayout.Button("修改选择的应用商", GUILayout.MinHeight(25), GUILayout.MaxWidth(200))) { for (int i = 0; i < CenterSwitcher.centerItemList.Length; i++) { CenterSwitcher.CenterItem item = CenterSwitcher.centerItemList[i]; if (item.gitToggle) { VersionInfo itemVerInfo = VersionInfo.Load(gitServerEditor.GetGitVerinfoPath(item.name, true)); itemVerInfo.noteHostUpdate = versionInfo.noteHostUpdate; itemVerInfo.Save(gitServerEditor.GetGitVerinfoPath(item.name, true)); } } } GUILayout.Space(30); versionInfo.isClose = EditorGUILayout.ToggleLeft("是否停服", versionInfo.isClose == 1) ? 1 : 0; if (GUILayout.Button("修改选择的应用商", GUILayout.MinHeight(25), GUILayout.MaxWidth(200))) { for (int i = 0; i < CenterSwitcher.centerItemList.Length; i++) { CenterSwitcher.CenterItem item = CenterSwitcher.centerItemList[i]; if (item.gitToggle) { VersionInfo itemVerInfo = VersionInfo.Load(gitServerEditor.GetGitVerinfoPath(item.name, true)); itemVerInfo.isClose = versionInfo.isClose; itemVerInfo.Save(gitServerEditor.GetGitVerinfoPath(item.name, true)); } } } GUILayout.EndVertical(); } // center list foldout_centerList = EditorGUILayout.Foldout(foldout_centerList, "版本信息列表"); if (foldout_centerList) { if (GUILayout.Button("刷新所有", GUILayout.MinHeight(25))) { for (int i = 0; i < CenterSwitcher.centerItemList.Length; i++) { CenterSwitcher.CenterItem item = CenterSwitcher.centerItemList[i]; item.versionInfo = null; } } GUILayout.Space(20); for (int i = 0; i < CenterSwitcher.centerItemList.Length; i++) { GUILayout.Space(20); CenterSwitcher.CenterItem item = CenterSwitcher.centerItemList[i]; GUILayout.BeginVertical(HGUILayout.boxMPStyle, GUILayout.ExpandWidth(true)); EditorGUILayout.LabelField(item.name + " ( " + gitServerEditor.GetGitVerinfoPath(item.name, true).Replace(gitServerEditor.gitVerinfoRoot, "") + " )"); GUILayout.Space(20); if (item.versionInfo == null) { item.versionInfo = VersionInfo.Load(gitServerEditor.GetGitVerinfoPath(item.name, true)); } item.versionInfo.version = EditorGUILayout.TextField("版本号: ", item.versionInfo.version, GUILayout.ExpandWidth(true)); GUILayout.Space(10); EditorGUILayout.LabelField("大版本更新通知:"); item.versionInfo.noteDownApp = EditorGUILayout.TextArea(item.versionInfo.noteDownApp, GUILayout.ExpandWidth(true), GUILayout.Height(60)); GUILayout.Space(10); EditorGUILayout.LabelField("热更新通知:"); item.versionInfo.noteHostUpdate = EditorGUILayout.TextArea(item.versionInfo.noteHostUpdate, GUILayout.ExpandWidth(true), GUILayout.Height(60)); GUILayout.Space(10); item.versionInfo.isClose = EditorGUILayout.ToggleLeft("是否停服", item.versionInfo.isClose == 1) ? 1 : 0; GUILayout.Space(10); HGUILayout.BeginCenterHorizontal(); if (GUILayout.Button("保存", GUILayout.MinHeight(25), GUILayout.MaxWidth(200))) { item.versionInfo.Save(gitServerEditor.GetGitVerinfoPath(item.name, true)); } if (GUILayout.Button("刷新", GUILayout.MinHeight(25), GUILayout.MaxWidth(200))) { item.versionInfo = null; } HGUILayout.EndCenterHorizontal(); GUILayout.EndVertical(); GUILayout.Space(20); } } // git foldout_git = EditorGUILayout.Foldout(foldout_git, "git"); if (foldout_git) { GUILayout.BeginVertical(HGUILayout.boxMPStyle, GUILayout.ExpandWidth(true)); HGUILayout.BeginCenterHorizontal(); if (GUILayout.Button("CopyFromTest", GUILayout.MinHeight(50), GUILayout.MaxWidth(200))) { Step_Verinfo_CopyFromTest(); } HGUILayout.EndCenterHorizontal(); GUILayout.Space(10); HGUILayout.BeginCenterHorizontal(); if (GUILayout.Button("推送", GUILayout.MinHeight(50), GUILayout.MaxWidth(200))) { Step_Begin(); // if (stepIsContinue) // Step_CheckBranch(); if (stepIsContinue) { Step_CommitBranch(); } if (stepIsContinue) { Step_PushBranchAndTag(); } } HGUILayout.EndCenterHorizontal(); GUILayout.EndVertical(); GUILayout.Space(30); } EditorGUILayout.EndScrollView(); }