feat: git log as panel in the panel
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user