fix: better handling of gitignore (once)
This commit is contained in:
@@ -135,7 +135,7 @@ export class GitEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async existingStageTargets(projectPath: string): Promise<string[]> {
|
private async existingStageTargets(projectPath: string): Promise<string[]> {
|
||||||
const targets = ['posts', 'media', 'meta', '.gitattributes'];
|
const targets = ['posts', 'media', 'meta', 'thumbnails', '.gitattributes', '.gitignore'];
|
||||||
const existing: string[] = [];
|
const existing: string[] = [];
|
||||||
|
|
||||||
for (const target of targets) {
|
for (const target of targets) {
|
||||||
@@ -383,6 +383,8 @@ export class GitEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.ensureGitignore(projectPath);
|
||||||
|
|
||||||
const stageTargets = await this.existingStageTargets(projectPath);
|
const stageTargets = await this.existingStageTargets(projectPath);
|
||||||
if (stageTargets.length === 0) {
|
if (stageTargets.length === 0) {
|
||||||
emitProgress('staging-files', 75, 'Staging project files...', 'no target files found');
|
emitProgress('staging-files', 75, 'Staging project files...', 'no target files found');
|
||||||
|
|||||||
@@ -49,8 +49,6 @@ export const GitSidebar: React.FC = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await window.electronAPI.git.ensureGitignore(resolvedProjectPath);
|
|
||||||
|
|
||||||
const repoState = await window.electronAPI.git.getRepoState(resolvedProjectPath);
|
const repoState = await window.electronAPI.git.getRepoState(resolvedProjectPath);
|
||||||
setIsRepo(repoState.isRepo);
|
setIsRepo(repoState.isRepo);
|
||||||
setCurrentBranch(repoState.currentBranch || null);
|
setCurrentBranch(repoState.currentBranch || null);
|
||||||
|
|||||||
@@ -294,8 +294,8 @@ describe('GitEngine', () => {
|
|||||||
expect(mockRaw).toHaveBeenCalledWith(['lfs', 'track', '*.tiff']);
|
expect(mockRaw).toHaveBeenCalledWith(['lfs', 'track', '*.tiff']);
|
||||||
expect(mockRaw).toHaveBeenCalledWith(['lfs', 'track', '*.bmp']);
|
expect(mockRaw).toHaveBeenCalledWith(['lfs', 'track', '*.bmp']);
|
||||||
expect(mockRaw).toHaveBeenCalledWith(['lfs', 'track', '*.ico']);
|
expect(mockRaw).toHaveBeenCalledWith(['lfs', 'track', '*.ico']);
|
||||||
expect(mockAdd).toHaveBeenNthCalledWith(1, ['posts', 'media', 'meta', '.gitattributes']);
|
expect(mockAdd).toHaveBeenNthCalledWith(1, ['posts', 'media', 'meta', 'thumbnails', '.gitattributes', '.gitignore']);
|
||||||
expect(mockAdd).toHaveBeenNthCalledWith(2, ['--renormalize', 'posts', 'media', 'meta', '.gitattributes']);
|
expect(mockAdd).toHaveBeenNthCalledWith(2, ['--renormalize', 'posts', 'media', 'meta', 'thumbnails', '.gitattributes', '.gitignore']);
|
||||||
expect(mockCommit).toHaveBeenCalledWith('initial commit');
|
expect(mockCommit).toHaveBeenCalledWith('initial commit');
|
||||||
expect(mockAddRemote).not.toHaveBeenCalled();
|
expect(mockAddRemote).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ describe('GitSidebar', () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checks gitignore defaults when sidebar loads', async () => {
|
it('does not modify gitignore when sidebar loads', async () => {
|
||||||
render(<GitSidebar />);
|
render(<GitSidebar />);
|
||||||
|
|
||||||
await screen.findByRole('button', { name: /initialize git/i });
|
await screen.findByRole('button', { name: /initialize git/i });
|
||||||
|
|
||||||
expect((window as any).electronAPI.git.ensureGitignore).toHaveBeenCalledWith('/repo/path');
|
expect((window as any).electronAPI.git.ensureGitignore).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows Initialize Git button when active project is not a git repository', async () => {
|
it('shows Initialize Git button when active project is not a git repository', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user