Skip to content

Commit b9f2bed

Browse files
committed
Don't rely on git failing on non-git folders (it may find a repo, lower in the hierarchy, typically while testing).
1 parent 1a15281 commit b9f2bed

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

build_docs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ def git_clone(repository, directory, branch=None):
123123
"""
124124
logging.info("Updating repository %s in %s", repository, directory)
125125
try:
126+
if not os.path.isdir(os.path.join(directory, '.git')):
127+
raise AssertionError("Not a git repository.")
126128
if branch:
127129
shell_out(['git', '-C', directory, 'checkout', branch])
128130
shell_out(['git', '-C', directory, 'pull', '--ff-only'])
129-
except subprocess.CalledProcessError:
131+
except (subprocess.CalledProcessError, AssertionError):
130132
if os.path.exists(directory):
131133
shutil.rmtree(directory)
132134
logging.info("Cloning %s into %s", repository, directory)

0 commit comments

Comments
 (0)