From eee4c54df0076182d1034675d53ffecdfabb0454 Mon Sep 17 00:00:00 2001 From: Ephenodrom Date: Fri, 26 Apr 2024 11:03:28 +0200 Subject: [PATCH] Prepare release 1.6.0 --- CHANGELOG.md | 5 +++++ README.md | 15 ++++++++++++++- bin/src/format_command.dart | 7 ++++++- pubspec.yaml | 2 +- test/format_command_test.dart | 17 +++++++++++++++++ 5 files changed, 43 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 161052d..66deace 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.6.0 + +- Fix REPLACE value for addIssueLink parameter +- Add new value REPLACE_ALL for addIssueLink parameter + ## 1.5.0 - Add new parameter "--filterDuplicates" (#1) diff --git a/README.md b/README.md index c8fe499..252881a 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Git Log Markdown Formater is a command line tool to convert a git log one line o - [How to use it](#how-to-use-it) - [Example](#example) - [Parameters](#parameters) + - [Additional Description](#additional-description) - [The template](#the-template) - [Pipeline example](#pipeline-example) - [.gitlab-ci.yml](#gitlab-ciyml) @@ -34,7 +35,7 @@ Git Log Markdown Formater is a command line tool to convert a git log one line o | --issueType | The issue management software you use. | JIRA (default), GITHUB, GITLAB | | | --iBaseUrl | The base url to display the issue. | | Required if addIssueLink != NONE | | --cBaseUrl | The base url to display the commit. | | Required if addCommitLink != NONE | -| --addIssueLink | Whether to add a issue link within the subject (%s) if one is found. | NONE, REPLACE (default), PREPEND, APPEND | | +| --addIssueLink | Whether to add a issue link within the subject (%s) if one is found. | NONE, REPLACE (default), REPLACE_ALL, PREPEND, APPEND | | | --addCommitLink | Whether to add a commit link to the hash (%H) or replace it. | NONE, REPLACE (default), PREPEND, APPEND | | | --header | String to append at the beginning of the markdown. | | | | --footer| String to append at the end of the markdown. | | | @@ -42,6 +43,18 @@ Git Log Markdown Formater is a command line tool to convert a git log one line o | --noMerges| Ignore merge requests | true, false (default) | | | --filterDuplicates| Filter entries with already existing commit messages | true, false (default) | | +#### Additional Description + +**addIssueLink**: + +Assuming you have the following commit message as the subject "JIRA-1234 - Fixing some stuff" and the following template "- %s". + +- NONE "- JIRA-1234 - Fixing some stuff" +- REPLACE (default): "- [JIRA-1234](https://link.to.my.jira/JIRA-1234) - Fixing some stuff" +- REPLACE_ALL: "- [JIRA-1234](https://link.to.my.jira/JIRA-1234)" +- PREPEND: "- [JIRA-1234](https://link.to.my.jira/JIRA-1234) JIRA-1234 - Fixing some stuff" +- APPEND: "- JIRA-1234 - Fixing some stuff [JIRA-1234](https://link.to.my.jira/JIRA-1234)" + ### The template You can define a custom template to order the values in a certain order or to create a readable markdown. The default template is set to **"- %s %H by %an"** and with all other default settings, this will result in something similar to this: diff --git a/bin/src/format_command.dart b/bin/src/format_command.dart index 71f8c6d..ceb2f7a 100644 --- a/bin/src/format_command.dart +++ b/bin/src/format_command.dart @@ -81,6 +81,7 @@ class FormatCommand extends Command { "REPLACE", "PREPEND", "APPEND", + "REPLACE_ALL", ], help: "To add a issue link at the end of the subject (%s).", ); @@ -355,17 +356,21 @@ class FormatCommand extends Command { String processModoluS(String? m, String formattedLine, String line) { var issue = getIssue(line); var link = ""; + m ??= "NULL"; if (issue != null && issue.length > 1) { link = issueType == "JIRA" ? issue : issue.substring(1); } if (issue != null && addIssueLink == "REPLACE") { + var tmp = m.replaceAll(issue, "[$issue]($ibu$link)"); + formattedLine = formattedLine.replaceAll("%s", tmp); + } else if (issue != null && addIssueLink == "REPLACE_ALL") { formattedLine = formattedLine.replaceAll("%s", "[$issue]($ibu$link)"); } else if (issue != null && addIssueLink == "PREPEND") { formattedLine = formattedLine.replaceAll("%s", " [$issue]($ibu$link) $m"); } else if (issue != null && addIssueLink == "APPEND") { formattedLine = formattedLine.replaceAll("%s", "$m [$issue]($ibu$link)"); } else { - formattedLine = formattedLine.replaceAll("%s", m ?? "NULL"); + formattedLine = formattedLine.replaceAll("%s", m); } return formattedLine; } diff --git a/pubspec.yaml b/pubspec.yaml index 9955b52..ecb804a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: git_log_markdown_formatter description: A sample command-line application with basic argument parsing. -version: 1.5.0 +version: 1.6.0 environment: sdk: ^3.2.2 diff --git a/test/format_command_test.dart b/test/format_command_test.dart index 4044ff1..a092304 100644 --- a/test/format_command_test.dart +++ b/test/format_command_test.dart @@ -193,4 +193,21 @@ s=JIRA-1234: Fix Typo;H=f2d9429a6bd955d12c2d82d481a46547cca51ccf;an=romgrm var markdown = cmd.formatLines(log8.split("\n")); expect(markdown, expected8); }); + + test('test processModuluS', () async { + var cmd = FormatCommand(); + cmd.cbu = "https://github.com/Ephenodrom/Dart-Basic-Utils/commit/"; + cmd.ibu = "https://github.com/Ephenodrom/Dart-Basic-Utils/issues/"; + cmd.issueType = "JIRA"; + cmd.template = "- %s"; + cmd.addIssueLink = "REPLACE"; + var line = + "s=JIRA-1234 - Fixing some stuff;H=e03ba499fd3238879ca3f2f2badf7457d61b0e7f;an=Ephenodrom"; + var template = "- %s"; + var m = "JIRA-1234 - Fixing some stuff"; + + var result = cmd.processModoluS(m, template, line); + expect(result, + "- [JIRA-1234](https://github.com/Ephenodrom/Dart-Basic-Utils/issues/JIRA-1234) - Fixing some stuff"); + }); }