From ac0073e2e09325bb0de5e47d1e4abf67465f3b92 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Tue, 22 Sep 2020 09:44:28 -0500 Subject: [PATCH] Fix detection of git submodules --- sphinx_multiversion/git.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sphinx_multiversion/git.py b/sphinx_multiversion/git.py index 331022b3..3be16e48 100644 --- a/sphinx_multiversion/git.py +++ b/sphinx_multiversion/git.py @@ -21,9 +21,13 @@ def get_toplevel_path(cwd=None): "git", "rev-parse", "--show-toplevel", + "--show-superproject-working-tree", ) output = subprocess.check_output(cmd, cwd=cwd).decode() - return output.rstrip("\n") + # If this is a git submodule of a super project then we'll have two lines + # of output, otherwise one. Since the superproject flag is second in the + # command above the superproject will always be the last line if present. + return output.split()[-1] def get_all_refs(gitroot):