update
Some checks failed
Continuous Integration / Build and Test on ubuntu-latest (push) Failing after 40s
Some checks failed
Continuous Integration / Build and Test on ubuntu-latest (push) Failing after 40s
This commit is contained in:
@@ -103,14 +103,15 @@ fn append_date_and_git_hash(output_path: &mut Option<PathBuf>, config: &Config)
|
||||
}
|
||||
|
||||
if config.append_git_hash {
|
||||
for dir in &config.directory {
|
||||
match Repository::open(dir) {
|
||||
'outer: for dir in &config.directory {
|
||||
match Repository::discover(dir) {
|
||||
Ok(repo) => {
|
||||
let head = repo.head().context("Failed to get repository HEAD")?;
|
||||
if let Some(oid) = head.target() {
|
||||
new_filename.push('_');
|
||||
new_filename.push_str(&oid.to_string()[..7]);
|
||||
info!("Appending git hash to filename.");
|
||||
break 'outer;
|
||||
}
|
||||
}
|
||||
Err(_) => warn!("Not a git repository, cannot append git hash."),
|
||||
@@ -306,7 +307,7 @@ fn write_content_lines(writer: &mut dyn Write, content: &str, line_numbers: bool
|
||||
writeln!(writer, "{:4} | {}", i + 1, line)?;
|
||||
}
|
||||
} else {
|
||||
writeln!(writer, "{}", content)?;
|
||||
write!(writer, "{}", content)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use codebase_to_prompt::{Config, Format, run};
|
||||
use codebase_to_prompt::{run, Config, Format};
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -18,7 +18,7 @@ fn test_run_with_markdown_format() {
|
||||
line_numbers: false,
|
||||
ignore_hidden: true,
|
||||
respect_gitignore: true,
|
||||
relative_path: false,
|
||||
relative_path: true,
|
||||
};
|
||||
|
||||
let result = run(config);
|
||||
@@ -76,7 +76,13 @@ fn test_run_with_git_hash_append() {
|
||||
let result = run(config);
|
||||
assert!(result.is_ok());
|
||||
|
||||
let output_file_name = output_file.file_name().unwrap().to_str().unwrap();
|
||||
assert!(output_file_name.contains("output"));
|
||||
assert!(output_file_name.len() > "output".len());
|
||||
let hashed_file = fs::read_dir(temp_dir.path())
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.find(|e| {
|
||||
let name = e.file_name();
|
||||
let name = name.to_string_lossy();
|
||||
name.starts_with("output_") && name.ends_with(".txt")
|
||||
});
|
||||
assert!(hashed_file.is_some(), "expected output file with git hash suffix");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user