Skip to content

Commit

Permalink
Keep the .git directory in the local course build testing setup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
markkuriekkinen committed Jun 29, 2023
1 parent ad23787 commit 5f87f2f
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 5f87f2f

Please sign in to comment.