Commit preview panel at the bottom; open other repositories from a recent list or a folder picker
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { addRecent, MAX_RECENTS } from "./recents";
|
||||
|
||||
describe("addRecent", () => {
|
||||
it("puts the path first", () => {
|
||||
expect(addRecent(["/a", "/b"], "/c")).toEqual(["/c", "/a", "/b"]);
|
||||
});
|
||||
it("moves a path that is already there to the front instead of repeating it", () => {
|
||||
expect(addRecent(["/a", "/b", "/c"], "/b")).toEqual(["/b", "/a", "/c"]);
|
||||
});
|
||||
it("keeps the list short", () => {
|
||||
const many = Array.from({ length: MAX_RECENTS }, (_, i) => `/r${i}`);
|
||||
const out = addRecent(many, "/new");
|
||||
expect(out).toHaveLength(MAX_RECENTS);
|
||||
expect(out[0]).toBe("/new");
|
||||
expect(out).not.toContain(`/r${MAX_RECENTS - 1}`);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
export const MAX_RECENTS = 12;
|
||||
|
||||
/** Puts `path` first, drops an older copy of it, and keeps at most MAX_RECENTS paths. */
|
||||
export function addRecent(list: string[], path: string): string[] {
|
||||
return [path, ...list.filter((p) => p !== path)].slice(0, MAX_RECENTS);
|
||||
}
|
||||
@@ -58,3 +58,26 @@ export interface LaidOutRow {
|
||||
color: number;
|
||||
segments: Segment[];
|
||||
}
|
||||
|
||||
export interface ChangedFile {
|
||||
/** One letter: A added, M modified, D deleted, R renamed, C copied, T type changed. */
|
||||
status: string;
|
||||
path: string;
|
||||
old_path: string | null;
|
||||
/** Line counts; null for binary files. */
|
||||
added: number | null;
|
||||
deleted: number | null;
|
||||
}
|
||||
|
||||
export interface CommitDetails {
|
||||
hash: string;
|
||||
author: string;
|
||||
author_email: string;
|
||||
author_time: number;
|
||||
committer: string;
|
||||
committer_email: string;
|
||||
commit_time: number;
|
||||
parents: string[];
|
||||
message: string;
|
||||
files: ChangedFile[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user