From 5f87f2f1b3592ba4a20b36d1b8a49b79e77af631 Mon Sep 17 00:00:00 2001 From: Markku Riekkinen Date: Thu, 29 Jun 2023 17:28:08 +0300 Subject: [PATCH] Keep the .git directory in the local course build testing setup Since `git clean` is run at the end of the course build nowadays, it caused a crash in the local testing setup when `settings.LOCAL_COURSE_SOURCE_PATH` is used. It crashed because the course directory was missing the `.git` directory and thus, it was not a git repository. The build error was the following: ``` stdout: fatal: not a git repository (or any parent up to mount point /tmp) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set) ``` Fix the crash by including the `.git` directory when the course source directory is copied to the build directory. The `.git` directory used to be excluded simply because the copy operation is a bit faster without it. --- builder/builder.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/builder/builder.py b/builder/builder.py index 945f616..2920e45 100644 --- a/builder/builder.py +++ b/builder/builder.py @@ -571,14 +571,8 @@ def build_course( path = CourseConfig.local_source_path_to(course_key) build_logger.debug(f"Course origin not set: copying the course sources from {path} to the build directory.") - def ignore_func(directory, contents): - # Do not copy the .git directory in shutil.copytree(). - if '.git' in contents: - return ('.git',) - return () - shutil.rmtree(build_path, ignore_errors=True) - shutil.copytree(path, build_path, symlinks=True, ignore=ignore_func) + shutil.copytree(path, build_path, symlinks=True) else: build_logger.warning(f"Course origin not set: skipping git update\n")