Consolidate multiple Git backend calls into a single bundle to reduce overhead when opening and auto-refreshing repositories. This significantly improves performance by fetching status, branches, commits, and files in one optimized operation, instead of re-running 'git rev-parse' and 'git status' multiple times. Also, streamline commit history loading by fetching file changes inline via 'git log --name-status -z', eliminating expensive per-commit 'git diff-tree' processes. Additionally, introduce the ability to create new branches from a specific commit in the history and refactor the commit comparison feature into a dedicated dialog. The status panel now displays concise file names.
133 lines
2.6 KiB
TypeScript
133 lines
2.6 KiB
TypeScript
export type FileStatusKind =
|
|
| "modified"
|
|
| "added"
|
|
| "deleted"
|
|
| "renamed"
|
|
| "untracked"
|
|
| "conflicted"
|
|
| "unknown";
|
|
|
|
export interface GitStatus {
|
|
repo_path: string;
|
|
current_branch: string | null;
|
|
upstream: string | null;
|
|
ahead: number;
|
|
behind: number;
|
|
files: GitFileStatus[];
|
|
clean: boolean;
|
|
}
|
|
|
|
export interface GitFileStatus {
|
|
path: string;
|
|
old_path: string | null;
|
|
staged: FileStatusKind | null;
|
|
unstaged: FileStatusKind | null;
|
|
}
|
|
|
|
export interface GitBranch {
|
|
name: string;
|
|
current: boolean;
|
|
remote: boolean;
|
|
}
|
|
|
|
export interface GitCommit {
|
|
hash: string;
|
|
short_hash: string;
|
|
summary: string;
|
|
author_name: string;
|
|
author_email: string;
|
|
date: string;
|
|
refs: string[];
|
|
parents: string[];
|
|
files: GitCommitFile[];
|
|
}
|
|
|
|
export interface GitCommitFile {
|
|
path: string;
|
|
old_path: string | null;
|
|
status: FileStatusKind;
|
|
}
|
|
|
|
export interface GitRepositoryFile {
|
|
path: string;
|
|
tracked: boolean;
|
|
status: FileStatusKind | null;
|
|
}
|
|
|
|
export interface RepositoryBundle {
|
|
status: GitStatus;
|
|
branches: GitBranch[];
|
|
commits: GitCommit[];
|
|
files: GitRepositoryFile[];
|
|
}
|
|
|
|
export interface GitDiffFile {
|
|
path: string;
|
|
old_path: string | null;
|
|
status: FileStatusKind;
|
|
additions: number;
|
|
deletions: number;
|
|
}
|
|
|
|
export interface GitCommitComparison {
|
|
from_hash: string;
|
|
from_short: string;
|
|
to_hash: string;
|
|
to_short: string;
|
|
files: GitDiffFile[];
|
|
patch: string;
|
|
}
|
|
|
|
export interface GitSearchHit {
|
|
commit_hash: string;
|
|
short_hash: string;
|
|
summary: string;
|
|
author_name: string;
|
|
author_email: string;
|
|
date: string;
|
|
file: string;
|
|
old_file: string | null;
|
|
line_number: number | null;
|
|
line: string;
|
|
matches_added: number;
|
|
}
|
|
|
|
export type ExplorerNodeKind = "folder" | "file";
|
|
|
|
export interface ExplorerNode {
|
|
name: string;
|
|
path: string;
|
|
kind: ExplorerNodeKind;
|
|
status: FileStatusKind | null;
|
|
tracked: boolean;
|
|
depth: number;
|
|
children: ExplorerNode[];
|
|
}
|
|
|
|
export type ConflictChoice = "ours" | "theirs" | "both-ot" | "both-to";
|
|
|
|
export type ConflictPart =
|
|
| { kind: "text"; lines: string[] }
|
|
| { kind: "conflict"; index: number; oursLines: string[]; theirsLines: string[] };
|
|
|
|
export type PreparedResolution =
|
|
| { kind: "content"; content: string }
|
|
| { kind: "side"; side: "ours" | "theirs" };
|
|
|
|
export interface ConflictFile {
|
|
path: string;
|
|
content: string;
|
|
ours: string | null;
|
|
theirs: string | null;
|
|
base: string | null;
|
|
binary: boolean;
|
|
ours_size: number | null;
|
|
theirs_size: number | null;
|
|
}
|
|
|
|
export interface StoredCredential {
|
|
username: string;
|
|
password: string;
|
|
expiresAt?: string | null;
|
|
}
|