Skip to content

Commit

Permalink
fix: Only update .gitignore when a link is indeed created (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
Atry authored Apr 25, 2024
1 parent dacceb1 commit 5133633
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions lib/hooks/link.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,25 @@ in
# Run extra shell hook
extra_hook
# Add this output to gitignore if not already
if ! test -f .gitignore
then
touch .gitignore
fi
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)"
echo -e -n "$newgitignore" > .gitignore
git add .gitignore
log "${ansi.bold}${ansi."11"}'/${output}' added to .gitignore${ansi.reset}"
fi
else
# this was an existing file
error "refusing to overwrite '${output}'"
fi
# Add this output to gitignore if not already
if ! test -f .gitignore
then
touch .gitignore
fi
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)"
echo -e -n "$newgitignore" > .gitignore
git add .gitignore
log "${ansi.bold}${ansi."11"}'/${output}' added to .gitignore${ansi.reset}"
fi
''

0 comments on commit 5133633

Please sign in to comment.