Skip to content

Commit

Permalink
Add option to pass a version message
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenpaulger authored and mrueg committed Apr 11, 2024
1 parent b7cb182 commit 9b91ee3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/confluence/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}

Expand Down Expand Up @@ -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{}{
Expand Down

0 comments on commit 9b91ee3

Please sign in to comment.