Skip to content

Commit dffadc1

Browse files
committed
refactor: clean up code and remove references to GIT_LOCAL_REPOS_DESIGN.md
1 parent 84b1cba commit dffadc1

16 files changed

Lines changed: 49 additions & 584 deletions

GIT_LOCAL_REPOS_DESIGN.md

Lines changed: 0 additions & 535 deletions
This file was deleted.

packages/insomnia-smoke-test/playwright/pages/project/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export class ProjectPage extends BasePage {
7272
}
7373

7474
const breadcrumbLink = this.page.getByTestId('workspace-breadcrumb-level-0').getByRole('link');
75-
await ((await breadcrumbLink.isVisible()) ? breadcrumbLink.click() : this.sidebar.projectRow(projectName).click());
75+
await ((await breadcrumbLink.isVisible())
76+
? breadcrumbLink.click()
77+
: this.sidebar.projectRow(projectName).click());
7678

7779
try {
7880
await this.page.waitForURL(this.projectDashboardUrl, { timeout: 5000, waitUntil: 'commit' });
@@ -103,9 +105,7 @@ export class ProjectPage extends BasePage {
103105
async createCollection(name = 'My Collection'): Promise<void> {
104106
await this.selectCreateInProjectType('Collection');
105107
await this.page.getByRole('dialog').waitFor({ state: 'visible' });
106-
const nameInput = this.page
107-
.getByRole('dialog')
108-
.getByPlaceholder('Enter a name for your Request Collection');
108+
const nameInput = this.page.getByRole('dialog').getByPlaceholder('Enter a name for your Request Collection');
109109
await nameInput.waitFor({ state: 'visible' });
110110
await nameInput.fill(name);
111111
await this.page.getByRole('dialog').getByRole('button', { name: 'Create' }).click();
@@ -154,7 +154,7 @@ export class ProjectPage extends BasePage {
154154
/**
155155
* Opens an existing local folder as a Git project (no clone). The native
156156
* directory picker is mocked to return `folderPath`. If the folder isn't a git
157-
* repo, the app runs `git init`. See GIT_LOCAL_REPOS_DESIGN.md.
157+
* repo, the app runs `git init`.
158158
*/
159159
async openGitProjectFromFolder(name: string, folderPath: string): Promise<void> {
160160
await mockOpenDialogForDirectory(this.app, folderPath);

packages/insomnia-smoke-test/tests/smoke/git-local-repos.test.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { test } from '../../playwright/test';
1010
// Verifies repositories can live in user-chosen folders on disk:
1111
// - opening an existing/plain folder as a Git project (runs `git init` if needed)
1212
// - cloning into a user-chosen destination folder
13-
// See GIT_LOCAL_REPOS_DESIGN.md.
1413

1514
const makeTempDir = (prefix: string) => fs.mkdtempSync(path.join(os.tmpdir(), prefix));
1615

@@ -26,9 +25,7 @@ test.describe('Git repositories in user-chosen folders', () => {
2625
await insomnia.projectPage.openGitProjectFromFolder('Opened Folder Project', folder);
2726

2827
// `git init` must have run inside the chosen folder (decision OQ2).
29-
await expect
30-
.poll(() => fs.existsSync(path.join(folder, '.git')), { timeout: 30_000 })
31-
.toBe(true);
28+
await expect.poll(() => fs.existsSync(path.join(folder, '.git')), { timeout: 30_000 }).toBe(true);
3229

3330
// The project landed — no error banner.
3431
await expect.soft(page.getByText('Opened Folder Project')).toBeVisible();
@@ -41,9 +38,7 @@ test.describe('Git repositories in user-chosen folders', () => {
4138
const folder = makeTempDir('insomnia-open-collision-');
4239
try {
4340
await insomnia.projectPage.openGitProjectFromFolder('First Adoption', folder);
44-
await expect
45-
.poll(() => fs.existsSync(path.join(folder, '.git')), { timeout: 30_000 })
46-
.toBe(true);
41+
await expect.poll(() => fs.existsSync(path.join(folder, '.git')), { timeout: 30_000 }).toBe(true);
4742

4843
// Back to the project dashboard, then try to adopt the same folder again.
4944
await insomnia.projectPage.openGitProjectFromFolder('Second Adoption', folder);
@@ -74,9 +69,7 @@ test.describe('Git clone into a user-chosen folder', () => {
7469
await insomnia.projectPage.cloneGitProjectIntoFolder('Cloned Into Folder', parent);
7570

7671
// The repo URL is "git-server.git" → derived repo name "git-server".
77-
await expect
78-
.poll(() => fs.existsSync(path.join(parent, 'git-server', '.git')), { timeout: 60_000 })
79-
.toBe(true);
72+
await expect.poll(() => fs.existsSync(path.join(parent, 'git-server', '.git')), { timeout: 60_000 }).toBe(true);
8073
} finally {
8174
fs.rmSync(parent, { recursive: true, force: true });
8275
}

packages/insomnia/electron-builder.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ const config = {
5858
NSRequiresAquaSystemAppearance: false,
5959
NSLocalNetworkUsageDescription:
6060
'Insomnia needs permission to connect to local APIs and development servers such as localhost, 127.0.0.1, or other LAN hosts.',
61-
// Allow Finder "Open With → Insomnia" on folders so they can be opened as
62-
// Git projects. See GIT_LOCAL_REPOS_DESIGN.md.
61+
// Allow Finder "Open With → Insomnia" on folders so they can be opened as Git projects.
6362
CFBundleDocumentTypes: [
6463
{
6564
CFBundleTypeName: 'Folder',

packages/insomnia/src/entry.main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ app.on('activate', (_error, hasVisibleWindows) => {
225225
// When a folder path is opened from the OS (CLI arg, Finder "Open With", etc.),
226226
// normalise it into the open-folder deep link so the renderer has a single,
227227
// well-formed entry point. Returns null when the path isn't an existing folder.
228-
// See GIT_LOCAL_REPOS_DESIGN.md.
229228
const toOpenFolderDeepLink = async (rawPath: string): Promise<string | null> => {
230229
try {
231230
if (!rawPath || !path.isAbsolute(rawPath)) {

packages/insomnia/src/main/git-service.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,7 @@ async function assertBranchOnOrigin(context: string): Promise<void> {
370370
* the GitRepository document should pass `directory` to avoid a DB lookup;
371371
* otherwise the directory is resolved from the database by id.
372372
*/
373-
async function getRepoBaseDir(
374-
gitRepositoryId: string,
375-
directory?: string | null,
376-
): Promise<string> {
373+
async function getRepoBaseDir(gitRepositoryId: string, directory?: string | null): Promise<string> {
377374
let dir = directory;
378375
if (dir === undefined) {
379376
const repo = await services.gitRepository.getById(gitRepositoryId);
@@ -395,8 +392,7 @@ async function getRepoBaseDir(
395392
*
396393
* Insomnia owns the app-managed location (`directory === null`). A user-chosen
397394
* `directory` belongs to the user and must never be deleted when the project is
398-
* removed (decision D4 in GIT_LOCAL_REPOS_DESIGN.md). Failures are logged, not
399-
* thrown — losing a project record should not be blocked by a stale folder.
395+
* removed. Failures are logged, not thrown — losing a project record should not be blocked by a stale folder.
400396
*/
401397
async function deleteManagedRepoFolderIfOwned(repo: Pick<GitRepository, '_id' | 'directory'>) {
402398
if (repo.directory) {
@@ -595,7 +591,12 @@ export async function loadGitRepository({ projectId, workspaceId }: { projectId:
595591
}
596592

597593
const bufferId = await database.bufferChanges();
598-
const fsClient = await getGitFSClient({ gitRepositoryId: gitRepository._id, projectId, workspaceId, directory: gitRepository.directory });
594+
const fsClient = await getGitFSClient({
595+
gitRepositoryId: gitRepository._id,
596+
projectId,
597+
workspaceId,
598+
directory: gitRepository.directory,
599+
});
599600

600601
if (GitVCS.isInitializedForRepo(gitRepository._id) && !gitRepository.needsFullClone) {
601602
let legacyInsomniaWorkspace;
@@ -1171,7 +1172,7 @@ export const cloneGitRepoAction = async ({
11711172
selectedAuthorEmail?: string | null;
11721173
/**
11731174
* Optional absolute path to a user-chosen folder to clone into. When omitted,
1174-
* the repository is stored in the app-managed location. See GIT_LOCAL_REPOS_DESIGN.md.
1175+
* the repository is stored in the app-managed location.
11751176
*/
11761177
directory?: string | null;
11771178
}) => {
@@ -1295,7 +1296,11 @@ export const cloneGitRepoAction = async ({
12951296

12961297
const project = await getProject();
12971298

1298-
const fsClient = await getGitFSClient({ projectId: project._id, gitRepositoryId: gitRepository._id, directory: gitRepository.directory });
1299+
const fsClient = await getGitFSClient({
1300+
projectId: project._id,
1301+
gitRepositoryId: gitRepository._id,
1302+
directory: gitRepository.directory,
1303+
});
12991304

13001305
if (gitRepository.needsFullClone) {
13011306
await GitVCS.initFromClone({
@@ -1567,7 +1572,7 @@ export const cloneGitRepoAction = async ({
15671572
};
15681573

15691574
/**
1570-
* Open/adopt an existing local folder as a Git project. See GIT_LOCAL_REPOS_DESIGN.md.
1575+
* Open/adopt an existing local folder as a Git project.
15711576
*
15721577
* Unlike {@link cloneGitRepoAction} this performs no network clone — it points
15731578
* Insomnia at a folder already on disk:
@@ -1606,7 +1611,9 @@ export const openGitRepoAction = async ({
16061611
}
16071612
await fs.promises.access(resolvedDirectory, fs.constants.R_OK | fs.constants.W_OK);
16081613
} catch {
1609-
return { errors: [`Folder is not accessible (check it exists and you have read/write permission): ${resolvedDirectory}`] };
1614+
return {
1615+
errors: [`Folder is not accessible (check it exists and you have read/write permission): ${resolvedDirectory}`],
1616+
};
16101617
}
16111618

16121619
// Hard-block if another project already owns this folder (OQ5).
@@ -1702,7 +1709,7 @@ export const openGitRepoAction = async ({
17021709
* Release a Git repository's runtime/disk resources when its project is being
17031710
* deleted (called from the renderer delete flow). Stops the file watcher and
17041711
* deletes the on-disk folder only when Insomnia owns it — user-chosen folders
1705-
* are left untouched (decision D4 in GIT_LOCAL_REPOS_DESIGN.md).
1712+
* are left untouched.
17061713
*
17071714
* The DB document removal stays in the renderer action so it participates in the
17081715
* same buffered change-set; this only handles the main-process-only concerns.
@@ -1719,7 +1726,7 @@ export const cleanupGitRepoStorageAction = async ({ gitRepositoryId }: { gitRepo
17191726

17201727
/**
17211728
* Move a Git project's on-disk repository to a user-chosen folder and record the
1722-
* new location on `GitRepository.directory`. See GIT_LOCAL_REPOS_DESIGN.md.
1729+
* new location on `GitRepository.directory`.
17231730
*
17241731
* The whole repository (working tree + `.git`) is moved, so history and
17251732
* uncommitted changes are preserved. If the previous location was the managed
@@ -3437,9 +3444,7 @@ export const registerGitServiceAPI = () => {
34373444
ipcMainHandle('git.cloneGitRepo', (_, options: Parameters<typeof cloneGitRepoAction>[0]) =>
34383445
cloneGitRepoAction(options),
34393446
);
3440-
ipcMainHandle('git.openGitRepo', (_, options: Parameters<typeof openGitRepoAction>[0]) =>
3441-
openGitRepoAction(options),
3442-
);
3447+
ipcMainHandle('git.openGitRepo', (_, options: Parameters<typeof openGitRepoAction>[0]) => openGitRepoAction(options));
34433448
ipcMainHandle('git.cleanupGitRepoStorage', (_, options: Parameters<typeof cleanupGitRepoStorageAction>[0]) =>
34443449
cleanupGitRepoStorageAction(options),
34453450
);

packages/insomnia/src/root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ const Root = () => {
407407
}
408408
// Open a local folder as a Git project (from the OS: Finder "Open With",
409409
// `insomnia /path/to/folder`, or this deep link). The main process has
410-
// already verified the path is an existing directory. See GIT_LOCAL_REPOS_DESIGN.md.
410+
// already verified the path is an existing directory
411411
if (urlWithoutParams === 'insomnia://app/open-folder') {
412412
const folderPath = params.path;
413413
if (!folderPath) {

packages/insomnia/src/routes/organization.$organizationId.project.$projectId.delete.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export async function clientAction({ params }: Route.ClientActionArgs) {
3737
const gitRepository = effectiveRepoId ? await services.gitRepository.getById(effectiveRepoId) : null;
3838
if (gitRepository) {
3939
// Stop the watcher and delete the on-disk folder only if Insomnia owns it.
40-
// User-chosen folders are left untouched (see GIT_LOCAL_REPOS_DESIGN.md, D4).
40+
// User-chosen folders are left untouched.
4141
await window.main.git.cleanupGitRepoStorage({ gitRepositoryId: gitRepository._id });
4242
await services.gitRepository.remove(gitRepository);
4343
}

packages/insomnia/src/routes/organization.$organizationId.project.$projectId.update.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export async function clientAction({ request, params }: Route.ClientActionArgs)
345345

346346
if (gitRepository) {
347347
// Stop the watcher and delete the folder only if Insomnia owns it; a
348-
// user-chosen folder stays on disk (see GIT_LOCAL_REPOS_DESIGN.md, D4).
348+
// user-chosen folder stays on disk.
349349
await window.main.git.cleanupGitRepoStorage({ gitRepositoryId: gitRepository._id });
350350
await services.gitRepository.remove(gitRepository);
351351
}

packages/insomnia/src/routes/organization.$organizationId.project.new.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface CreateProjectData {
3030
directory?: string | null;
3131
/**
3232
* When set, adopt this existing local folder as a Git project instead of
33-
* cloning from a URL. See GIT_LOCAL_REPOS_DESIGN.md.
33+
* cloning from a URL.
3434
*/
3535
openExistingDirectory?: string;
3636
}

0 commit comments

Comments
 (0)