diff --git a/README.md b/README.md index 3f500b0..cab92b5 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ pip install md2cf ```text usage: md2cf [-h] [-o HOST] [-u USERNAME] [-p PASSWORD] [--token TOKEN] [--insecure] [-s SPACE] [-a PARENT_TITLE | -A PARENT_ID] - [-t TITLE] [-m MESSAGE] [-i PAGE_ID] [--prefix PREFIX] - [--strip-top-header] [--remove-text-newlines] + [-t TITLE] [-m MESSAGE] [--minor-edit] [-i PAGE_ID] + [--prefix PREFIX] [--strip-top-header] [--remove-text-newlines] [--replace-all-labels] [--preface-markdown [PREFACE_MARKDOWN] | --preface-file PREFACE_FILE] [--postface-markdown [POSTFACE_MARKDOWN] | --postface-file @@ -159,6 +159,8 @@ Uploading a page with the same title twice will update the existing one. If you want to update a page by page ID, use the `--page-id` option. This allows you to change the page's title, or to update a page with a title that is annoying to use as a parameter. +With the `--minor-edit` option you can prevent notifications being sent to watcher of the page. This corresponds to the "Notify watchers" checkbox when editing pages manually. + ### Avoiding uploading content that hasn't changed If you want to avoid redundant uploads (and the corresponding update emails) when your content hasn't changed, you can add the `--only-changed` option. Note that this will store a hash of the page/attachment contents at the end of the version update message. diff --git a/md2cf/__main__.py b/md2cf/__main__.py index 0dd2095..032a6d2 100644 --- a/md2cf/__main__.py +++ b/md2cf/__main__.py @@ -84,6 +84,9 @@ def get_parser(): help="a title for the page. Determined from the document if missing", ) page_group.add_argument("-m", "--message", help="update message for the change") + page_group.add_argument( + "--minor-edit", action="store_true", help="do not notify watchers of change" + ) page_group.add_argument("-i", "--page-id", help="ID of the page to be updated") page_group.add_argument( "--prefix", @@ -227,6 +230,7 @@ def upsert_page( page: md2cf.document.Page, only_changed: bool = False, replace_all_labels: bool = False, + minor_edit: bool = False, ): existing_page = confluence.get_page( title=page.title, @@ -303,6 +307,7 @@ def upsert_page( parent_id=page.parent_id, update_message=page_message, labels=page.labels if replace_all_labels else None, + minor_edit=minor_edit, ) if not replace_all_labels and page.labels: @@ -477,6 +482,7 @@ def main(): page=page, only_changed=args.only_changed, replace_all_labels=args.replace_all_labels, + minor_edit=args.minor_edit, ) except HTTPError as e: sys.stderr.write("{} - {}\n".format(str(e), e.response.content)) diff --git a/md2cf/api.py b/md2cf/api.py index ed5b938..a31d6ee 100644 --- a/md2cf/api.py +++ b/md2cf/api.py @@ -106,10 +106,19 @@ def create_page( return self.api.content.post(json=page_structure) - def update_page(self, page, body, parent_id=None, update_message=None, labels=None): + def update_page( + self, + page, + body, + parent_id=None, + update_message=None, + labels=None, + minor_edit=False, + ): update_structure = { "version": { "number": page.version.number + 1, + "minorEdit": minor_edit, }, "title": page.title, "type": "page", diff --git a/tests/unit/test_confluence.py b/tests/unit/test_confluence.py index cd99259..d00add5 100644 --- a/tests/unit/test_confluence.py +++ b/tests/unit/test_confluence.py @@ -260,9 +260,7 @@ def test_update_page(confluence): test_new_body = "

This is my new body

" update_structure = { - "version": { - "number": test_page_version + 1, - }, + "version": {"number": test_page_version + 1, "minorEdit": False}, "title": test_page_title, "type": "page", "body": {"storage": {"value": test_new_body, "representation": "storage"}}, @@ -292,7 +290,11 @@ def test_update_page_with_message(confluence): test_new_body = "

This is my new body

" update_structure = { - "version": {"number": test_page_version + 1, "message": test_page_message}, + "version": { + "number": test_page_version + 1, + "message": test_page_message, + "minorEdit": False, + }, "title": test_page_title, "type": "page", "body": {"storage": {"value": test_new_body, "representation": "storage"}},