]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
ceph-docs: Verify push contains docs files; don't build if not 664/head
authorDan Mick <dan.mick@redhat.com>
Tue, 14 Mar 2017 20:53:53 +0000 (13:53 -0700)
committerDan Mick <dan.mick@redhat.com>
Wed, 15 Mar 2017 21:35:33 +0000 (14:35 -0700)
Signed-off-by: Dan Mick <dan.mick@redhat.com>
ceph-docs/build/build

index 888b128022c1f7a39a04da0eb83e7d34ff3374df..01a72095ac8c6f528e69651f02944192ebf3f11f 100644 (file)
@@ -2,6 +2,22 @@
 
 set -ex
 
+# did any doc/ files change?  
+# This assumes $GIT_COMMIT is a merge commit (it is usually, because that's how
+# we manage ceph, with PRs that include merges).  So, noting the three dots,
+# this git diff invocation compares the common ancestor between first parent
+# (original state of the branch) to the second parent (the branch being merged
+# in) i.e., same as git diff $(git merge-base p1 p2) p2 and outputs filenames
+# only (--name-only)
+
+# enclosing doublequotes prevent newlines from disappearing, for grep below
+files="$(git diff --name-only ${GIT_COMMIT}^1...${GIT_COMMIT}^2)"
+echo -e "changed files:\n$files"
+if ! (echo "$files" | grep -sq '^doc/'); then
+       echo "No doc files changed, skipping build"
+       exit 0
+fi
+
 ./admin/build-doc
 
 REV="$(git rev-parse HEAD)"