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 {
|
if config.append_git_hash {
|
||||||
for dir in &config.directory {
|
'outer: for dir in &config.directory {
|
||||||
match Repository::open(dir) {
|
match Repository::discover(dir) {
|
||||||
Ok(repo) => {
|
Ok(repo) => {
|
||||||
let head = repo.head().context("Failed to get repository HEAD")?;
|
let head = repo.head().context("Failed to get repository HEAD")?;
|
||||||
if let Some(oid) = head.target() {
|
if let Some(oid) = head.target() {
|
||||||
new_filename.push('_');
|
new_filename.push('_');
|
||||||
new_filename.push_str(&oid.to_string()[..7]);
|
new_filename.push_str(&oid.to_string()[..7]);
|
||||||
info!("Appending git hash to filename.");
|
info!("Appending git hash to filename.");
|
||||||
|
break 'outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => warn!("Not a git repository, cannot append git hash."),
|
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)?;
|
writeln!(writer, "{:4} | {}", i + 1, line)?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
writeln!(writer, "{}", content)?;
|
write!(writer, "{}", content)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use codebase_to_prompt::{Config, Format, run};
|
use codebase_to_prompt::{run, Config, Format};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ fn test_run_with_markdown_format() {
|
|||||||
line_numbers: false,
|
line_numbers: false,
|
||||||
ignore_hidden: true,
|
ignore_hidden: true,
|
||||||
respect_gitignore: true,
|
respect_gitignore: true,
|
||||||
relative_path: false,
|
relative_path: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = run(config);
|
let result = run(config);
|
||||||
@@ -76,7 +76,13 @@ fn test_run_with_git_hash_append() {
|
|||||||
let result = run(config);
|
let result = run(config);
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
|
||||||
let output_file_name = output_file.file_name().unwrap().to_str().unwrap();
|
let hashed_file = fs::read_dir(temp_dir.path())
|
||||||
assert!(output_file_name.contains("output"));
|
.unwrap()
|
||||||
assert!(output_file_name.len() > "output".len());
|
.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