fralau / mkdocs-macros-plugin

Create richer and more beautiful pages in MkDocs, by using variables and calls to macros in the markdown code.
https://mkdocs-macros-plugin.readthedocs.io
Other
318 stars 50 forks source link

Add a short_tag attribute to git context #183

Closed marcospereira closed 10 months ago

marcospereira commented 10 months ago

What?

Fixes #184.

This adds a short_tag attribute to the git context. It WILL NOT interfere with the changes made to fix #143 since there is no "manual' manipulation of the full tag description, but instead, it uses git itself to get the short name.

From git describe --help:

The command finds the most recent tag that is reachable from a commit. If the tag points to the commit, then only the tag is shown. Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object and the abbreviated object name of the most recent commit. The result is a "human-readable" object name which can also be used to identify the commit to other git commands.

And later, when describing --abbrev=0:

With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:

[torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
tags/v1.0.0

Why?

This is useful when showing latest release info, for example.

fralau commented 10 months ago

Hi, thanks for your contribution!

In line with the project's policy, could I ask you to open an issue detailing the problem you wish to solve (use case, etc.), and link your PR to it?

marcospereira commented 10 months ago

In line with the project's policy, could I ask you to open an issue detailing the problem you wish to solve (use case, etc.), and link your PR to it?

Done. See the linked issue. :-)

marcospereira commented 10 months ago

Hey, @fralau. Just a gentle reminder about this. Let me know if there are any changes I should make here.