jimporter / mike

Manage multiple versions of your MkDocs-powered documentation via Git
BSD 3-Clause "New" or "Revised" License
511 stars 45 forks source link

"Nice to have" FR: a way to do the equivalent of `git show --stat` *if* a commit is created #189

Closed ilyagr closed 8 months ago

ilyagr commented 8 months ago

What I want is easy to achieve if calling mike with --allow-empty, since a commit is always created in this case:

mike deploy --allow-empty ...
git show --stat gh-pages

However, it'd be nice if I could get a correct response even without --allow-empty:

Alternatively, this could be something like:

mike deploy --exec-on-commit-creation "git show --stat gh-pages"
jimporter commented 8 months ago

I assume your goal is to show the result of git show --stat only if mike actually generated a commit? In that case, just compare the Git SHA before and after you run mike, e.g. something like this:

OLD_REV=`git rev-parse gh-pages`
mike deploy ...
if [ "$OLD_REV" != "`git-rev-parse gh-pages`" ]; then
  git show --stat gh-pages
fi

This could possibly be handled via #161, but I don't intend to add anything that directly supports this in mike. It's rather specialized, and I'd prefer to avoid adding any more new features to mike unless they're extremely important; it's already quite a bit more complex than I'd ever intended.

ilyagr commented 8 months ago

Fair enough.

Originally, I was concerned about preserving the error code if I went with the script you suggested, but on second thought, that could be fixed with the appropriate sh option (set -x, I think).

Thanks for taking a look!

jimporter commented 8 months ago

Not a problem! And like I said, it might be possible to address this in a different way via a plugin system. I think that would cover most cases where people want to hook into various parts of what mike does internally.