diff --git a/test.py b/test.py index 9c3db7b7..978fb32a 100755 --- a/test.py +++ b/test.py @@ -166,6 +166,25 @@ def only_www_touched(): return www_changed and not other_changed +# Check whether only files in www got updated +def ha_guide_touched(): + """Check whether files in high-availability-guide directory are touched""" + + try: + args = ["git", "diff", "--name-only", "HEAD~1", "HEAD"] + modified_files = check_output(args).strip().split() + except (subprocess.CalledProcessError, OSError) as e: + print("git failed: %s" % e) + sys.exit(1) + + ha_changed = False + for f in modified_files: + if f.startswith("doc/high-availability-guide/"): + ha_changed = True + + return ha_changed + + def get_modified_files(rootdir, filtering=None): """Get modified files below doc directory""" @@ -457,10 +476,16 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions, os.chdir(root) + # ha-guide uses asciidoc which we do not track. + # Just check whether any file is touched in that directory + if root.endswith('doc/high-availability-guide'): + if ha_guide_touched(): + affected_books.append(book_root) + # We can scan only for depth of one of inclusion # therefore skip the common directory since there's no # book build in it. - if not root.endswith('doc/common'): + elif not root.endswith('doc/common'): for f in files: if (f.endswith('.xml') and f != 'pom.xml' and diff --git a/validate.py b/validate.py index 8a4ec3fb..5aef09dd 100755 --- a/validate.py +++ b/validate.py @@ -169,6 +169,24 @@ def only_www_touched(): return www_changed and not other_changed +def ha_guide_touched(): + """Check whether files in high-availability-guide directory are touched""" + + try: + args = ["git", "diff", "--name-only", "HEAD~1", "HEAD"] + modified_files = check_output(args).strip().split() + except (subprocess.CalledProcessError, OSError) as e: + print("git failed: %s" % e) + sys.exit(1) + + ha_changed = False + for f in modified_files: + if f.startswith("doc/high-availability-guide/"): + ha_changed = True + + return ha_changed + + def get_modified_files(rootdir, filtering=None): """Get modified files below doc directory""" @@ -449,6 +467,12 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions, force): os.chdir(root) + # ha-guide uses asciidoc which we do not track. + # Just check whether any file is touched in that directory + if root.endswith('doc/high-availability-guide'): + if ha_guide_touched(): + affected_books.append(book_root) + # We can scan only for depth of one of inclusion # therefore skip the common directory since there's no # book build in it.