aboutsummaryrefslogtreecommitdiff
path: root/packages/server/src/routes/api/v1/repo/map.ts
blob: a544d1a231139a173c11cd4163c716fd2083464d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { Commit } from "../../../../git/commit";
import { LogCommit } from "api";

export async function commitMap(commit: Commit): Promise<LogCommit> {
	const stats = await commit.stats();

	const is_signed = await commit.isSigned();

	return <LogCommit>{
		id: commit.id,
		author: {
			name: commit.author().name,
			email: commit.author().email,
			fingerprint: await commit.author().fingerprint().catch(() => null)
		},
		isSigned: is_signed,
		signatureVerified: is_signed ? await commit.verifySignature().catch(() => false) : null,
		message: commit.message,
		date: commit.date,
		insertions: stats.insertions,
		deletions: stats.deletions,
		files_changed: stats.files_changed
	};
}