feat: git log as panel in the panel

This commit is contained in:
2026-02-17 13:13:55 +01:00
parent 5c0dbaff71
commit b13eba025a
9 changed files with 487 additions and 39 deletions

View File

@@ -780,6 +780,19 @@ export class GitEngine {
});
}
async getFileHistory(projectPath: string, filePath: string, limit = 50): Promise<GitHistoryEntry[]> {
const git = simpleGit(projectPath);
const history = await git.log(['--max-count', String(limit), '--', filePath]);
return history.all.map((entry) => ({
hash: entry.hash,
shortHash: entry.hash.slice(0, 7),
date: entry.date,
subject: entry.message,
author: entry.author_name,
}));
}
async getRemoteState(projectPath: string): Promise<GitRemoteStateDto> {
const git = simpleGit(projectPath);
const status = await git.status();

View File

@@ -124,6 +124,11 @@ export function registerIpcHandlers(): void {
return engine.getHistory(projectPath, limit);
});
safeHandle('git:fileHistory', async (_, projectPath: string, filePath: string, limit?: number) => {
const engine = getGitEngine();
return engine.getFileHistory(projectPath, filePath, limit);
});
safeHandle('git:remoteState', async (_, projectPath: string) => {
const engine = getGitEngine();
return engine.getRemoteState(projectPath);

View File

@@ -14,6 +14,7 @@ export const electronAPI: ElectronAPI = {
getDiffContent: (projectPath: string, filePath: string) => ipcRenderer.invoke('git:diffContent', projectPath, filePath),
getCommitDiffContent: (projectPath: string, commitHash: string) => ipcRenderer.invoke('git:commitDiffContent', projectPath, commitHash),
getHistory: (projectPath: string, limit?: number) => ipcRenderer.invoke('git:history', projectPath, limit),
getFileHistory: (projectPath: string, filePath: string, limit?: number) => ipcRenderer.invoke('git:fileHistory', projectPath, filePath, limit),
getRemoteState: (projectPath: string) => ipcRenderer.invoke('git:remoteState', projectPath),
fetch: (projectPath: string) => ipcRenderer.invoke('git:fetch', projectPath),
pull: (projectPath: string) => ipcRenderer.invoke('git:pull', projectPath),

View File

@@ -405,6 +405,7 @@ export interface ElectronAPI {
getDiffContent: (projectPath: string, filePath: string) => Promise<GitDiffContentDto>;
getCommitDiffContent: (projectPath: string, commitHash: string) => Promise<GitCommitDiffContentDto>;
getHistory: (projectPath: string, limit?: number) => Promise<GitHistoryEntry[]>;
getFileHistory: (projectPath: string, filePath: string, limit?: number) => Promise<GitHistoryEntry[]>;
getRemoteState: (projectPath: string) => Promise<GitRemoteStateDto>;
fetch: (projectPath: string) => Promise<GitActionResult>;
pull: (projectPath: string) => Promise<GitActionResult>;