Skip to content

Commit

Permalink
fix: ensure gitignore entries are relative to root (#54)
Browse files Browse the repository at this point in the history
problem:
```.gitignore
treefmt.toml
```
can't be added: some/path/treefmt.toml

solution:
```.gitignore
/treefmt.toml
```

qed
  • Loading branch information
blaggacao committed May 4, 2023
1 parent d686345 commit 1da60ad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/hooks/link.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ in
then
touch .gitignore
fi
if ! grep -qF "${output}" .gitignore
if ! grep -qF "/${output}" .gitignore
then
if ! grep -qF "${gitignore-sentinel}" .gitignore
then
echo -e "\n# nixago: ${gitignore-sentinel}" >> .gitignore
fi
newgitignore="$(awk '1;/${gitignore-sentinel}/{ print "${output}"; }' .gitignore)"
newgitignore="$(awk '1;/${gitignore-sentinel}/{ print "/${output}"; }' .gitignore)"
echo -e -n "$newgitignore" > .gitignore
git add .gitignore
log "${ansi.bold}${ansi."11"}'${output}' added to .gitignore${ansi.reset}"
log "${ansi.bold}${ansi."11"}'/${output}' added to .gitignore${ansi.reset}"
fi
''

0 comments on commit 1da60ad

Please sign in to comment.