eleventy-plugin-git-commit-date icon indicating copy to clipboard operation
eleventy-plugin-git-commit-date copied to clipboard

feat: filter commits by message

Open TrebledJ opened this issue 2 years ago • 0 comments

This PR adds options to getGitCommitDateFromPath which allows fine-grained filtering to select commits which (presumably) update content. This enables programmers who have ~~OCD~~ set patterns and are stringent with commit messages to select more appropriate "last modified" dates.

Example

Suppose I commit content-changes with the pattern feat: updated post. I can filter commits using

getGitCommitDateFromPath(..., { keep: /^feat:/ });

Suppose I use these other patterns: chore: updated css, bugfix: fixed logic. I can exclude these commits using:

getGitCommitDateFromPath(..., { ignore: /^(bugfix|chore):/ });

These features might be a bit niche, but I thought it'd be a nice addition to this repo, in case others were looking for something similar.

Notes

  • This only checks the commit subject, not the body.
  • Slower with options, since we use --follow to follow renames. If no options are provided, roughly the same speed.
  • I didn't use the git log --grep option, since it is buggy in conjunction with --follow. The workaround implemented is to grab all commits (no -1 flag) and manually filter with JS.

TrebledJ avatar Jun 26 '23 07:06 TrebledJ