diff --git a/course/content.py b/course/content.py index fbf2c25d368985c1be5419b7162b50c2231d64b7..2e0f65b9a6a67e2cdf5e3813f37f718d745a2928 100644 --- a/course/content.py +++ b/course/content.py @@ -66,6 +66,19 @@ class SubdirRepoWrapper(object): self.repo.close() +def get_true_repo_and_path(repo, path): + if isinstance(repo, SubdirRepoWrapper): + if path: + path = repo.subdir + "/" + path + else: + path = repo.subdir + + return repo.repo, path + + else: + return repo, path + + def get_course_repo_path(course): from os.path import join return join(settings.GIT_ROOT, course.identifier) @@ -88,13 +101,7 @@ def get_repo_blob(repo, full_name, commit_sha, allow_tree=True): :arg allow_tree: Allow the resulting object to be a directory """ - if isinstance(repo, SubdirRepoWrapper): - if full_name: - full_name = repo.subdir + "/" + full_name - else: - full_name = repo.subdir - - repo = repo.repo + repo, full_name = get_true_repo_and_path(repo, full_name) names = full_name.split("/") diff --git a/course/validation.py b/course/validation.py index 7aadb27bd6b44b32b512ff508c300cf4bd310224..376aa068ca810b5dc4946649d65bfb6acd4ad75c 100644 --- a/course/validation.py +++ b/course/validation.py @@ -1024,6 +1024,9 @@ def check_attributes_yml(vctx, repo, path, tree): - test2.pdf - 42 """ + from course.content import get_true_repo_and_path + repo, path = get_true_repo_and_path(repo, path) + try: dummy, attr_blob_sha = tree[b".attributes.yml"] except KeyError: