repo2text

Crates.iorepo2text
lib.rsrepo2text
version1.0.1
created_at2024-12-18 19:42:13.265364+00
updated_at2024-12-19 18:59:55.652132+00
descriptionA Rust CLI tool to extract and save repository file contents into a text file.
homepagehttps://github.com/vicentedpsantos/repo2text
repositoryhttps://github.com/vicentedpsantos/repo2text
max_upload_size
id1488380
size26,446
Vicente Santos (vicentedpsantos)

documentation

README

repo2text

Crates.io

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:

  1. Traverse the repository at ~/projects/faktur.
  2. Read the contents of committed files while excluding the specified directories.
  3. 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.

Commit count: 4

cargo fmt