-
Notifications
You must be signed in to change notification settings - Fork 1
/
git_hooks.dart
56 lines (43 loc) · 1.09 KB
/
git_hooks.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import 'dart:io';
// ignore: import_of_legacy_library_into_null_safe
import 'package:git_hooks/git_hooks.dart';
void main(List<String> arguments) {
Map<Git, UserBackFun> params = {
Git.commitMsg: commitMsg,
Git.preCommit: preCommit
};
change(arguments, params);
}
Future<bool> commitMsg() async {
Directory rootDir = Directory.current;
File myFile = new File(rootDir.path + "/.git/COMMIT_EDITMSG");
var commitMsg = myFile.readAsStringSync();
if (commitMsg.startsWith('feat:')) {
return true;
}
if (commitMsg.startsWith('fix:')) {
return true;
}
if (commitMsg.startsWith('docs:')) {
return true;
}
if (commitMsg.startsWith('style:')) {
return true;
}
if (commitMsg.startsWith('refactor:')) {
return true;
}
if (commitMsg.startsWith('test:')) {
return true;
}
if (commitMsg.startsWith('chore:')) {
return true;
}
print(
"ERROR: Please input start with feat:, fix:, docs:, style:, refactor:, text:, chore: commit message!");
return false;
}
Future<bool> preCommit() async {
print('this is pre-commit');
return true;
}