From 50e585baf1fca072abd24b4190925f583c2ce588 Mon Sep 17 00:00:00 2001 From: Jan Date: Fri, 17 May 2024 00:51:19 +0300 Subject: [PATCH] add documentation and root hash change handling --- lix/packages/client/src/git-http/client.ts | 1 - lix/packages/client/src/git/debug/packfile.ts | 5 +++++ lix/packages/client/src/repoState.ts | 11 ++++++++--- lix/packages/docker-compose.yaml | 8 ++++---- lix/packages/exp/src/lix.svelte.ts | 8 ++++---- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lix/packages/client/src/git-http/client.ts b/lix/packages/client/src/git-http/client.ts index f1eaf212ba..ade8f86a17 100644 --- a/lix/packages/client/src/git-http/client.ts +++ b/lix/packages/client/src/git-http/client.ts @@ -199,7 +199,6 @@ export function makeHttpClient({ if (debug && uint8Array) { const { inflatePackResponse } = await import("../git/debug/packfile.js") console.info(await inflatePackResponse(uint8Array).catch((err: any) => err)) - } if (onRes) { diff --git a/lix/packages/client/src/git/debug/packfile.ts b/lix/packages/client/src/git/debug/packfile.ts index 8cc1fc209b..cc5b6e68be 100644 --- a/lix/packages/client/src/git/debug/packfile.ts +++ b/lix/packages/client/src/git/debug/packfile.ts @@ -5,6 +5,11 @@ import isoGit, { _collect, } from "../../../vendored/isomorphic-git/index.js" +if (window) { + // @ts-expect-error + window.isoGit = isoGit +} + /** * Use this to intercept your resoponse function to log the pack files interals * @param Uint8Array the body of a pack Response diff --git a/lix/packages/client/src/repoState.ts b/lix/packages/client/src/repoState.ts index cadb0912be..3a88f5d22a 100644 --- a/lix/packages/client/src/repoState.ts +++ b/lix/packages/client/src/repoState.ts @@ -130,7 +130,12 @@ export async function repoState( const stats = await rawFs.stat(placeholder) if (stats._rootHash) { - // FIXME: check _rootHash!!! or do this in the checkout ?! + // FIXME: check _rootHash!!! or do this in the checkout ?!? + // for the first version this is not an issue thouhg: + // if user commits localy all files that are changed are not placeholders, all other files are the same oids as when doing original checkout + // if user fetches without checking out etc. the oids are not invalidated + // if user does a different checkout the oids are allready up to date by emptyWorkdir and fresh checkoutPlaceholders + // if user does checkout with active placehodlers wihtout removing them first, checkout will fail with dirty workdir message } oids.push(stats._oid) @@ -198,7 +203,7 @@ export async function repoState( throw new Error("fs provider does not support placeholders") } console.info("Using lix for cloning repo") - // FIXME: symlink = false in git/config!? + // FIXME: symlink = false in git/config!??? await isoGit .clone({ fs: rawFs, @@ -321,7 +326,7 @@ export async function repoState( pathParts.length === 4 && prop === "readFile" ) { - // FIXME: is handling dir option reqlly neceasary anywhere? + // FIXME: is handling dir option really neceasary anywhere? // if (dir !== undefined) { // const dirWithLeadingSlash = dir.endsWith("/") ? dir : dir + "/" // if (!filePath.startsWith(dirWithLeadingSlash)) { diff --git a/lix/packages/docker-compose.yaml b/lix/packages/docker-compose.yaml index 251033475f..934c24638a 100644 --- a/lix/packages/docker-compose.yaml +++ b/lix/packages/docker-compose.yaml @@ -8,7 +8,7 @@ services: container_name: git image: git:12 hostname: git - ports: [ "8000" ] + # ports: [ "8000" ] labels: [ dev.orbstack.domains=git.local ] entrypoint: /start.sh # stdin_open: true @@ -37,8 +37,8 @@ services: volumes: - ./gitea:/data # - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" + # ports: + # - "3000:3000" runner: restart: always @@ -72,7 +72,7 @@ services: RUN chmod +x /workspace/dev.sh WORKDIR /workspace # todo: shell aliase - ports: [ "3334" ] + # ports: [ "3334" ] working_dir: /workspace entrypoint: /bin/bash ./dev.sh # entrypoint: /bin/bash diff --git a/lix/packages/exp/src/lix.svelte.ts b/lix/packages/exp/src/lix.svelte.ts index fa75afee2f..3afe9e1363 100644 --- a/lix/packages/exp/src/lix.svelte.ts +++ b/lix/packages/exp/src/lix.svelte.ts @@ -13,7 +13,7 @@ export function openRepo (url, { branch, author }) { folders: [], // >> files() fetchRefs: async function () { - return branches?.length < 2 && repoProm.then((repo)=> repo.getBranches().then(br => { + return branches?.length < 2 && repoProm.then((repo)=> repo.getBranches().then(br => { branches = br })) // TODO: reactivity: needs to be exposed but only executed when used in ui > revisit samuels proxy requirement! }, @@ -48,13 +48,13 @@ export function openRepo (url, { branch, author }) { set content (val) { fileContent = val - repoProm.then((repo: any) => repo.write(path, val).then(() => setTimeout(updateStatus, 0))) + repoProm.then((repo) => repo.write(path, val).then(() => setTimeout(updateStatus, 0))) } } }, pull: async function () { - const repo: any = await repoProm + const repo = await repoProm await repo.pull({ fastForward: true, singleBranch: true, @@ -63,7 +63,7 @@ export function openRepo (url, { branch, author }) { }, push: async function () { - const repo: any = await repoProm + const repo = await repoProm await repo.push() await updateStatus() },