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
This commit is contained in:
Andreas Jaeger 2013-09-10 10:04:11 +02:00
parent 288e308873
commit c1f4e7c52f
1 changed files with 22 additions and 0 deletions

View File

@ -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)