From fbef0ea1c15edff07d4c9187da75350e593ac675 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Mon, 23 Feb 2015 14:14:52 +0100 Subject: [PATCH] Handle RST files Do not build all manuals if only RST files are changed. Change-Id: Ie0790d7bebd676c9430a4295fe4421cbd74cbd8c --- RELEASE_NOTES.rst | 6 ++++++ os_doc_tools/doctest.py | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index b4f69053..61dd29b7 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -1,6 +1,12 @@ Release notes ============= +0.23 +---- + +* ``openstack-doc-test``: Don't build all books if only RST files are + changed. + 0.22 ---- diff --git a/os_doc_tools/doctest.py b/os_doc_tools/doctest.py index 8231a2a6..7bc9c874 100755 --- a/os_doc_tools/doctest.py +++ b/os_doc_tools/doctest.py @@ -376,6 +376,27 @@ def only_po_touched(): return locale_changed and not other_changed +def only_rst_touched(): + """Check whether only RST files are touched.""" + + try: + git_args = ["git", "diff", "--name-only", "HEAD~1", "HEAD"] + modified_files = check_output(git_args).strip().split() + except (subprocess.CalledProcessError, OSError) as e: + print("git failed: %s" % e) + sys.exit(1) + + rst_changed = False + other_changed = False + for f in modified_files: + if f.endswith(".rst"): + rst_changed = True + else: + other_changed = True + + return rst_changed and not other_changed + + def check_modified_affects_all(rootdir): """Check whether special files were modified. @@ -1571,6 +1592,10 @@ def doctest(): and only_po_touched()): print("Only files in locale directories changed, nothing to do.\n") return + # If only RST files are touched, there's nothing to do. + if (not CONF.force and only_rst_touched()): + print("Only RST files changed, nothing to do.\n") + return if CONF.check_syntax or CONF.check_niceness or CONF.check_links: if CONF.force: