Skip to content

Commit

Permalink
post-commit: Remove git commit from notification title.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Dec 18, 2023
1 parent 6e7260e commit 7ef0d7b
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions .hooks/post-commit
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ strip() {
notify() {
# if osascript is not supported, do nothing
if [ -f /usr/bin/osascript ]; then
# get '<SHORT_SHA> <FIRST_LINE_OF_COMMIT_MSG>'
COMMIT_INFO=$(git log --oneline -n 1 --format="%h %s")

# read back in the lint errors
# TODO: update for each tye of error
ERRORS=$(cat "$LINT_LOG" | sed 1,4d)

# Trigger apple- or OSA-script on supported platforms
/usr/bin/osascript -e "display notification \"$ERRORS\" with title \"ncu: $COMMIT_INFO: $*\""
/usr/bin/osascript -e "display notification \"$ERRORS\" with title \"$*\""
fi

# always clean up the lint output, and do not clag-up TMPDIR
# clean up
rm "$LINT_LOG"
}

Expand All @@ -35,9 +31,7 @@ if [ -z "$branch" ]; then
exit 0
fi

# Lint asynchrously, not blocking the terminal and piping all output to a file.
# IFF lint fails trigger a pop-up (on supported platforms) with at least the
# first error shown.
# We pipe output so that the terminal (tmux, vim, emacs etc.) isn't borked by
# stray output.
# Lint in the background, not blocking the terminal and piping all output to a file.
# If the lint fails, trigger a notification (on supported platforms) with at least the first error shown.
# We pipe output so that the terminal (tmux, vim, emacs etc.) isn't borked by stray output.
npm run lint:src | strip &>"$LINT_LOG" || notify "Lint Error" &

0 comments on commit 7ef0d7b

Please sign in to comment.