git-blame-ignore-revs-linter
v1.1.0
Published
Check for semantic issues in `.git-blame-ignore-revs` -- wrong commit, duplicates, etc.
Readme
.git-blame-ignore-revs linter
Check for semantic and opinionated issues in Git skip-list formatted files used by git blame --ignore-revs-file.
Usage
Through
npxnpx git-blame-ignore-revs-linterThrough npm
scriptsnpm install -D git-blame-ignore-revs-linter{ "scripts": { "check": "git-blame-ignore-revs" } }Through code
npm install git-blame-ignore-revs-linterimport fs from 'fs/promises'; import { lint } from 'git-blame-ignore-revs-linter'; await lint( dir, (await fs.readFile('.git-blame-ignore-revs', 'utf8')).split('\n') );See src/cli.ts for another code example
Checks
Commit not in repository
A non-existent commit doesn't alter behavior, adds noise to the file,
and is likely a mistake. Rebasing previous commits could invalidate
commits already in the .git-blame-ignore-revs, for example.
Given a Git history of:
$ git log
commit 6c29e5b0d2f83e03ce2320cd7ea445465e4bfc9f (HEAD -> main)
Author: Dale Cooper <[email protected]>
Date: Thu Jul 6 21:38:54 2023 -0500
do somethingAnd a .git-blame-ignore-revs of:
# run formatter
e4ded84c354e6be25aa073bdd3b43e8dc962b1ccWe'd get:
$ npx git-blame-ignore-revs
line 2: not found in repository (e4ded84c354e6be25aa073bdd3b43e8dc962b1cc)
run formatterCommit duplicated
A duplicate doesn't alter behavior and adds noise to the file.
Given a Git history of:
$ git log
commit 6c29e5b0d2f83e03ce2320cd7ea445465e4bfc9f (HEAD -> main)
Author: Dale Cooper <[email protected]>
Date: Thu Jul 6 21:38:54 2023 -0500
do somethingAnd a .git-blame-ignore-revs of:
# run formatter
71d5077ff1b80cb377dcec30d64c31c78c3accfc
# run formatter again
9b183f9ce24a93cfe1d6b16a3ef0902d9672c121
# something else!
71d5077ff1b80cb377dcec30d64c31c78c3accfcWe'd get:
$ npx git-blame-ignore-revs
line 6: duplicate entry (71d5077ff1b80cb377dcec30d64c31c78c3accfc)Malformed commit
Given a Git history of:
$ git log
commit 6c29e5b0d2f83e03ce2320cd7ea445465e4bfc9f (HEAD -> main)
Author: Dale Cooper <[email protected]>
Date: Thu Jul 6 21:38:54 2023 -0500
do somethingAnd a .git-blame-ignore-revs of:
6c29e5b0d2f83e03ce2320cd7ea445465e4bfc9f
# no go
main
# also a no go
v1.0We'd get:
$ npx git-blame-ignore-revs
line 3: not a valid commit (main)
line 5: not a valid commit (v1.0)