huskies: merge 1219 story Add runtime artifacts to the default project scaffold .gitignore
This commit is contained in:
@@ -64,6 +64,8 @@ pub(super) fn write_story_kit_gitignore(root: &Path) -> Result<(), String> {
|
||||
"store.json",
|
||||
"pipeline.db",
|
||||
"*.db",
|
||||
"merge_reports/",
|
||||
"session_store.json",
|
||||
];
|
||||
|
||||
let gitignore_path = root.join(".huskies").join(".gitignore");
|
||||
|
||||
@@ -20,6 +20,16 @@ use templates::{
|
||||
STORY_KIT_STACK,
|
||||
};
|
||||
|
||||
/// Retrofit the Story Kit `.gitignore` entries onto a project that was
|
||||
/// scaffolded before those entries existed (e.g. `merge_reports/` or
|
||||
/// `session_store.json` added in a later release). Idempotent — only
|
||||
/// appends lines that are missing, so it is safe to call on every project
|
||||
/// open regardless of how old the project's `.huskies/` directory is.
|
||||
pub(crate) fn ensure_gitignore_entries(root: &Path) -> Result<(), String> {
|
||||
write_story_kit_gitignore(root)?;
|
||||
append_root_gitignore_entries(root)
|
||||
}
|
||||
|
||||
pub(crate) fn scaffold_story_kit(root: &Path, port: u16) -> Result<(), String> {
|
||||
let story_kit_root = root.join(".huskies");
|
||||
let specs_root = story_kit_root.join("specs");
|
||||
|
||||
@@ -334,6 +334,31 @@ fn scaffold_creates_story_kit_gitignore_with_relative_entries() {
|
||||
// Database files must be ignored so novice users don't accidentally commit them
|
||||
assert!(sk_content.contains("pipeline.db"));
|
||||
assert!(sk_content.contains("*.db"));
|
||||
// Runtime artifacts written under .huskies/ must be ignored too (story 1219)
|
||||
assert!(sk_content.contains("merge_reports/"));
|
||||
assert!(sk_content.contains("session_store.json"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ensure_gitignore_entries_retrofits_already_adopted_project() {
|
||||
// Simulate a project scaffolded before merge_reports/ and session_store.json
|
||||
// were added to the ignore list: .huskies/.gitignore exists but lacks them.
|
||||
let dir = tempdir().unwrap();
|
||||
fs::create_dir_all(dir.path().join(".huskies")).unwrap();
|
||||
fs::write(
|
||||
dir.path().join(".huskies/.gitignore"),
|
||||
"worktrees/\ncoverage/\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
ensure_gitignore_entries(dir.path()).unwrap();
|
||||
|
||||
let sk_content = fs::read_to_string(dir.path().join(".huskies/.gitignore")).unwrap();
|
||||
assert!(sk_content.contains("merge_reports/"));
|
||||
assert!(sk_content.contains("session_store.json"));
|
||||
// Pre-existing entries must survive untouched
|
||||
assert!(sk_content.contains("worktrees/"));
|
||||
assert!(sk_content.contains("coverage/"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user