8000 Feature/local repo support by ddreamboy · Pull Request #9 · addyosmani/git2txt · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@ddreamboy
Copy link
@ddreamboy ddreamboy commented Dec 31, 2024

Add support for local repositories

Overview

This PR adds support for processing local Git repositories, allowing users to convert already cloned repositories (including private ones) to text format without requiring GitHub access.

Key Changes

  • Added --local flag to specify that the input is a local repository path
  • Implemented local repository validation to ensure path points to a valid Git repository
  • Modified input validation to support both remote URLs and local paths
  • Updated main processing logic to handle local repositories without temporary directory cleanup
  • Added documentation for local repository usage
  • Updated README.md to document local repository support

Usage Examples

You can now use git2txt with local repositories:

# Process a local repository
git2txt /path/to/local/repo --local

# Using relative paths
git2txt ./my-repo --local

# Specify custom output file
git2txt ./my-repo --local --output=analysis.txt

# Include all files regardless of size/type
git2txt ./my-repo --local --include-all

Why?

This enhancement addresses several use cases:

  1. Working with private repositories that are already cloned locally
  2. Processing repositories without needing GitHub authentication
  3. Analyzing repositories with uncommitted changes
  4. Improving performance by skipping the download step
  5. Working in environments with limited GitHub access

Testing

The changes have been tested with:

  • Different repository sizes
  • Various file types
  • Relative and absolute paths
  • Repositories with uncommitted changes
  • Invalid repository paths
  • Edge cases (empty repositories, no .git directory)

Documentation

The help text and README have been updated to include:

  • New --local flag description
  • Usage examples with local repositories
  • Updated feature list
  • Additional use cases

Implementation Notes

  • Local repository validation checks for both directory existence and .git folder presence
  • Repository name is extracted from the directory name for output file naming
  • Temporary directory cleanup is skipped for local repositories
  • All existing functionality for remote repositories remains unchanged

Future Considerations

Potential future enhancements could include:

  • Support for specific Git branches/tags in local repositories
  • Custom file inclusion/exclusion patterns
  • Diff analysis for uncommitted changes

Let me know if you would like me to clarify or modify any part of these changes.

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

0