From 5878a81d61dd51f0b3f1d00fa0ff937605599947 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Tue, 1 Oct 2013 22:38:53 +0200 Subject: [PATCH] Rebuild HA Guide if files modified Special case the HA Guide since it is using asciidoc. We do not check for includes and simply rebuild it whenever a file in the directory is changed. Change-Id: Ib4226a326f0d3c9f95d68950241f22f4c38c1d10 --- tools/test.py | 27 ++++++++++++++++++++++++++- tools/validate.py | 24 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/tools/test.py b/tools/test.py index 9c3db7b701..978fb32ad7 100755 --- a/tools/test.py +++ b/tools/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/tools/validate.py b/tools/validate.py index 8a4ec3fba3..5aef09dde7 100755 --- a/tools/validate.py +++ b/tools/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.