From 8493e6ad92447bb836930e78b2f6bbb45a710443 Mon Sep 17 00:00:00 2001
From: Andreas Jaeger <aj@suse.com>
Date: Tue, 2 Jan 2018 19:41:58 +0100
Subject: [PATCH] Fix sphinx publishing

Since change I9ed0b02d6ca20a6b679507c4d988531abc55b09d merged, we were
publishing to docs.o.o/$project/latest/html instead of
docs.o.o/$project/latest . We need to remove the final html part when
using rsync. Add an option to allow appending "/" to sphinx_output_src
so that rsync copies the content without the final html.

Change-Id: I0eed5ebf5af8d43f6a105a1fc0dcf1b0a9813dbd
---
 roles/fetch-sphinx-output/README.rst         | 9 ++++++++-
 roles/fetch-sphinx-output/defaults/main.yaml | 3 ++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/roles/fetch-sphinx-output/README.rst b/roles/fetch-sphinx-output/README.rst
index 6f658691e..3f84dd994 100644
--- a/roles/fetch-sphinx-output/README.rst
+++ b/roles/fetch-sphinx-output/README.rst
@@ -16,8 +16,15 @@ to the log root of the executor.
 
    Directory relative to zuul_work_dir where build output will be put.
 
+.. zuul:rolevar:: sphinx_output_suffix
+   :default: ''
+
+   Suffix to use for constructing the path. This is normally an
+   empty string. If set to '/' then, rsync will remove the last part
+   from the original path.
+
 .. zuul:rolevar:: sphinx_output_src
-   :default: {{ zuul_work_dir }}/{{ sphinx_build_dir }}/html
+   :default: {{ zuul_work_dir }}/{{ sphinx_build_dir }}/html{{ sphinx_output_suffix }}
 
    The location on the worker from which to fetch the generated sphinx
    content.  By default, the HTML doc build dir of the current
diff --git a/roles/fetch-sphinx-output/defaults/main.yaml b/roles/fetch-sphinx-output/defaults/main.yaml
index ca077c601..33c0a57e2 100644
--- a/roles/fetch-sphinx-output/defaults/main.yaml
+++ b/roles/fetch-sphinx-output/defaults/main.yaml
@@ -2,4 +2,5 @@
 zuul_executor_dest: "{{ zuul.executor.log_root }}"
 zuul_work_dir: "{{ zuul.project.src_dir }}"
 sphinx_build_dir: doc/build
-sphinx_output_src: "{{ zuul_work_dir }}/{{ sphinx_build_dir }}/html"
+sphinx_output_suffix: ""
+sphinx_output_src: "{{ zuul_work_dir }}/{{ sphinx_build_dir }}/html{{ sphinx_output_suffix }}"