1
1
package gerrit
2
2
3
3
import (
4
+ "context"
4
5
"fmt"
5
6
"net/url"
6
7
)
@@ -36,15 +37,15 @@ type ChangeEditDetailOptions struct {
36
37
// Edits aren’t tracked in the database.
37
38
//
38
39
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-edit-detail
39
- func (s * ChangesService ) GetChangeEditDetails (changeID string , opt * ChangeEditDetailOptions ) (* EditInfo , * Response , error ) {
40
+ func (s * ChangesService ) GetChangeEditDetails (ctx context. Context , changeID string , opt * ChangeEditDetailOptions ) (* EditInfo , * Response , error ) {
40
41
u := fmt .Sprintf ("changes/%s/edit" , changeID )
41
42
42
43
u , err := addOptions (u , opt )
43
44
if err != nil {
44
45
return nil , nil , err
45
46
}
46
47
47
- req , err := s .client .NewRequest ("GET" , u , nil )
48
+ req , err := s .client .NewRequest (ctx , "GET" , u , nil )
48
49
if err != nil {
49
50
return nil , nil , err
50
51
}
@@ -62,10 +63,10 @@ func (s *ChangesService) GetChangeEditDetails(changeID string, opt *ChangeEditDe
62
63
// Currently only web links are returned.
63
64
//
64
65
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-edit-meta-data
65
- func (s * ChangesService ) RetrieveMetaDataOfAFileFromChangeEdit (changeID , filePath string ) (* EditFileInfo , * Response , error ) {
66
+ func (s * ChangesService ) RetrieveMetaDataOfAFileFromChangeEdit (ctx context. Context , changeID , filePath string ) (* EditFileInfo , * Response , error ) {
66
67
u := fmt .Sprintf ("changes/%s/edit/%s/meta" , changeID , filePath )
67
68
68
- req , err := s .client .NewRequest ("GET" , u , nil )
69
+ req , err := s .client .NewRequest (ctx , "GET" , u , nil )
69
70
if err != nil {
70
71
return nil , nil , err
71
72
}
@@ -83,9 +84,9 @@ func (s *ChangesService) RetrieveMetaDataOfAFileFromChangeEdit(changeID, filePat
83
84
// The commit message is returned as base64 encoded string.
84
85
//
85
86
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-edit-message
86
- func (s * ChangesService ) RetrieveCommitMessageFromChangeEdit (changeID string ) (string , * Response , error ) {
87
+ func (s * ChangesService ) RetrieveCommitMessageFromChangeEdit (ctx context. Context , changeID string ) (string , * Response , error ) {
87
88
u := fmt .Sprintf ("changes/%s/edit:message" , changeID )
88
- return getStringResponseWithoutOptions (s .client , u )
89
+ return getStringResponseWithoutOptions (ctx , s .client , u )
89
90
}
90
91
91
92
// ChangeFileContentInChangeEdit put content of a file to a change edit.
@@ -95,10 +96,10 @@ func (s *ChangesService) RetrieveCommitMessageFromChangeEdit(changeID string) (s
95
96
// As response “204 No Content” is returned.
96
97
//
97
98
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#put-edit-file
98
- func (s * ChangesService ) ChangeFileContentInChangeEdit (changeID , filePath , content string ) (* Response , error ) {
99
+ func (s * ChangesService ) ChangeFileContentInChangeEdit (ctx context. Context , changeID , filePath , content string ) (* Response , error ) {
99
100
u := fmt .Sprintf ("changes/%s/edit/%s" , changeID , url .QueryEscape (filePath ))
100
101
101
- req , err := s .client .NewRawPutRequest (u , content )
102
+ req , err := s .client .NewRawPutRequest (ctx , u , content )
102
103
if err != nil {
103
104
return nil , err
104
105
}
@@ -113,10 +114,10 @@ func (s *ChangesService) ChangeFileContentInChangeEdit(changeID, filePath, conte
113
114
// As response “204 No Content” is returned.
114
115
//
115
116
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#put-change-edit-message
116
- func (s * ChangesService ) ChangeCommitMessageInChangeEdit (changeID string , input * ChangeEditMessageInput ) (* Response , error ) {
117
+ func (s * ChangesService ) ChangeCommitMessageInChangeEdit (ctx context. Context , changeID string , input * ChangeEditMessageInput ) (* Response , error ) {
117
118
u := fmt .Sprintf ("changes/%s/edit:message" , changeID )
118
119
119
- req , err := s .client .NewRequest ("PUT" , u , input )
120
+ req , err := s .client .NewRequest (ctx , "PUT" , u , input )
120
121
if err != nil {
121
122
return nil , err
122
123
}
@@ -131,30 +132,30 @@ func (s *ChangesService) ChangeCommitMessageInChangeEdit(changeID string, input
131
132
// When change edit doesn’t exist for this change yet it is created.
132
133
//
133
134
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#delete-edit-file
134
- func (s * ChangesService ) DeleteFileInChangeEdit (changeID , filePath string ) (* Response , error ) {
135
+ func (s * ChangesService ) DeleteFileInChangeEdit (ctx context. Context , changeID , filePath string ) (* Response , error ) {
135
136
u := fmt .Sprintf ("changes/%s/edit/%s" , changeID , filePath )
136
- return s .client .DeleteRequest (u , nil )
137
+ return s .client .DeleteRequest (ctx , u , nil )
137
138
}
138
139
139
140
// DeleteChangeEdit deletes change edit.
140
141
//
141
142
// As response “204 No Content” is returned.
142
143
//
143
144
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#delete-edit
144
- func (s * ChangesService ) DeleteChangeEdit (changeID string ) (* Response , error ) {
145
+ func (s * ChangesService ) DeleteChangeEdit (ctx context. Context , changeID string ) (* Response , error ) {
145
146
u := fmt .Sprintf ("changes/%s/edit" , changeID )
146
- return s .client .DeleteRequest (u , nil )
147
+ return s .client .DeleteRequest (ctx , u , nil )
147
148
}
148
149
149
150
// PublishChangeEdit promotes change edit to a regular patch set.
150
151
//
151
152
// As response “204 No Content” is returned.
152
153
//
153
154
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#publish-edit
154
- func (s * ChangesService ) PublishChangeEdit (changeID , notify string ) (* Response , error ) {
155
+ func (s * ChangesService ) PublishChangeEdit (ctx context. Context , changeID , notify string ) (* Response , error ) {
155
156
u := fmt .Sprintf ("changes/%s/edit:publish" , changeID )
156
157
157
- req , err := s .client .NewRequest ("POST" , u , map [string ]string {
158
+ req , err := s .client .NewRequest (ctx , "POST" , u , map [string ]string {
158
159
"notify" : notify ,
159
160
})
160
161
if err != nil {
@@ -169,10 +170,10 @@ func (s *ChangesService) PublishChangeEdit(changeID, notify string) (*Response,
169
170
// When change edit is already based on top of the latest patch set, the response “409 Conflict” is returned.
170
171
//
171
172
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#rebase-edit
172
- func (s * ChangesService ) RebaseChangeEdit (changeID string ) (* Response , error ) {
173
+ func (s * ChangesService ) RebaseChangeEdit (ctx context. Context , changeID string ) (* Response , error ) {
173
174
u := fmt .Sprintf ("changes/%s/edit:rebase" , changeID )
174
175
175
- req , err := s .client .NewRequest ("POST" , u , nil )
176
+ req , err := s .client .NewRequest (ctx , "POST" , u , nil )
176
177
if err != nil {
177
178
return nil , err
178
179
}
@@ -190,10 +191,10 @@ func (s *ChangesService) RebaseChangeEdit(changeID string) (*Response, error) {
190
191
// If only the content type is required, callers should use HEAD to avoid downloading the encoded file contents.
191
192
//
192
193
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-edit-file
193
- func (s * ChangesService ) RetrieveFileContentFromChangeEdit (changeID , filePath string ) (* string , * Response , error ) {
194
+ func (s * ChangesService ) RetrieveFileContentFromChangeEdit (ctx context. Context , changeID , filePath string ) (* string , * Response , error ) {
194
195
u := fmt .Sprintf ("changes/%s/edit/%s" , changeID , filePath )
195
196
196
- req , err := s .client .NewRequest ("GET" , u , nil )
197
+ req , err := s .client .NewRequest (ctx , "GET" , u , nil )
197
198
if err != nil {
198
199
return nil , nil , err
199
200
}
@@ -214,10 +215,10 @@ func (s *ChangesService) RetrieveFileContentFromChangeEdit(changeID, filePath st
214
215
// For further documentation please have a look at RetrieveFileContentFromChangeEdit.
215
216
//
216
217
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-edit-file
217
- func (s * ChangesService ) RetrieveFileContentTypeFromChangeEdit (changeID , filePath string ) (* Response , error ) {
218
+ func (s * ChangesService ) RetrieveFileContentTypeFromChangeEdit (ctx context. Context , changeID , filePath string ) (* Response , error ) {
218
219
u := fmt .Sprintf ("changes/%s/edit/%s" , changeID , filePath )
219
220
220
- req , err := s .client .NewRequest ("HEAD" , u , nil )
221
+ req , err := s .client .NewRequest (ctx , "HEAD" , u , nil )
221
222
if err != nil {
222
223
return nil , err
223
224
}
0 commit comments