From 9b91ee3344cca563bc173a28ae143943a2acb8cf Mon Sep 17 00:00:00 2001 From: Stephen Paulger Date: Wed, 10 Apr 2024 10:45:16 +0100 Subject: [PATCH] Add option to pass a version message --- main.go | 8 +++++++- pkg/confluence/api.go | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 740f8b2..ce27d3b 100644 --- a/main.go +++ b/main.go @@ -84,6 +84,12 @@ var flags = []cli.Flag{ Usage: "don't send notifications while updating Confluence page.", EnvVars: []string{"MARK_MINOR_EDIT"}, }), + altsrc.NewStringFlag(&cli.StringFlag{ + Name: "version-message", + Value: "", + Usage: "add a message to the page version, to explain the edit (default: \"\")", + EnvVars: []string{"MARK_VERSION_MESSAGE"}, + }), altsrc.NewStringFlag(&cli.StringFlag{ Name: "color", Value: "auto", @@ -511,7 +517,7 @@ func processFile( html = buffer.String() } - err = api.UpdatePage(target, html, cCtx.Bool("minor-edit"), meta.Labels, meta.ContentAppearance) + err = api.UpdatePage(target, html, cCtx.Bool("minor-edit"), cCtx.String("version-message"), meta.Labels, meta.ContentAppearance) if err != nil { log.Fatal(err) } diff --git a/pkg/confluence/api.go b/pkg/confluence/api.go index 954c43f..31be7f2 100644 --- a/pkg/confluence/api.go +++ b/pkg/confluence/api.go @@ -503,7 +503,7 @@ func (api *API) CreatePage( return request.Response.(*PageInfo), nil } -func (api *API) UpdatePage(page *PageInfo, newContent string, minorEdit bool, newLabels []string, appearance string) error { +func (api *API) UpdatePage(page *PageInfo, newContent string, minorEdit bool, versionMessage string, newLabels []string, appearance string) error { nextPageVersion := page.Version.Number + 1 oldAncestors := []map[string]interface{}{} @@ -532,6 +532,7 @@ func (api *API) UpdatePage(page *PageInfo, newContent string, minorEdit bool, ne "version": map[string]interface{}{ "number": nextPageVersion, "minorEdit": minorEdit, + "message": versionMessage, }, "ancestors": oldAncestors, "body": map[string]interface{}{