Title: feat(git): auto-init a bare repo on first push to an empty path by melvincarvalho · Pull Request #466 · JavaScriptSolidServer/JavaScriptSolidServer · GitHub
Open Graph Title: feat(git): auto-init a bare repo on first push to an empty path by melvincarvalho · Pull Request #466 · JavaScriptSolidServer/JavaScriptSolidServer
X Title: feat(git): auto-init a bare repo on first push to an empty path by melvincarvalho · Pull Request #466 · JavaScriptSolidServer/JavaScriptSolidServer
Description: Resolves #465. Summary Today git push http://localhost:5444/public/apps/penny main to a fresh path 404s — there's no .git yet and no HTTP path to create one. The only workaround has been to shell into the data directory and git init --bare manually, which defeats the point of having a git HTTP backend. This PR adds auto-init on first push, gated narrowly so it can't corrupt user content. After this lands, git push to a fresh pod path Just Works™, GitHub-style. Safety conditions Auto-init runs only when all of: Request is git-receive-pack (push). Fetches to a missing path still 404. ACL Write has already been verified by the existing preHandler hook in server.js (no change to authorization). Target path is empty or non-existent. A directory containing non-.git files (e.g. /public/apps/foo with index.html) stays a 404 — we never risk promoting a user-content directory into a git repo. Path resolves inside the data root (existing check above the new code). Implementation notes New helper tryAutoInitBareRepo(repoAbs) near findGitDir; documented with the safety conditions and the caller's responsibility (ACL must be checked upstream). Uses spawnSync('git', [...]) with an arg array — no shell interpolation. Errors swallowed; caller falls through to the standard 404. A missing git binary or a permission issue surfaces as 404, not 500. Concurrent first pushes to the same path are benign: mkdirSync({ recursive: true }) is idempotent and a second git init --bare no-ops on an existing bare repo. Diff size src/handlers/git.js: 52 lines added (40 are JSDoc / comments explaining the safety contract). test/git-auto-init.test.js: new file, 5 tests. Tests New test/git-auto-init.test.js exercises: ✅ Non-existent path → 200 + bare repo materialized ✅ Empty existing directory → 200 + bare repo materialized ✅ Non-empty directory (has index.html) → 404, file untouched, no .git/HEAD/objects ✅ Fetch (git-upload-pack) to a missing path → 404, no filesystem side effect ✅ Second push to a path with an existing repo → 200, no re-init (HEAD inode unchanged) These are the first tests of the git HTTP backend, period — no prior coverage existed. Run with: node --test test/git-auto-init.test.js What this unblocks jspod's `jspod install ` story — once you can push to a fresh path, the install flow is a local clone + git push instead of needing filesystem access on the pod machine The broader apps-in-pods direction — pods become composable git remotes Any downstream wrapper that wants to deploy app code over the existing JSS git HTTP backend Refs #465 — the upstream issue (auto-init proposal, Option A from the three options listed) jspod#25, jspod#26 — downstream consumers #463, #464 — broader apps-in-pods architecture
Open Graph Description: Resolves #465. Summary Today git push http://localhost:5444/public/apps/penny main to a fresh path 404s — there's no .git yet and no HTTP path to create one. The only workaround has been to she...
X Description: Resolves #465. Summary Today git push http://localhost:5444/public/apps/penny main to a fresh path 404s — there's no .git yet and no HTTP path to create one. The only workaround has been to...
Opengraph URL: https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/pull/466
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:a19fd88d-94b6-cb1b-4e2c-058d4a5843f4 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8EC8:137FF:15E812A:1BC53A4:6B03A2BB |
| html-safe-nonce | 6cddfa36b364a5acc6c79b4c39df88de14d18c0479fda749d3e9d7aac391ef34 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RUM4OjEzN0ZGOjE1RTgxMkE6MUJDNTNBNDo2QjAzQTJCQiIsInZpc2l0b3JfaWQiOiI1NzQxNTY2MDAwMjQ0MTcxNDUxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8154c4f173bdd16c5389499342d47dcdf934027016a2b8155c6ae4b7557f4f11 |
| hovercard-subject-tag | pull_request:3694853194 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/pull/466/files |
| twitter:image | https://avatars.githubusercontent.com/u/65864?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/65864?s=400&v=4 |
| og:image:alt | Resolves #465. Summary Today git push http://localhost:5444/public/apps/penny main to a fresh path 404s — there's no .git yet and no HTTP path to create one. The only workaround has been to she... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/JavaScriptSolidServer/JavaScriptSolidServer git https://github.com/JavaScriptSolidServer/JavaScriptSolidServer.git |
| octolytics-dimension-user_id | 205442424 |
| octolytics-dimension-user_login | JavaScriptSolidServer |
| octolytics-dimension-repository_id | 958025407 |
| octolytics-dimension-repository_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 958025407 |
| octolytics-dimension-repository_network_root_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width