public static void AppendLog(ChangeLogFileStream changelog, string version, string title, string logs) { if (!changelog.Exist()) { return; } string text = changelog.Get(); int firstLogIndex = text.IndexOf("\n## "); if (firstLogIndex < 0) { firstLogIndex = text.IndexOf("\r## "); } if (firstLogIndex < 0) { firstLogIndex = text.Length - 1; } string before = text.Substring(0, firstLogIndex); string after = text.Substring(firstLogIndex); string toAppend = ""; toAppend += string.Format("\n\n## {0} - {1}\n", OnlyDigitsAndPoints(version), DateTime.Now.ToString("yyyy-MM-dd")); toAppend += "### " + title + "\n"; toAppend += StartWithDash(logs); toAppend += "\n"; changelog.Set(before + toAppend + after); }
public static void Create(ChangeLogFileStream changelog, string title, string description) { if (!changelog.Exist()) { changelog.Create("# " + title + " \n" + description + " \n\n"); } }
public static void DrawEditorDefaultInterface(ChangeLogFileStream changelog, ref string version, ref string title, ref string logs, ref bool hide) { if (changelog == null) { return; } hide = EditorGUILayout.Foldout(hide, hide? "→ Log" : "↓ Log", EditorStyles.boldLabel); if (!hide) { GUILayout.BeginHorizontal(); GUILayout.Label("Version:", GUILayout.MaxWidth(60)); if (version == null || version.Length <= 0) { version = ChangeLogUtility.GetLastVersion(changelog); } version = ChangeLogUtility.OnlyDigitsAndPoints( EditorGUILayout.TextField(version, GUILayout.MaxWidth(80))); GUILayout.Label("Title:", GUILayout.MaxWidth(40)); title = EditorGUILayout.TextField(title, GUILayout.MaxWidth(1000)); GUILayout.EndHorizontal(); GUILayout.Label("New(s):", GUILayout.MaxWidth(60)); logs = ChangeLogUtility.StartWithDash( EditorGUILayout.TextArea(logs, GUILayout.MinHeight(80))); GUILayout.BeginHorizontal(); if (!changelog.Exist() && GUILayout.Button("Create ChangeLog.md")) { ChangeLogUtility.Create(changelog, "# Change Log ", "Find here developer log of this package. "); } if (changelog.Exist() && GUILayout.Button("Push to log")) { ChangeLogUtility.AppendLog(changelog, version, title, logs); } if (changelog.Exist() && GUILayout.Button("Open")) { if (changelog.Exist()) { changelog.Open(); } } GUILayout.EndHorizontal(); } }
public static string GetLastVersion(ChangeLogFileStream changelog) { if (changelog == null || !changelog.Exist()) { return("0.0.0"); } string t = changelog.Get(); Regex regex = new Regex("([\\n\\r]##\\s\\s*[\\d\\.]+)"); Match match = regex.Match(t); if (match.Success) { return(ChangeLogUtility.OnlyDigitsAndPoints(match.Value)); } return("0.0.0"); }