Skip to content

Bug: auto-loaded last_updated_by_git causes failure in non-git environments #109

@tang-mm

Description

@tang-mm

Description

canonical-sphinx auto-enables the sphinx_last_updated_by_git package if it's present in the venv, even when it's not added to the user extension list. When running build in non-git environments, this causes build warnings. For doc projects with --failed-on-warning enabled, it results in build failures.

This could happen in:

  • builds in a Docker container without .git directory
  • builds from the source tarball

Expected Behavior

User settings in conf.py be able to prevent sphinx_last_updated_by_git from loading and running.

Cause

When using sphinx-sitemap extension, it installs sphinx_last_updated_by_git as a hard dependency and provides the sitemap_show_lastmod flag in conf.py to toggle the features.

However, because canonical-sphinx detects that the package is installed in the venv (config.py), it auto-loads the package during doc build even if it's not added as a project extension in conf.py. This behavior forces Sphinx builds to check for git history, and cannot be disabled by setting sitemap_show_lastmod=False.

Steps to Reproduce

  1. Create a starter-pack project without .git directory (e.g. by renaming the .git or copying the docs/ dir outside the git project)
  2. Remove sphinx_last_updated_by_git from the requirement list and extension list in conf.py, but keep sphinx-sitemap.
  3. Set sitemap_show_lastmod=False in conf.py
  4. Re-run make install and make html

Output:

getting Git timestamps for source files... [100%] .
getting Git timestamps for dependencies... [100%] 

WARNING: Error getting data from Git (no "last updated" dates will be shown for source files from <path>/docs/explanation):
fatal: not a git repository (or any of the parent directories): .git

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions