From 1d8e43add244a43f8df5243213b6872491550c63 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Mon, 4 Jan 2021 15:42:34 +0200 Subject: [PATCH] Add --minor-edit command-line flag --- README.md | 3 +++ main.go | 4 +++- pkg/confluence/api.go | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 84830f0..5d6c3ab 100644 --- a/README.md +++ b/README.md @@ -270,6 +270,7 @@ mark -h | --help manual edits over Confluence Web UI. - `--drop-h1` – Don't include H1 headings in Confluence output. - `--dry-run` — Show resulting HTML and don't update Confluence page content. +- `--minor-edit` — Don't send notifications while updating Confluence page. - `--trace` — Enable trace logs. - `-v | --version` — Show version. - `-h | --help` — Show help screen and call 911. @@ -284,6 +285,8 @@ password = "matrixishere" base_url = "http://confluence.local" ``` +**NOTE**: Labels aren't supported when using `minor-edit`! + # Tricks ## Continuous Integration diff --git a/main.go b/main.go index 3c44285..b295c6b 100644 --- a/main.go +++ b/main.go @@ -43,6 +43,7 @@ Options: --drop-h1 Don't include H1 headings in Confluence output. --dry-run Resolve page and ancestry, show resulting HTML and exit. --compile-only Show resulting HTML and don't update Confluence page content. + --minor-edit Don't send notifications while updating Confluence page. --debug Enable debug logs. --trace Enable trace logs. -h --help Show this screen and call 911. @@ -62,6 +63,7 @@ func main() { dryRun = args["--dry-run"].(bool) editLock = args["-k"].(bool) dropH1 = args["--drop-h1"].(bool) + minorEdit = args["--minor-edit"].(bool) ) if args["--debug"].(bool) { @@ -240,7 +242,7 @@ func main() { html = buffer.String() } - err = api.UpdatePage(target, html, meta.Labels) + err = api.UpdatePage(target, html, minorEdit, meta.Labels) if err != nil { log.Fatal(err) } diff --git a/pkg/confluence/api.go b/pkg/confluence/api.go index 4d24a17..188bfbd 100644 --- a/pkg/confluence/api.go +++ b/pkg/confluence/api.go @@ -434,7 +434,7 @@ func (api *API) CreatePage( } func (api *API) UpdatePage( - page *PageInfo, newContent string, newLabels []string, + page *PageInfo, newContent string, minorEdit bool, newLabels []string, ) error { nextPageVersion := page.Version.Number + 1 @@ -467,7 +467,7 @@ func (api *API) UpdatePage( "title": page.Title, "version": map[string]interface{}{ "number": nextPageVersion, - "minorEdit": false, + "minorEdit": minorEdit, }, "ancestors": oldAncestors, "body": map[string]interface{}{