Skip to content

Commit

Permalink
This commit should fail
Browse files Browse the repository at this point in the history
  • Loading branch information
hyiso committed Jul 15, 2023
1 parent d829476 commit cd50245
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/pr_commits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: dart-lang/setup-dart@v1.3

- name: Get Dependencies
run: dart pub get

- name: Validate PR Commits
run: dart run commitlint_cli --from="${{ github.base_ref }}" --to="${{ github.head_ref }}" --config lib/commitlint.yaml
run: VERBOSE=true dart run commitlint_cli --from="${{ github.base_ref }}" --to="${{ github.head_ref }}" --config lib/commitlint.yaml
10 changes: 10 additions & 0 deletions lib/src/read.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'dart:io';
import 'package:path/path.dart';
import 'package:verbose/verbose.dart';

final verbose = Verbose('commitlint:read');

/// Read commit messages in given range([from], [to]),
/// or in [edit] file.
Expand All @@ -11,6 +14,7 @@ Future<Iterable<String>> read({
String? workingDirectory,
Iterable<String>? gitLogArgs,
}) async {
verbose('from = $from, to = $to, edit = $edit');
if (edit != null) {
return await _getEditingCommit(
edit: edit, workingDirectory: workingDirectory);
Expand All @@ -26,11 +30,14 @@ Future<Iterable<String>> _getRangeCommits({
required Iterable<String> gitLogArgs,
String? workingDirectory,
}) async {
verbose('git log ${gitLogArgs.join(' ')}');
final result = await Process.run(
'git',
['log', ...gitLogArgs],
workingDirectory: workingDirectory,
);
verbose('stdout = ${result.stdout}');
verbose('stderr = ${result.stderr}');
return ((result.stdout as String).trim().split('\n'))
.where((message) => message.trim().isNotEmpty)
.toList();
Expand All @@ -40,11 +47,14 @@ Future<Iterable<String>> _getEditingCommit({
required String edit,
String? workingDirectory,
}) async {
verbose('git rev-parse --show-toplevel');
final result = await Process.run(
'git',
['rev-parse', '--show-toplevel'],
workingDirectory: workingDirectory,
);
verbose('stdout = ${result.stdout}');
verbose('stderr = ${result.stderr}');
final root = result.stdout.toString().trim();
final file = File(join(root, edit));
if (await file.exists()) {
Expand Down

0 comments on commit cd50245

Please sign in to comment.