4 releases (2 stable)
new 1.0.1 | Dec 19, 2024 |
---|---|
0.2.0 | Dec 18, 2024 |
0.1.0 | Dec 18, 2024 |
#561 in Development tools
75 downloads per month
9KB
75 lines
repo2text
repo2text is a Rust CLI tool designed to transform the contents of a Git repository into a structured text file. This is particularly useful for uploading repository data into AI systems (like ChatGPT) for analysis, summarization, or debugging purposes.
Features
- Recursively traverses a Git repository to extract file contents.
- Appends the file paths and contents into a single
.txt
file. - Formats the output with clear delimiters for AI compatibility.
- Skips binary files and handles missing files gracefully.
Installation
Install the tool using cargo
:
cargo install repo2text
Or clone the repository and build from source:
git clone https://github.com/vicentedpsantos/repo2text.git
cd repo2text
cargo build --release
Usage
Run repo2text
with the following options:
repo2text --repo <REPO_PATH> --output <OUTPUT_FILE> --excluding <EXCLUDED_DIR>
Arguments:
--repo
: required. Path to the root of the Git repository.--output
: required. Path to the output.txt
file where the repository contents will be saved.--excluding
: optional. Directory to exclude from the traversal. Can be used multiple times.
Example
repo2text --repo ~/projects/faktur --output faktur.txt
repo2text --repo ~/projects/faktur \
--output ~/temp/faktur.txt \
--excluding ~/projects/faktur/spec/ \
--excluding ~/projects/faktur/.git/
This command will:
- Traverse the repository at
~/projects/faktur
. - Read the contents of committed files while excluding the specified directories.
- Save the structured data to
faktur.txt
.
Output Format
The tool generates a .txt
file where:
- Each file begins with a
FILE_PATH
line indicating its location in the repository. - File contents are enclosed within a code block (
```<language>
...
```
). - Sections are separated by
---
for easy parsing.
Use Case: Uploading to AI Systems
The structured format makes it easy to share your repository with AI systems for:
- Code analysis or debugging.
- Generating documentation or summaries.
- Discussing code architecture or functionality.
Simply copy and paste sections of the output .txt
file into your AI chat or upload the entire file if supported.
Limitations
- Excludes uncommitted changes or ignored files.
- Binary files are skipped to prevent unreadable output.
License
This project is licensed under the MIT License.
Dependencies
~12MB
~264K SLoC