Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 132 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gitmelt"
version = "0.3.0"
version = "0.4.0"
edition = "2024"
authors = ["qustrolabe <qustrolabe@gmail.com>"]
description = "a tool to turn repository into single file text digest to conveniently feed into LLM"
Expand All @@ -14,8 +14,9 @@ categories = ["command-line-utilities"]
anyhow = "1.0.100"
clap = { version = "4.5.54", features = ["derive"] }
content_inspector = "0.2.4"
crossbeam = "0.8.4"
crossbeam-channel = "0.5.15"
env_logger = "0.11.8"
glob = "0.3.3"
ignore = "0.4.25"
log = "0.4.29"
rayon = "1.11.0"
Expand All @@ -24,8 +25,10 @@ tiktoken-rs = "0.9.1"

[dev-dependencies]
tempfile = "3.24.0"
assert_cmd = "2.0.16"
predicates = "3.1.3"

[profile.release]
strip = true
lto = true
codegen-units = 1
codegen-units = 1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ and `.toml` files in the current directory and its subdirectories
## Build

```bash
cargo build --relase
cargo build --release
cargo install --path .
```
12 changes: 11 additions & 1 deletion src/cloner.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
use anyhow::{Context, Result};
use anyhow::{Context, Result, bail};
use log::info;
use std::process::Command;
use tempfile::TempDir;

fn check_git_installed() -> Result<()> {
match Command::new("git").arg("--version").output() {
Ok(output) if output.status.success() => Ok(()),
_ => {
bail!("Git is not installed or not in PATH. Please install Git to clone repositories.")
}
}
}

pub fn clone_repo(url: &str, branch: Option<&str>) -> Result<TempDir> {
check_git_installed()?;
let temp_dir = TempDir::new()?;
let target_path = temp_dir.path();

Expand Down
2 changes: 1 addition & 1 deletion src/decorator/file_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn print_tree(node: &TreeNode, prefix: &str, output: &mut String) {
prefix,
connector,
name,
if !child.is_file { "/" } else { "" }
if child.is_file { "" } else { "/" }
);

if !child.children.is_empty() {
Expand Down
22 changes: 22 additions & 0 deletions src/decorator/markdown.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use super::{ContentDecorator, format_path};
use std::path::Path;

pub struct MarkdownDecorator;

impl ContentDecorator for MarkdownDecorator {
fn before(&self, path: &Path) -> Option<String> {
let path_str = format_path(path);
// Extract extension for syntax highlighting (e.g., "rs", "toml")
let ext = path.extension().and_then(|e| e.to_str()).unwrap_or("");

Some(format!("## File: {path_str}\n```{ext}"))
}

fn after(&self, _path: &Path) -> Option<String> {
Some("```".to_string())
}

fn transform(&self, _path: &Path, content: String) -> String {
content
}
}
2 changes: 2 additions & 0 deletions src/decorator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ use std::path::Path;

pub mod default;
pub mod file_tree;
pub mod markdown;
pub mod xml;

pub use default::DefaultDecorator;
pub use file_tree::FileTreeDecorator;
pub use markdown::MarkdownDecorator;
pub use xml::XmlDecorator;

#[derive(clap::ValueEnum, Clone, Debug, Default, PartialEq)]
Expand Down
Loading