Skip to content

Add Git support for containers #5

@melvincarvalho

Description

@melvincarvalho

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

  1. Familiar workflow - Developers know Git; versioning pods becomes intuitive
  2. Offline editing - Clone pod locally, edit, push when ready
  3. Collaboration - Multiple users can branch/merge pod content
  4. Backup - Clone provides automatic backup
  5. 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

  1. Auto-init: Create .git when container is created, or on first clone attempt?
  2. Bare vs regular: Bare repos are more efficient for servers
  3. RDF awareness: Should commits trigger any RDF-specific logic?
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions