From fc893078c4b51f2d9e5c46245fcd5d6e5e6c51e5 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 1 Aug 2016 12:35:31 -0500 Subject: [PATCH] Fix check_attributes_yml to respect content in subdirectories --- course/content.py | 21 ++++++++++++++------- course/validation.py | 3 +++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/course/content.py b/course/content.py index fbf2c25d..2e0f65b9 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 7aadb27b..376aa068 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: -- GitLab