Skip to content

Commit 4817815

Browse files
baudouin-ivclaude
andcommitted
fix: self-ignore the .nightcrow session directory
The session writer creates `<repo>/.nightcrow/session.json` inside the user's working tree. Without explicit setup the file appears as an untracked path in both `git status` and nightcrow's own status view, which is noise the user has to suppress per-repo by editing their `.gitignore`. Have `save_session` drop a `.nightcrow/.gitignore` containing `*` on first write so the directory ignores itself; an existing file is left alone so a user-customised ignore pattern is never clobbered. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent bdcafe4 commit 4817815

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/session.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,19 @@ pub fn load_session(repo_path: &str) -> Option<SessionState> {
4444

4545
pub fn save_session(repo_path: &str, state: &SessionState) {
4646
let path = session_path(repo_path);
47-
if let Some(dir) = path.parent()
48-
&& let Err(e) = std::fs::create_dir_all(dir)
49-
{
50-
tracing::warn!("failed to create session directory: {e}");
47+
if let Some(dir) = path.parent() {
48+
if let Err(e) = std::fs::create_dir_all(dir) {
49+
tracing::warn!("failed to create session directory: {e}");
50+
}
51+
// Drop a self-ignoring `.gitignore` inside `.nightcrow/` so the
52+
// session file never pollutes the user's `git status`. Only write
53+
// when missing — a user-edited file should not be clobbered.
54+
let gi = dir.join(".gitignore");
55+
if !gi.exists()
56+
&& let Err(e) = std::fs::write(&gi, "*\n")
57+
{
58+
tracing::warn!("failed to write nightcrow gitignore: {e}");
59+
}
5160
}
5261
let text = match serde_json::to_string(state) {
5362
Ok(t) => t,

0 commit comments

Comments
 (0)