Skip to content

Commit

Permalink
Prepare release 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ephenodrom committed Feb 7, 2024
1 parent 0575916 commit 0039cc9
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- name: Build Executable
run: |
dart pub get
dart update_meta.dart
dart compile exe bin/git_log_markdown_formatter.dart -o glmf
zip glmf.zip glmf
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.4.0

- Minor code improvements
- Added unit tests
- Add new command to display the version

## 1.3.0

- Remove %b in format.
Expand Down
2 changes: 2 additions & 0 deletions bin/git_log_markdown_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import 'package:args/command_runner.dart';

import 'src/exception/git_exception.dart';
import 'src/format_command.dart';
import 'src/version.dart';

void main(List<String> arguments) {
CommandRunner("glmf", "A simple git log to markdown formatter")
..addCommand(FormatCommand())
..addCommand(VersionCommand())
..run(arguments).catchError(
(error) {
if (error is GitException) {
Expand Down
6 changes: 6 additions & 0 deletions bin/meta.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// DO NOT EDIT THIS FILE EXCEPT TO ENTER INITIAL VERSION AND OTHER META INFO
/// THIS FILE IS AUTOMATICALLY OVER WRITTEN BY MetaUpdate
Map<String, String> meta = <String, String>{
"version": "X.X.X",
};
2 changes: 1 addition & 1 deletion bin/src/format_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class FormatCommand extends Command {
}

parameters.add(
'--format="H=%H;h=%h;T=%T;t=%t;P=%P;p=%p;an=%an;ae=%ae;ad=%ad;ar=%ar;cn=%cn;ce=%ce;cd=%cd;cr=%cr;s=%s"');
'--format=H=%H;h=%h;T=%T;t=%t;P=%P;p=%p;an=%an;ae=%ae;ad=%ad;ar=%ar;cn=%cn;ce=%ce;cd=%cd;cr=%cr;s=%s');
ProcessResult result = await Process.run(
'git',
parameters,
Expand Down
18 changes: 18 additions & 0 deletions bin/src/version.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:args/command_runner.dart';

import '../meta.dart';

class VersionCommand extends Command {
@override
String get description => "Prints the current version";

@override
String get name => "version";

VersionCommand();

@override
void run() async {
print("Version ${meta['version']}");
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: git_log_markdown_formatter
description: A sample command-line application with basic argument parsing.
version: 1.3.0
version: 1.4.0

environment:
sdk: ^3.2.2
Expand Down
36 changes: 31 additions & 5 deletions test/format_command_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:test/test.dart';

import '../bin/src/format_command.dart';
Expand Down Expand Up @@ -64,17 +67,20 @@ s=Prepare release 5.7.0;H=6a5034927857a08f3bdf5a177529e361179f6dab;an=Ephenodrom
- Prepare release 5.7.0 [Commit](https://github.com/Ephenodrom/Dart-Basic-Utils/commit/6a5034927857a08f3bdf5a177529e361179f6dab) by Ephenodrom''';

var log5 = '''
H=f8a1e620360ca63bc0394bf4ad1da048202414b0;h=f8a1e620;T=de9b19f895ce53c3937e4af6466402732f1db798;t=de9b19f8;P=381199afb48e88d4d910ae1ac696b6a3dd1b6c88 bb52d4b4b08e3d8b1e4b9874b002e194ec9fb2fe;p=381199af bb52d4b4;an=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0;ae=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0@gitlab.muc.internetx.com;ad=Tue Feb 6 10:12:27 2024 +0000;ar=32 minutes ago;cn=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0;ce=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0@gitlab.muc.internetx.com;cd=Tue Feb 6 10:12:27 2024 +0000;cr=32 minutes ago;s=Merge branch 'develop';b=
H=bb52d4b4b08e3d8b1e4b9874b002e194ec9fb2fe;h=bb52d4b4;T=de9b19f895ce53c3937e4af6466402732f1db798;t=de9b19f8;P=fed4dbc2de6f96fa6fb8614aca18d173e77efdea;p=fed4dbc2;an=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0;ae=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0@gitlab.muc.internetx.com;ad=Tue Feb 6 10:12:27 2024 +0000;ar=32 minutes ago;cn=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0;ce=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0@gitlab.muc.internetx.com;cd=Tue Feb 6 10:12:27 2024 +0000;cr=32 minutes ago;s=Update versions for release;b=
H=8dc94f9c56f4459e6be99b44e61831690d55b17f;h=8dc94f9c;T=08d5a5d01ad5ee96335952b78e97e8776fd2d700;t=08d5a5d0;P=6c10904dffddf1db78711bf2aa91a448ece939ee;p=6c10904d;an=surattanabopp;[email protected];ad=Mon Jan 29 19:18:55 2024 +0100;ar=8 days ago;cn=surattanabopp;[email protected];cd=Mon Jan 29 19:18:55 2024 +0100;cr=8 days ago;s=SSLM-1369 Fix Null Pointer Exception;b=
H=6c10904dffddf1db78711bf2aa91a448ece939ee;h=6c10904d;T=c8c44a9e36cf5c10d142fe481add1c79599e7773;t=c8c44a9e;P=aacd6f9925ad245f9fd07d0cf764253d517ba752;p=aacd6f99;an=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0;ae=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0@gitlab.muc.internetx.com;ad=Tue Jan 23 14:52:27 2024 +0000;ar=2 weeks ago;cn=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0;ce=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0@gitlab.muc.internetx.com;cd=Tue Jan 23 14:52:27 2024 +0000;cr=2 weeks ago;s=Update for next development version;b=
H=aacd6f9925ad245f9fd07d0cf764253d517ba752;h=aacd6f99;T=3a0dc6937a412026b645ed43476c27f7a9f0d4ad;t=3a0dc693;P=d67d1af73ecb49b16dc557dcd2732a56c104c8cd 381199afb48e88d4d910ae1ac696b6a3dd1b6c88;p=d67d1af7 381199af;an=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0;ae=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0@gitlab.muc.internetx.com;ad=Tue Jan 23 14:52:24 2024 +0000;ar=2 weeks ago;cn=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0;ce=group_103_bot_b3bc1c614c59f2a273ddb49272a686f0@gitlab.muc.internetx.com;cd=Tue Jan 23 14:52:24 2024 +0000;cr=2 weeks ago;s=Merge tag '4.15.0' into develop;b=Tag release
H=f8a1e620360ca63bc0394bf4ad1da048202414b0;h=f8a1e620;T=de9b19f895ce53c3937e4af6466402732f1db798;t=de9b19f8;P=381199afb48e88d4d910ae1ac696b6a3dd1b6c88 bb52d4b4b08e3d8b1e4b9874b002e194ec9fb2fe;p=381199af bb52d4b4;an=group__bot_b3bc1c614c59f2a273ddb49272a686f0;ae=group__bot_;ad=Tue Feb 6 10:12:27 2024 +0000;ar=32 minutes ago;cn=group__bot_b3bc1c614c59f2a273ddb49272a686f0;ce=group__bot_;cd=Tue Feb 6 10:12:27 2024 +0000;cr=32 minutes ago;s=Merge branch 'develop';b=
H=bb52d4b4b08e3d8b1e4b9874b002e194ec9fb2fe;h=bb52d4b4;T=de9b19f895ce53c3937e4af6466402732f1db798;t=de9b19f8;P=fed4dbc2de6f96fa6fb8614aca18d173e77efdea;p=fed4dbc2;an=group__bot_b3bc1c614c59f2a273ddb49272a686f0;ae=group__bot_;ad=Tue Feb 6 10:12:27 2024 +0000;ar=32 minutes ago;cn=group__bot_b3bc1c614c59f2a273ddb49272a686f0;ce=group__bot_;cd=Tue Feb 6 10:12:27 2024 +0000;cr=32 minutes ago;s=Update versions for release;b=
H=6c10904dffddf1db78711bf2aa91a448ece939ee;h=6c10904d;T=c8c44a9e36cf5c10d142fe481add1c79599e7773;t=c8c44a9e;P=aacd6f9925ad245f9fd07d0cf764253d517ba752;p=aacd6f99;an=group__bot_b3bc1c614c59f2a273ddb49272a686f0;ae=group__bot_;ad=Tue Jan 23 14:52:27 2024 +0000;ar=2 weeks ago;cn=group__bot_b3bc1c614c59f2a273ddb49272a686f0;ce=group__bot_;cd=Tue Jan 23 14:52:27 2024 +0000;cr=2 weeks ago;s=Update for next development version;b=
H=aacd6f9925ad245f9fd07d0cf764253d517ba752;h=aacd6f99;T=3a0dc6937a412026b645ed43476c27f7a9f0d4ad;t=3a0dc693;P=d67d1af73ecb49b16dc557dcd2732a56c104c8cd 381199afb48e88d4d910ae1ac696b6a3dd1b6c88;p=d67d1af7 381199af;an=group__bot_b3bc1c614c59f2a273ddb49272a686f0;ae=group__bot_;ad=Tue Jan 23 14:52:24 2024 +0000;ar=2 weeks ago;cn=group__bot_b3bc1c614c59f2a273ddb49272a686f0;ce=group__bot_;cd=Tue Jan 23 14:52:24 2024 +0000;cr=2 weeks ago;s=Merge tag '4.15.0' into develop;b=Tag release
''';

var expected5 = '''
- Merge branch 'JIRA-2' into 'develop' [Commit](https://github.com/Ephenodrom/Dart-Basic-Utils/commit/aa1114f4d27a049ac4e01fa78402eee965a1528a) by Ephenodrom
- Update .gitlab-ci.yml [Commit](https://github.com/Ephenodrom/Dart-Basic-Utils/commit/c491eb38b129b85a21e6482c8e7e7a8cdd02e03a) by Ephenodrom''';

var expected6 = '''
- Prepare release 1.3.0 [Commit](https://github.com/Ephenodrom/Dart-Basic-Utils/commit/057591671b2480912eb8813e4cc1800a7b9159e9) by Ephenodrom
- Prepare release 1.2.0 [Commit](https://github.com/Ephenodrom/Dart-Basic-Utils/commit/5487684ade026e08cebef020d13e29750c470fd6) by Ephenodrom''';

test('test formatLines()', () {
var cmd = FormatCommand();
cmd.cbu = "https://github.com/Ephenodrom/Dart-Basic-Utils/commit/";
Expand Down Expand Up @@ -149,4 +155,24 @@ H=aacd6f9925ad245f9fd07d0cf764253d517ba752;h=aacd6f99;T=3a0dc6937a412026b645ed43
var markdown = cmd.formatLines(log5.split("\n"));
expect(markdown, expected5);
});

test('test formatLines() 7', () async {
var args = <String>[
"format",
"-otest_resources/test_notes.md",
"--iBaseUrl=https://github.com/Ephenodrom/Dart-Basic-Utils/issues/",
"--cBaseUrl=https://github.com/Ephenodrom/Dart-Basic-Utils/commit/",
'--from=1.1.0',
'--to=1.3.0',
];

var runner = CommandRunner("glmf", "A simple git log to markdown formatter")
..addCommand(FormatCommand());
await runner.run(args);
await Future.delayed(Duration(seconds: 1));
var testNotes = File("test_resources/test_notes.md");
var content = testNotes.readAsStringSync();
expect(expected6, content);
testNotes.deleteSync();
});
}
34 changes: 34 additions & 0 deletions update_meta.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'dart:io';

void main() {
var metaDartFile = File("bin/meta.dart");

try {
// Read the pubspec.yaml file
final pubspecFile = File('pubspec.yaml');
final pubspecContent = pubspecFile.readAsStringSync();

// Use a regular expression to extract the version
final versionMatch = RegExp(r'version: (.+)').firstMatch(pubspecContent);

// Check if a match was found
if (versionMatch != null) {
final version = versionMatch.group(1)!;

String metaDartFileContents = """
/// DO NOT EDIT THIS FILE EXCEPT TO ENTER INITIAL VERSION AND OTHER META INFO
/// THIS FILE IS AUTOMATICALLY OVER WRITTEN BY MetaUpdate
Map<String, String> meta = <String, String>{
"version":"$version",
};
""";

metaDartFile.writeAsStringSync(metaDartFileContents);
} else {
print('Version not found in pubspec.yaml');
}
} catch (e) {
print('Error: $e');
}
}

0 comments on commit 0039cc9

Please sign in to comment.