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

Feature request: exclude specific commits when calculating the 'last update' calculation #113

Open
markszabo opened this issue Apr 6, 2023 · 3 comments

Comments

@markszabo
Copy link

In our usage it sometimes happens that we need to make changes to many/all markdown files at once, e.g. running a formatter, or when the name of an internal product or team changes. We would like to exclude these changes from the 'last update' calculation, as they don't mean that the content was actually checked and actualized (but merely that someone run a search and replace over the entire repo). This doesn't happen that often, so we have a limited number of these commits (less than 5).

Thus I'd like to propose a new config option called exclude_commits as a list of commit ids that should not be considered when calculating the last update time, e.g.

plugins:
  - git-revision-date-localized:
      exclude_commits:
          - 6150fad
          - 7d89e01
          - e7f82de

If this sounds like something you would accept to be part of the plugin, I'm happy to send a PR with the implementation and doc update.

@timvink
Copy link
Owner

timvink commented Apr 6, 2023

That would be a nice addition. I'd prefer to this outside of the plugin if possible.

For example, for git-authors the main command it git blame, and there you have the option to specify a file with commit hashes to ignore (see timvink/mkdocs-git-authors-plugin#71) for details.

Preferably I would like a similar approach for this plugin (which uses git log, see below). A quick glance at the docs for git log show this isn't possible.

# Latest commit touching a specific file
commit_timestamp = git.log(
realpath, date="unix", format="%at", n=1, no_show_signature=True
)

Do you already have a specific approach in mind?

@timvink
Copy link
Owner

timvink commented Apr 6, 2023

The --exclude parameter (https://git-scm.com/docs/git-log#Documentation/git-log.txt---excludeltglob-patterngt) seems promising

Going through this blogpost, it seems we could add a .git-log-exclude to the root of a project, container a list of commit hashes.

Update: from the blogpost, it also requires setting a global or local git config option (something like git config log.exclude .git-log-exclude). That's something to be aware of when collaborating with a team on documentation, or when setting up your CI/CD build.

If that works, we would only need to update the documentation with an additional 'how to' page.

@markszabo
Copy link
Author

Thanks for the quick reply! I played around with the options (including the one you suggested), but didn't find anything that would work. The closest I could get is to exclude certain commits by commit message, but even this requires cli parameters and doesn't seem to be configurable via the git config:

git log --oneline --invert-grep --grep='Update team name' docs/index.md

Meanwhile my colleague implemented this feature and will send a PR after testing it.

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

No branches or pull requests

2 participants