Skip to content

Conversation

@aryasaatvik
Copy link

Summary

This PR adds a --keep-git flag and a corresponding keepGit persistent setting to opensrc.

Problem

By default, opensrc removes the .git directory after cloning to save space. While efficient, this prevents subsequent git operations (like git blame, git log, or git rev-parse) which are useful for developer tools and AI agents that need to construct GitHub permalinks or inspect code history.

Changes

  • Added keepGit to OpensrcSettings in src/lib/settings.ts.
  • Implemented getKeepGitPermission() and setKeepGitPermission() helper functions.
  • Modified fetchSource() and fetchRepoSource() in src/lib/git.ts to conditionally skip .git removal.
  • Updated the fetch command and main CLI entry point to support the --keep-git flag.
  • Centralized FetchOptions in src/types.ts.
  • Updated the README with documentation for the new flag and setting.

Usage

# CLI flag
opensrc zod --keep-git

# Persistent setting in opensrc/settings.json
{
  "keepGit": true
}

…it option to OpensrcSettings interface in settings.ts\n- Add getKeepGitPermission and setKeepGitPermission functions\n- Modify fetchSource and fetchRepoSource to respect keepGit option\n- Add --keep-git CLI flag to fetch command\n- Support both CLI flag and settings.json configuration\n- Default behavior remains removing .git for space efficiency\n\nThis enables tools to perform git operations (blame, log, rev-parse) on \ncloned repositories without network calls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant