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 committer: string,
14 public parentHash: string
15 ) {}
16
17 static build(
18 branch: string,
19 hash: string,
20 message: string,
21 date: Date,
22 committer: string,
23 parentHash: string
24 ): Commit {
25 return new Commit(branch, hash, message, date, committer, parentHash);
26 }
27}
28
29@json
30export class CommitStr {
31 constructor(
32 public branch: string,
33 public hash: string,
34 public message: string,
35 public date: string,
36 public committer: string,
37 public parentHash: string
38 ) {}
39
40 toCommit(): Commit {
41 return Commit.build(
42 this.branch,
43 this.hash,
44 this.message,
45 Date.fromString(this.date),
46 this.committer,
47 this.parentHash
48 );
49 }
50}