eleventy-plugin-git-commit-date
eleventy-plugin-git-commit-date copied to clipboard
feat: filter commits by message
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
--followto follow renames. If no options are provided, roughly the same speed. - I didn't use the git log
--grepoption, since it is buggy in conjunction with--follow. The workaround implemented is to grab all commits (no-1flag) and manually filter with JS.