-
Notifications
You must be signed in to change notification settings - Fork 9
/
git_dsl.dart
85 lines (63 loc) · 2.03 KB
/
git_dsl.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import 'package:json_annotation/json_annotation.dart'
if (dart.library.isolate) 'package:danger_core/src/mock_json_annotation.dart';
part 'git_dsl.g.dart';
@JsonSerializable()
class GitJSONDSL {
/// Filepaths with changes relative to the git root
@JsonKey(name: 'modified_files')
final List<String> modifiedFiles;
///Newly created filepaths relative to the git root
@JsonKey(name: 'created_files')
final List<String> createdFiles;
/// Removed filepaths relative to the git root
@JsonKey(name: 'deleted_files')
final List<String> deletedFiles;
/// The Git commit metadata
final List<GitCommit> commits;
factory GitJSONDSL.fromJson(Map<String, dynamic> json) =>
_$GitJSONDSLFromJson(json);
GitJSONDSL(
{this.modifiedFiles, this.createdFiles, this.deletedFiles, this.commits});
Map<String, dynamic> toJson() => _$GitJSONDSLToJson(this);
}
@JsonSerializable()
class GitCommit {
/// The SHA for the commit
final String sha;
/// Who wrote the commit
final GitCommitAuthor author;
/// Who deployed the commit
final GitCommitAuthor committer;
/// The commit message
final String message;
/// Potential parent commits, and other assorted metadata
final dynamic tree;
/// SHAs for the commit's parents
final List<String> parents;
/// Link to the commit
final String url;
factory GitCommit.fromJson(Map<String, dynamic> json) =>
_$GitCommitFromJson(json);
GitCommit(
{this.sha,
this.author,
this.committer,
this.message,
this.tree,
this.parents,
this.url});
Map<String, dynamic> toJson() => _$GitCommitToJson(this);
}
@JsonSerializable()
class GitCommitAuthor {
/// The display name for the author
final String name;
/// The authors email
final String email;
/// ISO6801 date string
final String date;
factory GitCommitAuthor.fromJson(Map<String, dynamic> json) =>
_$GitCommitAuthorFromJson(json);
GitCommitAuthor({this.name, this.email, this.date});
Map<String, dynamic> toJson() => _$GitCommitAuthorToJson(this);
}