Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: filter commits by message #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

TrebledJ
Copy link

@TrebledJ TrebledJ commented Jun 26, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant