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 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"); }