Enhancing product doc sync script
Now it manages the git branch and commits to the repo
@@ -30,9 +30,26 @@ convert_doc_extensions() {
sed -e '/development.md/! s/\.md[[:>:]]/.html/g' -e'/development.md/! s@\./docs/@./@g'
}
+reset_repo() {
+ if ! git -C $PRODUCT_DOCS_REPO diff --exit-code; then
+ echo "Product docs repo has uncommitted changes, please deal with them first" >&2
+ exit 1
+ fi
+
+ git -C $PRODUCT_DOCS_REPO fetch origin
+ git -C $PRODUCT_DOCS_REPO checkout smart-agent
+ # If there aren't any pending commits in the smart-agent branch, then reset
+ # with the latest master first
+ if [[ -z "$(git cherry -v origin/master origin/smart-agent)" ]]; then
+ git -C $PRODUCT_DOCS_REPO reset --hard origin/master
+ fi
+}
+
[ -d $PRODUCT_DOCS_REPO ] || \
(echo "product-docs repo dir cannot be found at $PRODUCT_DOCS_REPO; please set \$PRODUCT_DOCS_REPO" && exit 1)
+reset_repo
+
mkdir -p $AGENT_PRODUCT_DOCS/{monitors,observers}
for f in $(find $AGENT_REPO_BASE/docs -name "*.md"); do
@@ -92,3 +109,6 @@ header_comment | \
convert_relative_links \
> $AGENT_PRODUCT_DOCS/overview.rst
+git -C $PRODUCT_DOCS_REPO add $PRODUCT_DOCS_REPO
+git -C $PRODUCT_DOCS_REPO commit
+git -C $PRODUCT_DOCS_REPO push
