public static string ToCommitMessage(this RepositoryStatus status) { var stringBuilder = new StringBuilder(); var lastState = (string)null; foreach (var state in status.OrderBy(s => s.State)) { var thisState = state.State.ToReadableString(); if (thisState == lastState) { stringBuilder.Append($", {Path.GetFileName(state.FilePath)}"); continue; } stringBuilder.Append($"{(lastState == null ? string.Empty : ", ")}{thisState}: {Path.GetFileName(state.FilePath)}"); lastState = thisState; } var commitMessage = stringBuilder.ToString(); if (commitMessage.Length <= MaxCommitMessageLength) { return(commitMessage); } const string newlineInsert = "...\n\n"; commitMessage = commitMessage[..(MaxCommitMessageLength - 3)] + newlineInsert + commitMessage[(MaxCommitMessageLength - 3)..];