mkdocs-git-authors-plugin icon indicating copy to clipboard operation
mkdocs-git-authors-plugin copied to clipboard

Problems with git-authors on submodules

Open leandrolerena opened this issue 1 year ago • 1 comments

Hi again @timvink

I wanted to follow-up on https://github.com/timvink/mkdocs-git-authors-plugin/issues/79

I discovered that the git-revision-date-localized plugin (also yours, nice work!) works fine with submodules with the monorepo plugin.

Why does one work and the other not? Could this give some valuable insight on how to solve the issue with monorepo?

leandrolerena avatar Mar 25 '24 10:03 leandrolerena

I will chime in here to say that we just noticed that the git-authors plugin doesn't pull the authors information from the submodules even without using the monorepo plugin. We were investigating using one of:

  • the monorepo-plugin
  • the multirepo-plugin but specifically didn't want the maintenance burden of maintaining the nav sections. We ended up forgoing both plugins and just using the submodules with the mkdocs-material theme which, I think, gets us the compromise we need between maintenance burden and usability.

All that to say that we're using mkdocs material with straight submodules and the git-authors plugin doesn't pull the authors, but the git-revision-date-localized does work as stated.

Edit: I just noticed this on the roadmap thread and wondering if this is the difference in one working while the other doesn't:

mkdocs-git-authors-plugin uses it's own implementation around git (very elegantly written by
@uliska), making it light weight on dependencies. mkdocs-git-revision-date-localized-plugin
however uses GitPython, and several other large dependencies like babel, so is not lightweight.

mckraken avatar Jun 10 '25 02:06 mckraken

There is a relative easy fix i found out to accept also submodules. Under the hood git blame is used. But the command is not working when executed from the superproject folder. If the working directory is specified as the absolute path (which is within an arbitary submodule) through "git -C path/to/file/within/submodule_folder blame file_name --porcelain..." it is working. Also monorepo is working with it now. (although not tested much)

So I modified within page.py:

def _process_git_blame(self) -> None:

....

########### ADDED THIS LINES to handle submodules
# (git blame is only working within submodules, when the git command is executed within the submodules folder)
args.append(str(self._path.parent.absolute()))
args.append("blame")
args.append(self._path.name)
################################

if self.repo().config("ignore_commits"):
    args.append("--ignore-revs-file")
    args.append(self.repo().config("ignore_commits"))
args.append("--porcelain")
args.append("-w")  # Ignore whitespace changes

########### CHANGED THIS LINE to handle submodules
cmd = GitCommand("-C", args) # Fix handle submodules by specifying the working directory
##############################

cmd.run()

m-vik avatar Jul 08 '25 12:07 m-vik

Thanks for the investigation. To be honest I haven't been very active with mkdocs for a while now.

Why does one work and the other not?

We never explicitly supported git submodules in this plugin. And revision date has some specific fixes to add support monorepo, like https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/pull/185/files

@m-vik that looks promising. Would you mind taking a try at a PR?

timvink avatar Jul 08 '25 20:07 timvink

Also would like this capability

legoguy1000 avatar Sep 15 '25 14:09 legoguy1000