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

Remove Unable to find a git directory and/or git is not installed warning on local only builds #58

Closed
aphive opened this issue Aug 22, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@aphive
Copy link

aphive commented Aug 22, 2021

When working on a local only docs site, is there a way to not let this warning show up? When you get to having many pages it becomes a useless nuisance as we already know there is no git configuration set.

@timvink
Copy link
Owner

timvink commented Sep 3, 2021

Hi @aphive.

So you have a local docs folder that is not under version control (not a git repo). Because you're getting a warning instead of an error, that means you have fallback_to_build_date enabled in your mkdocs.yml

except (InvalidGitRepositoryError, NoSuchPathError) as err:
if self.config.get('fallback_to_build_date'):
logger.warning(
"[git-revision-date-localized-plugin] Unable to find a git directory and/or git is not installed."
" Option 'fallback_to_build_date' set to 'true': Falling back to build date"
)
commit_timestamp = time.time()

I am wondering what your use case is, and what the best solution then would be. I see two:

  1. You're developing locally but intend to publish to an environment with git later. This plugin could have a new option to disable itself using an environment variable (for which mkdocs 1.2 adds really nice support https://www.mkdocs.org/user-guide/configuration/#environment-variables), so it will only be disabled when you have a specific env var setup.

  2. The actual behaviour you want is not the revision date but the last build date (last time mkdocs serve or mkdocs build was run). You want that behaviour without the warnings. In that case, a new option suppress_warnings would be probably be the most elegant solution to accomodate your use case.

Also wondering if commenting out the plugin in your mkdocs.yml while developing locally would be an option?

Let me know what you think!

@timvink timvink added the enhancement New feature or request label Sep 3, 2021
@aphive
Copy link
Author

aphive commented Sep 10, 2021

Thanks for the feedback. I think having both option 1 and 2 option to suppress_warnings would be the right way to go. Option one would serve best for cases where builds do take advantage of the env variable and option two would serve for cases where no other env will be used.

For the time being, I can work with the plugin disabled. Wondering tho if there could potential missed issues due to no warning showing.

timvink added a commit that referenced this issue Sep 11, 2021
timvink added a commit that referenced this issue Sep 11, 2021
@timvink
Copy link
Owner

timvink commented Sep 11, 2021

I've added a new enabled option in v.0.10.0, that you can use with environment variables (see docs). Because you can use fallbacks, I think that should be sufficient. I agree that adding suppress_warnings could cause missing potentially missed issues --> probably not a good design choice.

@timvink timvink closed this as completed Sep 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants