Summary
Enable containers to function as Git repositories, allowing users to:
git clone a container
git push changes back
- Track version history of resources
Motivation
- Familiar workflow - Developers know Git; versioning pods becomes intuitive
- Offline editing - Clone pod locally, edit, push when ready
- Collaboration - Multiple users can branch/merge pod content
- Backup - Clone provides automatic backup
- Version history - Built-in audit trail for all changes
Prior Art
nosdav/server
Already implemented in nosdav using git http-backend:
QuitStore
QuitStore - "Quads in Git" - combines Git with RDF/SPARQL for versioned linked data.
Git HTTP Protocol
Implementation Approach
Simple: Shell out to git http-backend
Following nosdav's approach - no npm packages, just use Git's built-in CGI:
import { spawn } from 'child_process';
function handleGitRequest(request, reply) {
const git = spawn('git', ['http-backend'], {
env: {
GIT_PROJECT_ROOT: '/path/to/pods',
GIT_HTTP_EXPORT_ALL: '1',
GIT_HTTP_RECEIVE_PACK: 'true',
PATH_INFO: request.url,
QUERY_STRING: request.query,
REQUEST_METHOD: request.method,
// ... other CGI env vars
}
});
request.raw.pipe(git.stdin);
git.stdout.pipe(reply.raw);
}
Detection
Git requests identified by:
*/info/refs?service=git-upload-pack
*/git-upload-pack
*/git-receive-pack
- URLs ending in
.git
Authorization
Use existing WAC - check acl:Read for clone, acl:Write for push.
Questions
- Auto-init: Create
.git when container is created, or on first clone attempt?
- Bare vs regular: Bare repos are more efficient for servers
- RDF awareness: Should commits trigger any RDF-specific logic?
- Submodules: Support
.git suffix on any container path?
Files to Modify
| File |
Change |
src/handlers/git.js |
NEW - Git HTTP backend handler |
src/index.js |
Add git route detection |
src/handlers/container.js |
Optional: init git on container creation |
Effort Estimate
~3-4 hours - mostly porting nosdav's working implementation.
References
Summary
Enable containers to function as Git repositories, allowing users to:
git clonea containergit pushchanges backMotivation
Prior Art
nosdav/server
Already implemented in nosdav using
git http-backend:QuitStore
QuitStore - "Quads in Git" - combines Git with RDF/SPARQL for versioned linked data.
Git HTTP Protocol
Implementation Approach
Simple: Shell out to
git http-backendFollowing nosdav's approach - no npm packages, just use Git's built-in CGI:
Detection
Git requests identified by:
*/info/refs?service=git-upload-pack*/git-upload-pack*/git-receive-pack.gitAuthorization
Use existing WAC - check
acl:Readfor clone,acl:Writefor push.Questions
.gitwhen container is created, or on first clone attempt?.gitsuffix on any container path?Files to Modify
src/handlers/git.jssrc/index.jssrc/handlers/container.jsEffort Estimate
~3-4 hours - mostly porting nosdav's working implementation.
References