npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

git-blame-ignore-style-formatting-post-commit-hook

v0.0.1

Published

post-commit hook to add an entry to .git-blame-ignore-revs for `style: foo` commits

Downloads

3

Readme

Automatically git-blame-ignore style tweaks

.github/workflows/github-actions.yml

A post-commit hook to add an entry to .git-blame-ignore-revs for pure formatting commits

Now you can upgrade to prettier v2 without ruining git blame!

PRs with changes to .git-blame-ignore-revs cannot squash+merge, otherwise you'll have to add more entries to .git-blame-ignore-revs in a follow up PR/commit.

What does it do, how does it work?

When you make a commit like this:

style(homepage): Sort imports

This post-commit hook will automatically add another commit like so:

chore(git-blame): Ignore previous style change

Commit message may be customized in a future version to be: chore(git-blame): Ignore "Sort imports"

You do NOT need to use commitlint or commitizen to use this hook. It simply looks for commit messages starting with style: foo. (And probably also style(foo): bar, but that may come in a future version)

Setup

npm install git-blame-ignore-style-formatting-post-commit-hook --save-dev
yarn add git-blame-ignore-style-formatting-post-commit-hook --dev

If you are using husky (recommended), create hook like so:

mkdir .husky
mv .husky/post-commit .husky/old-post-commit;
rm .husky/post-commit
npx husky add .husky/post-commit 'GIT_ROOT="$(git rev-parse --show-toplevel)"';
npx husky add .husky/post-commit '$GIT_ROOT/node_modules/.bin/git-blame-ignore-style-formatting-post-commit-hook';
npx husky add .husky/post-commit '# Directly invoking module is faster than `yarn run git-blame-ignore-style-formatting-post-commit-hook`';
npx husky add .husky/post-commit "# (which makes sense, because it's skipping yarn\!)";

If not using husky, you can use this shell script as a starting point:

HOOKS_PATH=".git-hooks"
git config core.hooksPath $HOOKS_PATH
mkdir $HOOKS_PATH;
mv $HOOKS_PATH/post-commit $HOOKS_PATH/old-post-commit;
rm $HOOKS_PATH/post-commit
touch $HOOKS_PATH/post-commit;
chmod +x $HOOKS_PATH/post-commit;
echo '#!/usr/bin/env sh' >> $HOOKS_PATH/post-commit;
echo 'GIT_ROOT="$(git rev-parse --show-toplevel)"' >> $HOOKS_PATH/post-commit;
echo '' >> $HOOKS_PATH/post-commit;
echo '$GIT_ROOT/node_modules/.bin/git-blame-ignore-style-formatting-post-commit-hook' >> $HOOKS_PATH/post-commit;
echo '# Directly invoking module is faster than `yarn run git-blame-ignore-style-formatting-post-commit-hook`' >> $HOOKS_PATH/post-commit;
echo "# (which makes sense, because it's skipping yarn\!)" >> $HOOKS_PATH/post-commit;

If you don't already have a .git-blame-ignore-revs, one will be created for you before this script attempts to write to it:

Created empty .git-blame-ignore-revs file, and preinstall script to configure git to use it.

When you make a style: commit, it will now show something like this after you commit:

Adding .git-blame-ignore-revs entry for last commit. Reason: Starts with "style:"

When/if you are rebasing, and need to refresh the sha, you can simply reword your style: commits to re-run the post-commit hook

-pick 7713c93 style: cleanup comments
-pick c2d2cf6 chore(git-blame): Ignore previous style change
+reword 7713c93 style: cleanup comments
+drop c2d2cf6 chore(git-blame): Ignore previous style change