import { page } from '$app/state';
export type Commit = {
sha: string;
short: string;
author: string;
at: string;
subject: string;
added: number;
removed: number;
files: number;
// Net lines and files this commit added, lockfiles excluded, so the running total is the size of the code.
lines: number;
born: number;
// In a file's history: the file's path in this commit, which differs before a rename.
path?: string;
};
export type TreeEntry = { name: string; path: string; dir: boolean; size: number | null; commit: Commit | null };
export type DiffLine = { kind: 'add' | 'del' | 'ctx'; text: string; old: number | null; new: number | null };
export type DiffHunk = { header: string; lines: DiffLine[] };
export type FileDiff = {
path: string;
from: string | null;
status: 'added' | 'deleted' | 'modified' | 'renamed';
added: number;
removed: number;
binary: boolean;
hunks: DiffHunk[];
truncated: boolean;
};
// The repository the current route is in: every repository page lives under /[owner]/[repo].
export const repoBase = () => `/${page.params.owner ?? ''}/${page.params.repo ?? ''}`;
export const repoName = () => page.params.repo ?? '';