GitRoot
Craft your forge, Build your project, Grow your community freely
1// SPDX-FileCopyrightText: 2025 Romain Maneschi <romain@gitroot.dev>
2//
3// SPDX-License-Identifier: MIT
4
5import { Date } from "date";
6
7export class Commit {
8 constructor(
9 public branch: string,
10 public hash: string,
11 public message: string,
12 public date: Date,
13 public committerEmail: string,
14 public committerName: string,
15 public parentHash: string,
16 public isSigned: bool,
17 public isValidSignature: bool,
18 public signingKey: string,
19 ) {}
20
21 static build(
22 branch: string,
23 hash: string,
24 message: string,
25 date: Date,
26 committerEmail: string,
27 committerName: string,
28 parentHash: string,
29 isSigned: bool,
30 isValidSignature: bool,
31 signingKey: string,
32 ): Commit {
33 return new Commit(
34 branch,
35 hash,
36 message,
37 date,
38 committerEmail,
39 committerName,
40 parentHash,
41 isSigned,
42 isValidSignature,
43 signingKey,
44 );
45 }
46}
47
48@json
49export class CommitStr {
50 constructor(
51 public branch: string,
52 public hash: string,
53 public message: string,
54 public date: string,
55 public committerEmail: string,
56 public committerName: string,
57 public parentHash: string,
58 public isSigned: bool,
59 public isValidSignature: bool,
60 public signingKey: string,
61 ) {}
62
63 toCommit(): Commit {
64 return Commit.build(
65 this.branch,
66 this.hash,
67 this.message,
68 Date.fromString(this.date),
69 this.committerEmail,
70 this.committerName,
71 this.parentHash,
72 this.isSigned,
73 this.isValidSignature,
74 this.signingKey,
75 );
76 }
77}