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:
parent
4fd1902248
commit
92293619ff
@ -135,6 +135,24 @@ def error_message(error_log):
|
|||||||
errs.reverse()
|
errs.reverse()
|
||||||
return "\n".join(errs)
|
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():
|
def get_modified_files():
|
||||||
try:
|
try:
|
||||||
@ -345,6 +363,10 @@ def main(rootdir, force):
|
|||||||
if force:
|
if force:
|
||||||
print("Validation of all files and build of all books will be forced.")
|
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)
|
check_deleted_files(rootdir, FILE_EXCEPTIONS)
|
||||||
validate_individual_files(rootdir, FILE_EXCEPTIONS, force)
|
validate_individual_files(rootdir, FILE_EXCEPTIONS, force)
|
||||||
build_affected_books(rootdir, BOOK_EXCEPTIONS, FILE_EXCEPTIONS, force)
|
build_affected_books(rootdir, BOOK_EXCEPTIONS, FILE_EXCEPTIONS, force)
|
||||||
|
Loading…
Reference in New Issue
Block a user