From 6604c65ab7b070f96f0cadc0803c7b3465191e28 Mon Sep 17 00:00:00 2001 From: Alexander Perlman Date: Fri, 28 Feb 2025 15:25:56 +0100 Subject: [PATCH 1/3] Change module name --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6c6352c..a390532 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/andygrunwald/go-gerrit +module github.com/halvfigur/go-gerrit go 1.16 From b448094e2c3088003f449e46b6223d0908e05c80 Mon Sep 17 00:00:00 2001 From: Alexander Perlman Date: Fri, 28 Feb 2025 15:51:11 +0100 Subject: [PATCH 2/3] Add new version of ChangeFileContentInChangeEdit --- changes_edit.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/changes_edit.go b/changes_edit.go index fed06a1..bc6e852 100644 --- a/changes_edit.go +++ b/changes_edit.go @@ -2,7 +2,9 @@ package gerrit import ( "context" + "encoding/base64" "fmt" + "net/http" "net/url" ) @@ -107,6 +109,28 @@ func (s *ChangesService) ChangeFileContentInChangeEdit(ctx context.Context, chan return s.client.Do(req, nil) } +func (s *ChangesService) ChangeFileContentInChangeEditNew(ctx context.Context, changeID, filePath string, content []byte, fileMode *int) (*Response, error) { + u := fmt.Sprintf("changes/%s/edit/%s", changeID, url.QueryEscape(filePath)) + + payload := struct { + Data string `json:"binary_content"` + FileMode int `json:"file_mode,omitempty"` // FileMode is optional + }{ + Data: "data:text/plain;base64," + base64.StdEncoding.EncodeToString(content), + } + + if fileMode != nil { + payload.FileMode = *fileMode + } + + req, err := s.client.NewRequest(ctx, http.MethodPut, u, payload) + if err != nil { + return nil, err + } + + return s.client.Do(req, nil) +} + // ChangeCommitMessageInChangeEdit modify commit message. // The request body needs to include a ChangeEditMessageInput entity. // From 5868ceed53d32f098eb2cdd6d4ec2d9f5f334590 Mon Sep 17 00:00:00 2001 From: Sid Olofsson Date: Thu, 6 Mar 2025 15:18:19 +0100 Subject: [PATCH 3/3] Revert "Change module name" This reverts commit 6604c65ab7b070f96f0cadc0803c7b3465191e28. --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index a390532..6c6352c 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/halvfigur/go-gerrit +module github.com/andygrunwald/go-gerrit go 1.16