Skip to content

AshishKumar4/cf-git

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@ashishkumar472/cf-git

A Cloudflare Workers-native fork of isomorphic-git, ported to work with the Cloudflare Workers runtime.

npm version License: MIT

Key Differences from Upstream

1. Native Cloudflare Workers APIs

  • SHA-1 Hashing: Uses crypto.subtle.digestSync() (Workers-specific synchronous crypto API)
  • No CommonJS Dependencies: Removed sha.js, async-lock, and path-browserify
  • Pure ESM: All modules are ES modules with no CommonJS fallbacks

2. Modified Components

src/utils/shasum.js

  • Replaced sha.js with native crypto.subtle.digestSync()
  • Falls back to async crypto.subtle.digest() if needed
  • Workers-only: No Node.js crypto support

src/utils/join.js

  • Replaced path-browserify with simple string-based path joining
  • Sufficient for git operations which always use forward slashes

src/utils/AsyncLock.js

  • Replaced async-lock with queue-based implementation

3. Testing

Tests run in actual Cloudflare Workers runtime using @cloudflare/vitest-pool-workers:

# Run Workers-specific tests
npm run test:workers

# Watch mode
npm run test:workers:watch

Why This Fork?

The original isomorphic-git uses CommonJS modules (require()) which don't work in Cloudflare Workers' ESM-only environment. Instead of using polyfills, we modified the source to use native Workers APIs directly, resulting in:

  • Faster performance - Native crypto is faster than polyfills
  • Smaller bundle - Fewer dependencies
  • No build issues - No CommonJS transformation needed
  • Type-safe - Proper Workers types
  • Tested - Tests run in actual Workers runtime

Development

# Install dependencies
npm install --legacy-peer-deps

# Build
npm run build

# Test in Workers environment
npm run test:workers

# Format code
npm run format

Installation

npm install @ashishkumar472/cf-git
# or
bun add @ashishkumar472/cf-git

Usage

import git from '@ashishkumar472/cf-git'
import http from '@ashishkumar472/cf-git/http/web'

// All isomorphic-git APIs work the same way
await git.clone({
  fs,
  http,
  dir: '/repo',
  url: 'https://github.com/owner/repo',
})

Compatibility

Works with:

  • Cloudflare Workers
  • Cloudflare Pages Functions
  • Miniflare (local development)
  • Vitest with Workers pool

Does NOT work with:

  • Node.js (use original isomorphic-git)
  • Browser (no digestSync support)
  • Other edge runtimes without Workers APIs

License

MIT (same as original isomorphic-git)

Credits

Based on isomorphic-git by William Hilton and contributors.

About

A fork of isomorphic git ported to work with cloudflare workers

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.5%
  • Other 0.5%