From c1f4e7c52f71d292d62de496f8229fb130767335 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Tue, 10 Sep 2013 10:04:11 +0200 Subject: [PATCH] Do not build all books if only www/ is changed We do not validate the contents of www/ directory and if only files in it get updated, all the books get build. Let's do a quick exit for the case of changing only www/. Change-Id: I05fd5ae58f9351d3d78788f4fe5bbb1e082fb183 --- validate.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/validate.py b/validate.py index 70975395..cf9b469d 100755 --- a/validate.py +++ b/validate.py @@ -135,6 +135,24 @@ def error_message(error_log): errs.reverse() return "\n".join(errs) +# Check whether only files in www got updated +def only_www_touched(): + try: + args = ["git", "diff", "--name-only", "HEAD", "HEAD~1"] + modified_files = check_output(args).strip().split() + except (CalledProcessError, OSError) as e: + print("git failed: %s" % e) + sys.exit(1) + + www_changed = False + other_changed = False + for f in modified_files: + if f.startswith("www/"): + www_changed = True + else: + other_changed = True + + return www_changed and not other_changed def get_modified_files(): try: @@ -345,6 +363,10 @@ def main(rootdir, force): if force: print("Validation of all files and build of all books will be forced.") + if not force and only_www_touched(): + print("Only files in www directory changed, no validation done.") + return + check_deleted_files(rootdir, FILE_EXCEPTIONS) validate_individual_files(rootdir, FILE_EXCEPTIONS, force) build_affected_books(rootdir, BOOK_EXCEPTIONS, FILE_EXCEPTIONS, force)