Skip to content

Commit

Permalink
add documentation and root hash change handling
Browse files Browse the repository at this point in the history
  • Loading branch information
janfjohannes committed May 16, 2024
1 parent 781e947 commit 50e585b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
1 change: 0 additions & 1 deletion lix/packages/client/src/git-http/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions lix/packages/client/src/git/debug/packfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions lix/packages/client/src/repoState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)) {
Expand Down
8 changes: 4 additions & 4 deletions lix/packages/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lix/packages/exp/src/lix.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!
},
Expand Down Expand Up @@ -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,
Expand All @@ -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()
},
Expand Down

0 comments on commit 50e585b

Please sign in to comment.